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