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 | |
| 11 | #include "GrRenderTargetProxy.h" |
| 12 | #include "GrTextureProxy.h" |
| 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 |
Greg Daniel | 4065d45 | 2018-11-16 15:43:41 -0500 | [diff] [blame] | 31 | GrTextureRenderTargetProxy(const GrCaps&, const GrBackendFormat&, const GrSurfaceDesc&, |
| 32 | GrSurfaceOrigin, GrMipMapped, SkBackingFit, SkBudgeted, |
| 33 | GrInternalSurfaceFlags); |
Robert Phillips | 84a8120 | 2016-11-04 11:59:10 -0400 | [diff] [blame] | 34 | |
Chris Dalton | 706a6ff | 2017-11-29 22:01:06 -0700 | [diff] [blame] | 35 | // Lazy-callback version |
Greg Daniel | 457469c | 2018-02-08 15:05:44 -0500 | [diff] [blame] | 36 | GrTextureRenderTargetProxy(LazyInstantiateCallback&&, LazyInstantiationType, |
Greg Daniel | 4065d45 | 2018-11-16 15:43:41 -0500 | [diff] [blame] | 37 | const GrBackendFormat&, const GrSurfaceDesc& desc, GrSurfaceOrigin, |
| 38 | GrMipMapped, SkBackingFit, SkBudgeted, GrInternalSurfaceFlags); |
Chris Dalton | 706a6ff | 2017-11-29 22:01:06 -0700 | [diff] [blame] | 39 | |
Robert Phillips | 84a8120 | 2016-11-04 11:59:10 -0400 | [diff] [blame] | 40 | // Wrapped version |
Robert Phillips | 066f020 | 2017-07-25 10:16:35 -0400 | [diff] [blame] | 41 | GrTextureRenderTargetProxy(sk_sp<GrSurface>, GrSurfaceOrigin); |
Robert Phillips | 84a8120 | 2016-11-04 11:59:10 -0400 | [diff] [blame] | 42 | |
Robert Phillips | eee4d6e | 2017-06-05 09:26:07 -0400 | [diff] [blame] | 43 | bool instantiate(GrResourceProvider*) override; |
Robert Phillips | 5af44de | 2017-07-18 14:49:38 -0400 | [diff] [blame] | 44 | sk_sp<GrSurface> createSurface(GrResourceProvider*) const override; |
Brian Salomon | bb5711a | 2017-05-17 13:49:59 -0400 | [diff] [blame] | 45 | |
| 46 | size_t onUninstantiatedGpuMemorySize() const override; |
Chris Dalton | 706a6ff | 2017-11-29 22:01:06 -0700 | [diff] [blame] | 47 | |
Greg Daniel | 849dce1 | 2018-04-24 14:32:53 -0400 | [diff] [blame] | 48 | SkDEBUGCODE(void onValidateSurface(const GrSurface*) override;) |
Robert Phillips | 84a8120 | 2016-11-04 11:59:10 -0400 | [diff] [blame] | 49 | }; |
| 50 | |
| 51 | #ifdef SK_BUILD_FOR_WIN |
| 52 | #pragma warning(pop) |
| 53 | #endif |
| 54 | |
| 55 | #endif |