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