Debian Codegraph @

src/gpu/ganesh/gl/GrGLTextureRenderTarget.h

raw
1 /*
2 * Copyright 2014 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 GrGLTextureRenderTarget_DEFINED
8 #define GrGLTextureRenderTarget_DEFINED
9
10 #include "include/core/SkRefCnt.h"
11 #include "include/gpu/ganesh/GrBackendSurface.h"
12 #include "src/gpu/ganesh/gl/GrGLRenderTarget.h"
13 #include "src/gpu/ganesh/gl/GrGLTexture.h"
14
15 #include <cstddef>
16 #include <string_view>
17
18 class GrGLGpu;
19 class GrGLTextureParameters;
20 class SkTraceMemoryDump;
21 enum class GrMipmapStatus;
22 enum class GrWrapCacheable : bool;
23 namespace skgpu {
24 enum class Budgeted : bool;
25 }
26
27 #ifdef SK_BUILD_FOR_WIN
28 // Windows gives bogus warnings about inheriting asTexture/asRenderTarget via dominance.
29 #pragma warning(push)
30 #pragma warning(disable: 4250)
31 #endif
32
33 class GrGLTextureRenderTarget : public GrGLTexture, public GrGLRenderTarget {
34 public:
35 // We're virtually derived from GrSurface (via both GrGLTexture and GrGLRenderTarget) so its
36 // constructor must be explicitly called.
37 GrGLTextureRenderTarget(GrGLGpu* gpu,
38 skgpu::Budgeted budgeted,
39 int sampleCount,
40 const GrGLTexture::Desc& texDesc,
41 const GrGLRenderTarget::IDs&,
42 GrMipmapStatus,
43 std::string_view label);
44
45 bool canAttemptStencilAttachment(bool useMultisampleFBO) const override;
46
47 void dumpMemoryStatistics(SkTraceMemoryDump* traceMemoryDump) const override;
48
49 static sk_sp<GrGLTextureRenderTarget> MakeWrapped(GrGLGpu* gpu,
50 int sampleCount,
51 const GrGLTexture::Desc&,
52 sk_sp<GrGLTextureParameters>,
53 const GrGLRenderTarget::IDs&,
54 GrWrapCacheable,
55 GrMipmapStatus,
56 std::string_view label);
57
58 GrBackendFormat backendFormat() const override {
59 // It doesn't matter if we take the texture or render target path, so just pick texture.
60 return GrGLTexture::backendFormat();
61 }
62
63 protected:
64 void onAbandon() override {
65 GrGLRenderTarget::onAbandon();
66 GrGLTexture::onAbandon();
67 }
68
69 void onRelease() override {
70 GrGLRenderTarget::onRelease();
71 GrGLTexture::onRelease();
72 }
73
74 private:
75 // Constructor for instances wrapping backend objects.
76 GrGLTextureRenderTarget(GrGLGpu* gpu,
77 int sampleCount,
78 const GrGLTexture::Desc& texDesc,
79 sk_sp<GrGLTextureParameters> parameters,
80 const GrGLRenderTarget::IDs& ids,
81 GrWrapCacheable,
82 GrMipmapStatus,
83 std::string_view label);
84
85 size_t onGpuMemorySize() const override;
86
87 void onSetLabel() override;
88 };
89
90 #ifdef SK_BUILD_FOR_WIN
91 #pragma warning(pop)
92 #endif
93
94 #endif