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 GrGLAttachment : public GrAttachment { 15 public: 16 struct IDDesc { IDDescIDDesc17 IDDesc() : fRenderbufferID(0) {} 18 GrGLuint fRenderbufferID; 19 }; 20 GrGLAttachment(GrGpu * gpu,const IDDesc & idDesc,SkISize dimensions,UsageFlags supportedUsages,int sampleCnt,GrGLFormat format)21 GrGLAttachment( 22 GrGpu* gpu, const IDDesc& idDesc, SkISize dimensions, UsageFlags supportedUsages, 23 int sampleCnt, GrGLFormat format) 24 : GrAttachment(gpu, dimensions, supportedUsages, sampleCnt, GrMipmapped::kNo, 25 GrProtected::kNo) 26 , fFormat(format) 27 , fRenderbufferID(idDesc.fRenderbufferID) { 28 SkASSERT(supportedUsages == UsageFlags::kStencilAttachment || 29 supportedUsages == UsageFlags::kColorAttachment); 30 this->registerWithCache(SkBudgeted::kYes); 31 } 32 33 GrBackendFormat backendFormat() const override; 34 renderbufferID()35 GrGLuint renderbufferID() const { return fRenderbufferID; } 36 format()37 GrGLFormat format() const { return fFormat; } 38 39 protected: 40 // overrides of GrResource 41 void onRelease() override; 42 void onAbandon() override; 43 void setMemoryBacking(SkTraceMemoryDump* traceMemoryDump, 44 const SkString& dumpName) const override; 45 46 private: 47 GrGLFormat fFormat; 48 49 // may be zero for external SBs associated with external RTs 50 // (we don't require the client to give us the id, just tell 51 // us how many bits of stencil there are). 52 GrGLuint fRenderbufferID; 53 54 using INHERITED = GrAttachment; 55 }; 56 57 #endif 58