1 2 /* 3 * Copyright 2011 Google Inc. 4 * 5 * Use of this source code is governed by a BSD-style license that can be 6 * found in the LICENSE file. 7 */ 8 9 10 #ifndef GrGLStencilBuffer_DEFINED 11 #define GrGLStencilBuffer_DEFINED 12 13 #include "gl/GrGLInterface.h" 14 #include "../GrStencilBuffer.h" 15 16 class GrGLStencilBuffer : public GrStencilBuffer { 17 public: 18 static const GrGLenum kUnknownInternalFormat = ~0; 19 static const GrGLuint kUnknownBitCount = ~0; 20 struct Format { 21 GrGLenum fInternalFormat; 22 GrGLuint fStencilBits; 23 GrGLuint fTotalBits; 24 bool fPacked; 25 }; 26 GrGLStencilBuffer(GrGpu * gpu,GrGLint rbid,int width,int height,int sampleCnt,const Format & format)27 GrGLStencilBuffer(GrGpu* gpu, GrGLint rbid, 28 int width, int height, 29 int sampleCnt, 30 const Format& format) 31 : GrStencilBuffer(gpu, width, height, format.fStencilBits, sampleCnt) 32 , fFormat(format) 33 , fRenderbufferID(rbid) { 34 } 35 36 virtual ~GrGLStencilBuffer(); 37 38 virtual size_t sizeInBytes() const; 39 renderbufferID()40 GrGLuint renderbufferID() const { 41 return fRenderbufferID; 42 } 43 format()44 const Format& format() const { return fFormat; } 45 46 protected: 47 virtual void onRelease(); 48 49 virtual void onAbandon(); 50 51 private: 52 Format fFormat; 53 // may be zero for external SBs associated with external RTs 54 // (we don't require the client to give us the id, just tell 55 // us how many bits of stencil there are). 56 GrGLuint fRenderbufferID; 57 58 typedef GrStencilBuffer INHERITED; 59 }; 60 61 #endif 62