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 | |
| 9 | #ifndef GrGLStencilBuffer_DEFINED |
| 10 | #define GrGLStencilBuffer_DEFINED |
| 11 | |
tomhudson@google.com | 6bf38b5 | 2012-02-14 15:11:59 +0000 | [diff] [blame] | 12 | #include "gl/GrGLInterface.h" |
tomhudson@google.com | d8f856c | 2012-05-10 12:13:36 +0000 | [diff] [blame] | 13 | #include "GrStencilBuffer.h" |
bsalomon@google.com | 81c3f8d | 2011-08-03 15:18:33 +0000 | [diff] [blame] | 14 | |
| 15 | class GrGLStencilBuffer : public GrStencilBuffer { |
| 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 | |
bsalomon@google.com | 7283022 | 2013-01-23 20:25:22 +0000 | [diff] [blame] | 26 | GrGLStencilBuffer(GrGpu* gpu, |
| 27 | bool isWrapped, |
| 28 | GrGLint rbid, |
bsalomon@google.com | 81c3f8d | 2011-08-03 15:18:33 +0000 | [diff] [blame] | 29 | int width, int height, |
bsalomon@google.com | 558a75b | 2011-08-08 17:01:14 +0000 | [diff] [blame] | 30 | int sampleCnt, |
rmistry@google.com | fbfcd56 | 2012-08-23 18:09:54 +0000 | [diff] [blame] | 31 | const Format& format) |
bsalomon@google.com | 7283022 | 2013-01-23 20:25:22 +0000 | [diff] [blame] | 32 | : GrStencilBuffer(gpu, isWrapped, width, height, format.fStencilBits, sampleCnt) |
bsalomon@google.com | 81c3f8d | 2011-08-03 15:18:33 +0000 | [diff] [blame] | 33 | , fFormat(format) |
| 34 | , fRenderbufferID(rbid) { |
| 35 | } |
| 36 | |
bsalomon@google.com | 0b77d68 | 2011-08-19 13:28:54 +0000 | [diff] [blame] | 37 | virtual ~GrGLStencilBuffer(); |
bsalomon@google.com | 81c3f8d | 2011-08-03 15:18:33 +0000 | [diff] [blame] | 38 | |
robertphillips@google.com | d6bbbf8 | 2012-09-05 15:46:34 +0000 | [diff] [blame] | 39 | virtual size_t sizeInBytes() const SK_OVERRIDE; |
bsalomon@google.com | 81c3f8d | 2011-08-03 15:18:33 +0000 | [diff] [blame] | 40 | |
| 41 | GrGLuint renderbufferID() const { |
| 42 | return fRenderbufferID; |
| 43 | } |
| 44 | |
bsalomon@google.com | 0b77d68 | 2011-08-19 13:28:54 +0000 | [diff] [blame] | 45 | const Format& format() const { return fFormat; } |
bsalomon@google.com | 81c3f8d | 2011-08-03 15:18:33 +0000 | [diff] [blame] | 46 | |
| 47 | protected: |
robertphillips@google.com | d6bbbf8 | 2012-09-05 15:46:34 +0000 | [diff] [blame] | 48 | // overrides of GrResource |
| 49 | virtual void onRelease() SK_OVERRIDE; |
| 50 | virtual void onAbandon() SK_OVERRIDE; |
bsalomon@google.com | 81c3f8d | 2011-08-03 15:18:33 +0000 | [diff] [blame] | 51 | |
| 52 | private: |
| 53 | Format fFormat; |
| 54 | // may be zero for external SBs associated with external RTs |
| 55 | // (we don't require the client to give us the id, just tell |
| 56 | // us how many bits of stencil there are). |
| 57 | GrGLuint fRenderbufferID; |
| 58 | |
| 59 | typedef GrStencilBuffer INHERITED; |
| 60 | }; |
| 61 | |
| 62 | #endif |