blob: f083e7155fb369a7042d399083673588403ffeff [file] [log] [blame]
Brian Osman45580d32016-11-23 09:37:01 -05001/*
2 * Copyright 2016 Google Inc.
3 *
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
6 */
7
8#ifndef GrTextureContext_DEFINED
9#define GrTextureContext_DEFINED
10
11#include "GrSurfaceContext.h"
12#include "../private/GrTextureProxy.h"
13
14class GrContext;
15class GrDrawingManager;
16class GrSurface;
17class GrTextureOpList;
18class GrTextureProxy;
19struct SkIPoint;
20struct SkIRect;
21
22/**
23 * A helper object to orchestrate commands (currently just copies) for GrSurfaces that are
24 * GrTextures and not GrRenderTargets.
25 */
26class SK_API GrTextureContext : public GrSurfaceContext {
27public:
28 ~GrTextureContext() override;
29
Robert Phillipsf200a902017-01-30 13:27:37 -050030 GrSurfaceProxy* asSurfaceProxy() override { return fTextureProxy.get(); }
31 const GrSurfaceProxy* asSurfaceProxy() const override { return fTextureProxy.get(); }
32 sk_sp<GrSurfaceProxy> asSurfaceProxyRef() override { return fTextureProxy; }
33
34 GrTextureProxy* asTextureProxy() override { return fTextureProxy.get(); }
Greg Daniele252f082017-10-23 16:05:23 -040035 const GrTextureProxy* asTextureProxy() const override { return fTextureProxy.get(); }
Robert Phillipsf200a902017-01-30 13:27:37 -050036 sk_sp<GrTextureProxy> asTextureProxyRef() override { return fTextureProxy; }
37
38 GrRenderTargetProxy* asRenderTargetProxy() override;
39 sk_sp<GrRenderTargetProxy> asRenderTargetProxyRef() override;
Robert Phillips27341362016-12-14 08:46:47 -050040
Brian Osman45580d32016-11-23 09:37:01 -050041protected:
Robert Phillips2c862492017-01-18 10:08:39 -050042 GrTextureContext(GrContext*, GrDrawingManager*, sk_sp<GrTextureProxy>,
43 sk_sp<SkColorSpace>, GrAuditTrail*, GrSingleOwner*);
Brian Osman45580d32016-11-23 09:37:01 -050044
Robert Phillips2de8cfa2017-06-28 10:33:41 -040045 SkDEBUGCODE(void validate() const override;)
Brian Osman45580d32016-11-23 09:37:01 -050046
47private:
48 friend class GrDrawingManager; // for ctor
49
Robert Phillips2de8cfa2017-06-28 10:33:41 -040050 GrOpList* getOpList() override;
Brian Osman45580d32016-11-23 09:37:01 -050051
Brian Osman45580d32016-11-23 09:37:01 -050052 sk_sp<GrTextureProxy> fTextureProxy;
53
54 // In MDB-mode the GrOpList can be closed by some other renderTargetContext that has picked
55 // it up. For this reason, the GrOpList should only ever be accessed via 'getOpList'.
Robert Phillipsdc83b892017-04-13 12:23:54 -040056 sk_sp<GrTextureOpList> fOpList;
Robert Phillipse2f7d182016-12-15 09:23:05 -050057
58 typedef GrSurfaceContext INHERITED;
Brian Osman45580d32016-11-23 09:37:01 -050059};
60
61#endif