Robert Phillips | 84a8120 | 2016-11-04 11:59:10 -0400 | [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 GrTextureRenderTargetProxy_DEFINED |
| 9 | #define GrTextureRenderTargetProxy_DEFINED |
| 10 | |
Greg Daniel | f91aeb2 | 2019-06-18 09:58:02 -0400 | [diff] [blame] | 11 | #include "src/gpu/GrRenderTargetProxy.h" |
| 12 | #include "src/gpu/GrTextureProxy.h" |
Robert Phillips | 84a8120 | 2016-11-04 11:59:10 -0400 | [diff] [blame] | 13 | |
| 14 | #ifdef SK_BUILD_FOR_WIN |
| 15 | // Windows gives warnings about inheriting asTextureProxy/asRenderTargetProxy via dominance. |
| 16 | #pragma warning(push) |
| 17 | #pragma warning(disable: 4250) |
| 18 | #endif |
| 19 | |
| 20 | // This class delays the acquisition of RenderTargets that are also textures until |
| 21 | // they are actually required |
| 22 | // Beware: the uniqueID of the TextureRenderTargetProxy will usually be different than |
| 23 | // the uniqueID of the RenderTarget/Texture it represents! |
Brian Osman | 086679b | 2018-09-10 16:26:51 -0400 | [diff] [blame] | 24 | class GrTextureRenderTargetProxy : public GrRenderTargetProxy, public GrTextureProxy { |
Robert Phillips | 84a8120 | 2016-11-04 11:59:10 -0400 | [diff] [blame] | 25 | private: |
Robert Phillips | 0bd24dc | 2018-01-16 08:06:32 -0500 | [diff] [blame] | 26 | // DDL TODO: rm the GrSurfaceProxy friending |
Robert Phillips | 3743013 | 2016-11-09 06:50:43 -0500 | [diff] [blame] | 27 | friend class GrSurfaceProxy; // for ctors |
Robert Phillips | 0bd24dc | 2018-01-16 08:06:32 -0500 | [diff] [blame] | 28 | friend class GrProxyProvider; // for ctors |
Robert Phillips | 3743013 | 2016-11-09 06:50:43 -0500 | [diff] [blame] | 29 | |
Robert Phillips | 84a8120 | 2016-11-04 11:59:10 -0400 | [diff] [blame] | 30 | // Deferred version |
Brian Salomon | beb7f52 | 2019-08-30 16:19:42 -0400 | [diff] [blame] | 31 | GrTextureRenderTargetProxy(const GrCaps&, |
| 32 | const GrBackendFormat&, |
| 33 | const GrSurfaceDesc&, |
| 34 | int sampleCnt, |
| 35 | GrSurfaceOrigin, |
| 36 | GrMipMapped, |
| 37 | GrMipMapsStatus, |
| 38 | const GrSwizzle& textureSwizzle, |
| 39 | const GrSwizzle& outputSwizzle, |
| 40 | SkBackingFit, |
| 41 | SkBudgeted, |
| 42 | GrProtected, |
| 43 | GrInternalSurfaceFlags, |
| 44 | UseAllocator); |
Robert Phillips | 84a8120 | 2016-11-04 11:59:10 -0400 | [diff] [blame] | 45 | |
Chris Dalton | 706a6ff | 2017-11-29 22:01:06 -0700 | [diff] [blame] | 46 | // Lazy-callback version |
Brian Salomon | beb7f52 | 2019-08-30 16:19:42 -0400 | [diff] [blame] | 47 | GrTextureRenderTargetProxy(const GrCaps&, |
| 48 | LazyInstantiateCallback&&, |
| 49 | const GrBackendFormat&, |
| 50 | const GrSurfaceDesc& desc, |
| 51 | int sampleCnt, |
| 52 | GrSurfaceOrigin, |
| 53 | GrMipMapped, |
| 54 | GrMipMapsStatus, |
| 55 | const GrSwizzle& textureSwizzle, |
| 56 | const GrSwizzle& outputSwizzle, |
| 57 | SkBackingFit, |
| 58 | SkBudgeted, |
| 59 | GrProtected, |
| 60 | GrInternalSurfaceFlags, |
| 61 | UseAllocator); |
Chris Dalton | 706a6ff | 2017-11-29 22:01:06 -0700 | [diff] [blame] | 62 | |
Robert Phillips | 84a8120 | 2016-11-04 11:59:10 -0400 | [diff] [blame] | 63 | // Wrapped version |
Brian Salomon | beb7f52 | 2019-08-30 16:19:42 -0400 | [diff] [blame] | 64 | GrTextureRenderTargetProxy(sk_sp<GrSurface>, |
| 65 | GrSurfaceOrigin, |
| 66 | const GrSwizzle& textureSwizzle, |
| 67 | const GrSwizzle& outputSwizzle, |
| 68 | UseAllocator); |
Robert Phillips | 84a8120 | 2016-11-04 11:59:10 -0400 | [diff] [blame] | 69 | |
Chris Dalton | 3f7932e | 2019-08-19 00:39:13 -0600 | [diff] [blame] | 70 | void initSurfaceFlags(const GrCaps&); |
| 71 | |
Robert Phillips | 10d1721 | 2019-04-24 14:09:10 -0400 | [diff] [blame] | 72 | bool instantiate(GrResourceProvider*) override; |
Robert Phillips | 5af44de | 2017-07-18 14:49:38 -0400 | [diff] [blame] | 73 | sk_sp<GrSurface> createSurface(GrResourceProvider*) const override; |
Brian Salomon | bb5711a | 2017-05-17 13:49:59 -0400 | [diff] [blame] | 74 | |
| 75 | size_t onUninstantiatedGpuMemorySize() const override; |
Chris Dalton | 706a6ff | 2017-11-29 22:01:06 -0700 | [diff] [blame] | 76 | |
Greg Daniel | 849dce1 | 2018-04-24 14:32:53 -0400 | [diff] [blame] | 77 | SkDEBUGCODE(void onValidateSurface(const GrSurface*) override;) |
Robert Phillips | 84a8120 | 2016-11-04 11:59:10 -0400 | [diff] [blame] | 78 | }; |
| 79 | |
| 80 | #ifdef SK_BUILD_FOR_WIN |
| 81 | #pragma warning(pop) |
| 82 | #endif |
| 83 | |
| 84 | #endif |