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/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>( 35 new GrGLAttachment(gpu, renderbufferID, dimensions, supportedUsages, sampleCnt, 36 format)); 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)53 GrGLAttachment(GrGpu* gpu, 54 GrGLuint renderbufferID, 55 SkISize dimensions, 56 UsageFlags supportedUsages, 57 int sampleCnt, 58 GrGLFormat format) 59 : GrAttachment(gpu, dimensions, supportedUsages, sampleCnt, GrMipmapped::kNo, 60 GrProtected::kNo) 61 , fFormat(format) 62 , fRenderbufferID(renderbufferID) { 63 SkASSERT(supportedUsages == UsageFlags::kStencilAttachment || 64 supportedUsages == UsageFlags::kColorAttachment); 65 this->registerWithCache(SkBudgeted::kYes); 66 } 67 68 GrGLFormat fFormat; 69 70 // may be zero for external SBs associated with external RTs 71 // (we don't require the client to give us the id, just tell 72 // us how many bits of stencil there are). 73 GrGLuint fRenderbufferID; 74 75 using INHERITED = GrAttachment; 76 }; 77 78 #endif 79