Brian Osman | 45580d3 | 2016-11-23 09:37:01 -0500 | [diff] [blame] | 1 | /* |
| 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 | |
| 14 | class GrContext; |
| 15 | class GrDrawingManager; |
| 16 | class GrSurface; |
| 17 | class GrTextureOpList; |
| 18 | class GrTextureProxy; |
| 19 | struct SkIPoint; |
| 20 | struct SkIRect; |
| 21 | |
| 22 | /** |
| 23 | * A helper object to orchestrate commands (currently just copies) for GrSurfaces that are |
| 24 | * GrTextures and not GrRenderTargets. |
| 25 | */ |
| 26 | class SK_API GrTextureContext : public GrSurfaceContext { |
| 27 | public: |
| 28 | ~GrTextureContext() override; |
| 29 | |
Robert Phillips | f200a90 | 2017-01-30 13:27:37 -0500 | [diff] [blame] | 30 | 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(); } |
| 35 | sk_sp<GrTextureProxy> asTextureProxyRef() override { return fTextureProxy; } |
| 36 | |
| 37 | GrRenderTargetProxy* asRenderTargetProxy() override; |
| 38 | sk_sp<GrRenderTargetProxy> asRenderTargetProxyRef() override; |
Robert Phillips | 2734136 | 2016-12-14 08:46:47 -0500 | [diff] [blame] | 39 | |
Brian Osman | 45580d3 | 2016-11-23 09:37:01 -0500 | [diff] [blame] | 40 | protected: |
Robert Phillips | 2c86249 | 2017-01-18 10:08:39 -0500 | [diff] [blame] | 41 | GrTextureContext(GrContext*, GrDrawingManager*, sk_sp<GrTextureProxy>, |
| 42 | sk_sp<SkColorSpace>, GrAuditTrail*, GrSingleOwner*); |
Brian Osman | 45580d3 | 2016-11-23 09:37:01 -0500 | [diff] [blame] | 43 | |
Robert Phillips | 2de8cfa | 2017-06-28 10:33:41 -0400 | [diff] [blame] | 44 | SkDEBUGCODE(void validate() const override;) |
Brian Osman | 45580d3 | 2016-11-23 09:37:01 -0500 | [diff] [blame] | 45 | |
| 46 | private: |
| 47 | friend class GrDrawingManager; // for ctor |
| 48 | |
Robert Phillips | 2de8cfa | 2017-06-28 10:33:41 -0400 | [diff] [blame] | 49 | GrOpList* getOpList() override; |
Brian Osman | 45580d3 | 2016-11-23 09:37:01 -0500 | [diff] [blame] | 50 | |
Brian Osman | 45580d3 | 2016-11-23 09:37:01 -0500 | [diff] [blame] | 51 | sk_sp<GrTextureProxy> fTextureProxy; |
| 52 | |
| 53 | // In MDB-mode the GrOpList can be closed by some other renderTargetContext that has picked |
| 54 | // it up. For this reason, the GrOpList should only ever be accessed via 'getOpList'. |
Robert Phillips | dc83b89 | 2017-04-13 12:23:54 -0400 | [diff] [blame] | 55 | sk_sp<GrTextureOpList> fOpList; |
Robert Phillips | e2f7d18 | 2016-12-15 09:23:05 -0500 | [diff] [blame] | 56 | |
| 57 | typedef GrSurfaceContext INHERITED; |
Brian Osman | 45580d3 | 2016-11-23 09:37:01 -0500 | [diff] [blame] | 58 | }; |
| 59 | |
| 60 | #endif |