1 /* 2 * Copyright 2011 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 GrGLMtlAttachment_DEFINED 9 #define GrGLMtlAttachment_DEFINED 10 11 #include "include/gpu/gl/GrGLInterface.h" 12 #include "src/gpu/ganesh/GrAttachment.h" 13 14 class GrGLGpu; 15 16 class GrGLAttachment : public GrAttachment { 17 public: 18 static sk_sp<GrGLAttachment> MakeStencil(GrGLGpu* gpu, 19 SkISize dimensions, 20 int sampleCnt, 21 GrGLFormat format); 22 23 static sk_sp<GrGLAttachment> MakeMSAA(GrGLGpu* gpu, 24 SkISize dimensions, 25 int sampleCnt, 26 GrGLFormat format); 27 MakeWrappedRenderBuffer(GrGpu * gpu,GrGLuint renderbufferID,SkISize dimensions,UsageFlags supportedUsages,int sampleCnt,GrGLFormat format)28 static sk_sp<GrGLAttachment> MakeWrappedRenderBuffer(GrGpu* gpu, 29 GrGLuint renderbufferID, 30 SkISize dimensions, 31 UsageFlags supportedUsages, 32 int sampleCnt, 33 GrGLFormat format) { 34 return sk_sp<GrGLAttachment>(new GrGLAttachment( 35 gpu, renderbufferID, dimensions, supportedUsages, sampleCnt, format, 36 /*label=*/"MakeWrappedRenderBuffer")); 37 } 38 39 GrBackendFormat backendFormat() const override; 40 renderbufferID()41 GrGLuint renderbufferID() const { return fRenderbufferID; } 42 format()43 GrGLFormat format() const { return fFormat; } 44 45 protected: 46 // overrides of GrResource 47 void onRelease() override; 48 void onAbandon() override; 49 void setMemoryBacking(SkTraceMemoryDump* traceMemoryDump, 50 const SkString& dumpName) const override; 51 52 private: GrGLAttachment(GrGpu * gpu,GrGLuint renderbufferID,SkISize dimensions,UsageFlags supportedUsages,int sampleCnt,GrGLFormat format,std::string_view label)53 GrGLAttachment(GrGpu* gpu, 54 GrGLuint renderbufferID, 55 SkISize dimensions, 56 UsageFlags supportedUsages, 57 int sampleCnt, 58 GrGLFormat format, 59 std::string_view label) 60 : GrAttachment(gpu, 61 dimensions, 62 supportedUsages, 63 sampleCnt, 64 GrMipmapped::kNo, 65 GrProtected::kNo, 66 label) 67 , fFormat(format) 68 , fRenderbufferID(renderbufferID) { 69 SkASSERT(supportedUsages == UsageFlags::kStencilAttachment || 70 supportedUsages == UsageFlags::kColorAttachment); 71 this->registerWithCache(skgpu::Budgeted::kYes); 72 } 73 74 void onSetLabel() override; 75 76 GrGLFormat fFormat; 77 78 // may be zero for external SBs associated with external RTs 79 // (we don't require the client to give us the id, just tell 80 // us how many bits of stencil there are). 81 GrGLuint fRenderbufferID; 82 83 using INHERITED = GrAttachment; 84 }; 85 86 #endif 87