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 GrGLStencilAttachment_DEFINED | 9 #ifndef GrGLStencilAttachment_DEFINED |
10 #define GrGLStencilAttachment_DEFINED | 10 #define GrGLStencilAttachment_DEFINED |
11 | 11 |
12 #include "gl/GrGLInterface.h" | 12 #include "gl/GrGLInterface.h" |
13 #include "GrStencilAttachment.h" | 13 #include "GrStencilAttachment.h" |
14 | 14 |
15 class GrGLStencilAttachment : public GrStencilAttachment { | 15 class GrGLStencilAttachment : public GrStencilAttachment { |
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 { | 26 struct IDDesc { |
27 IDDesc() : fRenderbufferID(0), fLifeCycle(kCached_LifeCycle) {} | 27 IDDesc() : fRenderbufferID(0) {} |
28 GrGLuint fRenderbufferID; | 28 GrGLuint fRenderbufferID; |
29 GrGpuResource::LifeCycle fLifeCycle; | |
30 }; | 29 }; |
31 | 30 |
32 GrGLStencilAttachment(GrGpu* gpu, | 31 GrGLStencilAttachment(GrGpu* gpu, |
33 const IDDesc& idDesc, | 32 const IDDesc& idDesc, |
34 int width, int height, | 33 int width, int height, |
35 int sampleCnt, | 34 int sampleCnt, |
36 const Format& format) | 35 const Format& format) |
37 : GrStencilAttachment(gpu, idDesc.fLifeCycle, width, height, format.fSte
ncilBits, sampleCnt) | 36 : GrStencilAttachment(gpu, width, height, format.fStencilBits, sampleCnt
) |
38 , fFormat(format) | 37 , fFormat(format) |
39 , fRenderbufferID(idDesc.fRenderbufferID) { | 38 , fRenderbufferID(idDesc.fRenderbufferID) { |
40 this->registerWithCache(); | 39 this->registerWithCache(SkBudgeted::kYes); |
41 } | 40 } |
42 | 41 |
43 GrGLuint renderbufferID() const { | 42 GrGLuint renderbufferID() const { |
44 return fRenderbufferID; | 43 return fRenderbufferID; |
45 } | 44 } |
46 | 45 |
47 const Format& format() const { return fFormat; } | 46 const Format& format() const { return fFormat; } |
48 | 47 |
49 protected: | 48 protected: |
50 // overrides of GrResource | 49 // overrides of GrResource |
51 void onRelease() override; | 50 void onRelease() override; |
52 void onAbandon() override; | 51 void onAbandon() override; |
53 void setMemoryBacking(SkTraceMemoryDump* traceMemoryDump, | 52 void setMemoryBacking(SkTraceMemoryDump* traceMemoryDump, |
54 const SkString& dumpName) const override; | 53 const SkString& dumpName) const override; |
55 | 54 |
56 private: | 55 private: |
57 size_t onGpuMemorySize() const override; | 56 size_t onGpuMemorySize() const override; |
58 | 57 |
59 Format fFormat; | 58 Format fFormat; |
60 // may be zero for external SBs associated with external RTs | 59 // may be zero for external SBs associated with external RTs |
61 // (we don't require the client to give us the id, just tell | 60 // (we don't require the client to give us the id, just tell |
62 // us how many bits of stencil there are). | 61 // us how many bits of stencil there are). |
63 GrGLuint fRenderbufferID; | 62 GrGLuint fRenderbufferID; |
64 | 63 |
65 typedef GrStencilAttachment INHERITED; | 64 typedef GrStencilAttachment INHERITED; |
66 }; | 65 }; |
67 | 66 |
68 #endif | 67 #endif |
OLD | NEW |