bsalomon@google.com | 81c3f8d | 2011-08-03 15:18:33 +0000 | [diff] [blame] | 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 | |
egdaniel | 8dc7c3a | 2015-04-16 11:22:42 -0700 | [diff] [blame] | 9 | #ifndef GrGLStencilAttachment_DEFINED |
| 10 | #define GrGLStencilAttachment_DEFINED |
bsalomon@google.com | 81c3f8d | 2011-08-03 15:18:33 +0000 | [diff] [blame] | 11 | |
tomhudson@google.com | 6bf38b5 | 2012-02-14 15:11:59 +0000 | [diff] [blame] | 12 | #include "gl/GrGLInterface.h" |
egdaniel | 8dc7c3a | 2015-04-16 11:22:42 -0700 | [diff] [blame] | 13 | #include "GrStencilAttachment.h" |
bsalomon@google.com | 81c3f8d | 2011-08-03 15:18:33 +0000 | [diff] [blame] | 14 | |
egdaniel | 8dc7c3a | 2015-04-16 11:22:42 -0700 | [diff] [blame] | 15 | class GrGLStencilAttachment : public GrStencilAttachment { |
bsalomon@google.com | 81c3f8d | 2011-08-03 15:18:33 +0000 | [diff] [blame] | 16 | public: |
caryclark@google.com | cf6285b | 2012-06-06 12:09:01 +0000 | [diff] [blame] | 17 | static const GrGLenum kUnknownInternalFormat = ~0U; |
| 18 | static const GrGLuint kUnknownBitCount = ~0U; |
bsalomon@google.com | 81c3f8d | 2011-08-03 15:18:33 +0000 | [diff] [blame] | 19 | struct Format { |
| 20 | GrGLenum fInternalFormat; |
| 21 | GrGLuint fStencilBits; |
| 22 | GrGLuint fTotalBits; |
| 23 | bool fPacked; |
| 24 | }; |
| 25 | |
kkinnunen | 36c57df | 2015-01-27 00:30:18 -0800 | [diff] [blame] | 26 | struct IDDesc { |
kkinnunen | 2e6055b | 2016-04-22 01:48:29 -0700 | [diff] [blame] | 27 | IDDesc() : fRenderbufferID(0) {} |
kkinnunen | 36c57df | 2015-01-27 00:30:18 -0800 | [diff] [blame] | 28 | GrGLuint fRenderbufferID; |
kkinnunen | 36c57df | 2015-01-27 00:30:18 -0800 | [diff] [blame] | 29 | }; |
| 30 | |
egdaniel | 8dc7c3a | 2015-04-16 11:22:42 -0700 | [diff] [blame] | 31 | GrGLStencilAttachment(GrGpu* gpu, |
kkinnunen | 2e6055b | 2016-04-22 01:48:29 -0700 | [diff] [blame] | 32 | const IDDesc& idDesc, |
| 33 | int width, int height, |
| 34 | int sampleCnt, |
| 35 | const Format& format) |
| 36 | : GrStencilAttachment(gpu, width, height, format.fStencilBits, sampleCnt) |
bsalomon@google.com | 81c3f8d | 2011-08-03 15:18:33 +0000 | [diff] [blame] | 37 | , fFormat(format) |
kkinnunen | 36c57df | 2015-01-27 00:30:18 -0800 | [diff] [blame] | 38 | , fRenderbufferID(idDesc.fRenderbufferID) { |
kkinnunen | 2e6055b | 2016-04-22 01:48:29 -0700 | [diff] [blame] | 39 | this->registerWithCache(SkBudgeted::kYes); |
bsalomon@google.com | 81c3f8d | 2011-08-03 15:18:33 +0000 | [diff] [blame] | 40 | } |
| 41 | |
bsalomon@google.com | 81c3f8d | 2011-08-03 15:18:33 +0000 | [diff] [blame] | 42 | GrGLuint renderbufferID() const { |
| 43 | return fRenderbufferID; |
| 44 | } |
| 45 | |
bsalomon@google.com | 0b77d68 | 2011-08-19 13:28:54 +0000 | [diff] [blame] | 46 | const Format& format() const { return fFormat; } |
bsalomon@google.com | 81c3f8d | 2011-08-03 15:18:33 +0000 | [diff] [blame] | 47 | |
| 48 | protected: |
robertphillips@google.com | d6bbbf8 | 2012-09-05 15:46:34 +0000 | [diff] [blame] | 49 | // overrides of GrResource |
mtklein | 36352bf | 2015-03-25 18:17:31 -0700 | [diff] [blame] | 50 | void onRelease() override; |
| 51 | void onAbandon() override; |
ericrk | 0a5fa48 | 2015-09-15 14:16:10 -0700 | [diff] [blame] | 52 | void setMemoryBacking(SkTraceMemoryDump* traceMemoryDump, |
| 53 | const SkString& dumpName) const override; |
bsalomon@google.com | 81c3f8d | 2011-08-03 15:18:33 +0000 | [diff] [blame] | 54 | |
| 55 | private: |
mtklein | 36352bf | 2015-03-25 18:17:31 -0700 | [diff] [blame] | 56 | size_t onGpuMemorySize() const override; |
bsalomon | 69ed47f | 2014-11-12 11:13:39 -0800 | [diff] [blame] | 57 | |
bsalomon@google.com | 81c3f8d | 2011-08-03 15:18:33 +0000 | [diff] [blame] | 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 | |
egdaniel | 8dc7c3a | 2015-04-16 11:22:42 -0700 | [diff] [blame] | 64 | typedef GrStencilAttachment INHERITED; |
bsalomon@google.com | 81c3f8d | 2011-08-03 15:18:33 +0000 | [diff] [blame] | 65 | }; |
| 66 | |
| 67 | #endif |