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