xref: /aosp_15_r20/external/skia/src/gpu/ganesh/GrTextureRenderTargetProxy.h (revision c8dee2aa9b3f27cf6c858bd81872bdeb2c07ed17)
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 #ifndef GrTextureRenderTargetProxy_DEFINED
8 #define GrTextureRenderTargetProxy_DEFINED
9 
10 #include "include/core/SkRefCnt.h"
11 #include "include/gpu/ganesh/GrTypes.h"
12 #include "include/private/base/SkDebug.h"
13 #include "src/gpu/ganesh/GrCaps.h"
14 #include "src/gpu/ganesh/GrRenderTargetProxy.h"
15 #include "src/gpu/ganesh/GrTextureProxy.h"
16 
17 #include <cstddef>
18 #include <string_view>
19 
20 class GrBackendFormat;
21 class GrResourceProvider;
22 class GrSurface;
23 enum class GrDDLProvider : bool;
24 enum class GrInternalSurfaceFlags;
25 enum class GrMipmapStatus;
26 enum class SkBackingFit;
27 struct SkISize;
28 
29 namespace skgpu {
30 enum class Budgeted : bool;
31 enum class Mipmapped : bool;
32 }  // namespace skgpu
33 
34 #ifdef SK_BUILD_FOR_WIN
35 // Windows gives warnings about inheriting asTextureProxy/asRenderTargetProxy via dominance.
36 #pragma warning(push)
37 #pragma warning(disable: 4250)
38 #endif
39 
40 // This class delays the acquisition of RenderTargets that are also textures until
41 // they are actually required
42 // Beware: the uniqueID of the TextureRenderTargetProxy will usually be different than
43 // the uniqueID of the RenderTarget/Texture it represents!
44 class GrTextureRenderTargetProxy : public GrRenderTargetProxy, public GrTextureProxy {
45 private:
46     // DDL TODO: rm the GrSurfaceProxy friending
47     friend class GrSurfaceProxy; // for ctors
48     friend class GrProxyProvider; // for ctors
49 
50     // Deferred version
51     GrTextureRenderTargetProxy(const GrCaps&,
52                                const GrBackendFormat&,
53                                SkISize,
54                                int sampleCnt,
55                                skgpu::Mipmapped,
56                                GrMipmapStatus,
57                                SkBackingFit,
58                                skgpu::Budgeted,
59                                GrProtected,
60                                GrInternalSurfaceFlags,
61                                UseAllocator,
62                                GrDDLProvider creatingProvider,
63                                std::string_view label);
64 
65     // Lazy-callback version
66     GrTextureRenderTargetProxy(const GrCaps&,
67                                LazyInstantiateCallback&&,
68                                const GrBackendFormat&,
69                                SkISize,
70                                int sampleCnt,
71                                skgpu::Mipmapped,
72                                GrMipmapStatus,
73                                SkBackingFit,
74                                skgpu::Budgeted,
75                                GrProtected,
76                                GrInternalSurfaceFlags,
77                                UseAllocator,
78                                GrDDLProvider creatingProvider,
79                                std::string_view label);
80 
81     // Wrapped version
82     GrTextureRenderTargetProxy(sk_sp<GrSurface>,
83                                UseAllocator,
84                                GrDDLProvider creatingProvider);
85 
86     void initSurfaceFlags(const GrCaps&);
87 
88     bool instantiate(GrResourceProvider*) override;
89     sk_sp<GrSurface> createSurface(GrResourceProvider*) const override;
90 
91     size_t onUninstantiatedGpuMemorySize() const override;
92     LazySurfaceDesc callbackDesc() const override;
93     SkDEBUGCODE(void onValidateSurface(const GrSurface*) override;)
94 };
95 
96 #ifdef SK_BUILD_FOR_WIN
97 #pragma warning(pop)
98 #endif
99 
100 #endif
101