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 "src/gpu/GrRenderTargetProxy.h"
12 #include "src/gpu/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!
24 class GrTextureRenderTargetProxy : public GrRenderTargetProxy, public GrTextureProxy {
25 private:
26     // DDL TODO: rm the GrSurfaceProxy friending
27     friend class GrSurfaceProxy; // for ctors
28     friend class GrProxyProvider; // for ctors
29 
30     // Deferred version
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);
45 
46     // Lazy-callback version
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);
62 
63     // Wrapped version
64     GrTextureRenderTargetProxy(sk_sp<GrSurface>,
65                                GrSurfaceOrigin,
66                                const GrSwizzle& textureSwizzle,
67                                const GrSwizzle& outputSwizzle,
68                                UseAllocator);
69 
70     void initSurfaceFlags(const GrCaps&);
71 
72     bool instantiate(GrResourceProvider*) override;
73     sk_sp<GrSurface> createSurface(GrResourceProvider*) const override;
74 
75     size_t onUninstantiatedGpuMemorySize(const GrCaps&) const override;
76 
77     SkDEBUGCODE(void onValidateSurface(const GrSurface*) override;)
78 };
79 
80 #ifdef SK_BUILD_FOR_WIN
81 #pragma warning(pop)
82 #endif
83 
84 #endif
85