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 | |
Mike Klein | c0bd9f9 | 2019-04-23 12:05:21 -0500 | [diff] [blame] | 11 | #include "src/gpu/GrSurfaceContext.h" |
Greg Daniel | f91aeb2 | 2019-06-18 09:58:02 -0400 | [diff] [blame] | 12 | #include "src/gpu/GrTextureProxy.h" |
Brian Osman | 45580d3 | 2016-11-23 09:37:01 -0500 | [diff] [blame] | 13 | |
| 14 | class GrContext; |
| 15 | class GrDrawingManager; |
| 16 | class GrSurface; |
Brian Osman | 45580d3 | 2016-11-23 09:37:01 -0500 | [diff] [blame] | 17 | class GrTextureProxy; |
| 18 | struct SkIPoint; |
| 19 | struct SkIRect; |
| 20 | |
| 21 | /** |
| 22 | * A helper object to orchestrate commands (currently just copies) for GrSurfaces that are |
| 23 | * GrTextures and not GrRenderTargets. |
| 24 | */ |
Brian Salomon | 57f211b | 2019-08-21 15:21:09 -0400 | [diff] [blame] | 25 | class GrTextureContext : public GrSurfaceContext { |
Brian Osman | 45580d3 | 2016-11-23 09:37:01 -0500 | [diff] [blame] | 26 | public: |
| 27 | ~GrTextureContext() override; |
| 28 | |
Robert Phillips | f200a90 | 2017-01-30 13:27:37 -0500 | [diff] [blame] | 29 | GrSurfaceProxy* asSurfaceProxy() override { return fTextureProxy.get(); } |
| 30 | const GrSurfaceProxy* asSurfaceProxy() const override { return fTextureProxy.get(); } |
| 31 | sk_sp<GrSurfaceProxy> asSurfaceProxyRef() override { return fTextureProxy; } |
| 32 | |
| 33 | GrTextureProxy* asTextureProxy() override { return fTextureProxy.get(); } |
Greg Daniel | e252f08 | 2017-10-23 16:05:23 -0400 | [diff] [blame] | 34 | const GrTextureProxy* asTextureProxy() const override { return fTextureProxy.get(); } |
Robert Phillips | f200a90 | 2017-01-30 13:27:37 -0500 | [diff] [blame] | 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: |
Brian Salomon | d628747 | 2019-06-24 15:50:07 -0400 | [diff] [blame] | 41 | GrTextureContext(GrRecordingContext*, |
| 42 | sk_sp<GrTextureProxy>, |
| 43 | GrColorType, |
| 44 | SkAlphaType, |
| 45 | sk_sp<SkColorSpace>); |
Brian Osman | 45580d3 | 2016-11-23 09:37:01 -0500 | [diff] [blame] | 46 | |
Robert Phillips | 2de8cfa | 2017-06-28 10:33:41 -0400 | [diff] [blame] | 47 | SkDEBUGCODE(void validate() const override;) |
Brian Osman | 45580d3 | 2016-11-23 09:37:01 -0500 | [diff] [blame] | 48 | |
| 49 | private: |
| 50 | friend class GrDrawingManager; // for ctor |
| 51 | |
Robert Phillips | 0d075de | 2019-03-04 11:08:13 -0500 | [diff] [blame] | 52 | sk_sp<GrTextureProxy> fTextureProxy; |
Brian Osman | 45580d3 | 2016-11-23 09:37:01 -0500 | [diff] [blame] | 53 | |
Robert Phillips | e2f7d18 | 2016-12-15 09:23:05 -0500 | [diff] [blame] | 54 | typedef GrSurfaceContext INHERITED; |
Brian Osman | 45580d3 | 2016-11-23 09:37:01 -0500 | [diff] [blame] | 55 | }; |
| 56 | |
| 57 | #endif |