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 | SkISize, |
34 | int sampleCnt, |
35 | GrMipmapped, |
36 | GrMipmapStatus, |
37 | SkBackingFit, |
38 | SkBudgeted, |
39 | GrProtected, |
40 | GrInternalSurfaceFlags, |
41 | UseAllocator, |
42 | GrDDLProvider creatingProvider); |
43 | |
44 | // Lazy-callback version |
45 | GrTextureRenderTargetProxy(const GrCaps&, |
46 | LazyInstantiateCallback&&, |
47 | const GrBackendFormat&, |
48 | SkISize, |
49 | int sampleCnt, |
50 | GrMipmapped, |
51 | GrMipmapStatus, |
52 | SkBackingFit, |
53 | SkBudgeted, |
54 | GrProtected, |
55 | GrInternalSurfaceFlags, |
56 | UseAllocator, |
57 | GrDDLProvider creatingProvider); |
58 | |
59 | // Wrapped version |
60 | GrTextureRenderTargetProxy(sk_sp<GrSurface>, |
61 | UseAllocator, |
62 | GrDDLProvider creatingProvider); |
63 | |
64 | void initSurfaceFlags(const GrCaps&); |
65 | |
66 | bool instantiate(GrResourceProvider*) override; |
67 | sk_sp<GrSurface> createSurface(GrResourceProvider*) const override; |
68 | |
69 | size_t onUninstantiatedGpuMemorySize(const GrCaps&) const override; |
70 | LazySurfaceDesc callbackDesc() const override; |
71 | SkDEBUGCODE(void onValidateSurface(const GrSurface*) override;) |
72 | }; |
73 | |
74 | #ifdef SK_BUILD_FOR_WIN |
75 | #pragma warning(pop) |
76 | #endif |
77 | |
78 | #endif |
79 | |