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 struct IDDesc { |
| 27 GrGLuint fRenderbufferID; |
| 28 GrGpuResource::LifeCycle fLifeCycle; |
| 29 }; |
| 30 |
26 GrGLStencilBuffer(GrGpu* gpu, | 31 GrGLStencilBuffer(GrGpu* gpu, |
27 GrGLint rbid, | 32 const IDDesc& idDesc, |
28 int width, int height, | 33 int width, int height, |
29 int sampleCnt, | 34 int sampleCnt, |
30 const Format& format) | 35 const Format& format) |
31 : GrStencilBuffer(gpu, width, height, format.fStencilBits, sampleCnt) | 36 : GrStencilBuffer(gpu, idDesc.fLifeCycle, width, height, format.fStencil
Bits, sampleCnt) |
32 , fFormat(format) | 37 , fFormat(format) |
33 , fRenderbufferID(rbid) { | 38 , fRenderbufferID(idDesc.fRenderbufferID) { |
34 this->registerWithCache(); | 39 this->registerWithCache(); |
35 } | 40 } |
36 | 41 |
37 GrGLuint renderbufferID() const { | 42 GrGLuint renderbufferID() const { |
38 return fRenderbufferID; | 43 return fRenderbufferID; |
39 } | 44 } |
40 | 45 |
41 const Format& format() const { return fFormat; } | 46 const Format& format() const { return fFormat; } |
42 | 47 |
43 protected: | 48 protected: |
44 // overrides of GrResource | 49 // overrides of GrResource |
45 void onRelease() SK_OVERRIDE; | 50 void onRelease() SK_OVERRIDE; |
46 void onAbandon() SK_OVERRIDE; | 51 void onAbandon() SK_OVERRIDE; |
47 | 52 |
48 private: | 53 private: |
49 size_t onGpuMemorySize() const SK_OVERRIDE; | 54 size_t onGpuMemorySize() const SK_OVERRIDE; |
50 | 55 |
51 Format fFormat; | 56 Format fFormat; |
52 // may be zero for external SBs associated with external RTs | 57 // may be zero for external SBs associated with external RTs |
53 // (we don't require the client to give us the id, just tell | 58 // (we don't require the client to give us the id, just tell |
54 // us how many bits of stencil there are). | 59 // us how many bits of stencil there are). |
55 GrGLuint fRenderbufferID; | 60 GrGLuint fRenderbufferID; |
56 | 61 |
57 typedef GrStencilBuffer INHERITED; | 62 typedef GrStencilBuffer INHERITED; |
58 }; | 63 }; |
59 | 64 |
60 #endif | 65 #endif |
OLD | NEW |