blob: 2bf33ef7b2654fed79837e318b65d78b665fbf8b [file] [log] [blame]
bsalomon@google.com81c3f8d2011-08-03 15:18:33 +00001/*
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.com6bf38b52012-02-14 15:11:59 +000012#include "gl/GrGLInterface.h"
tomhudson@google.comd8f856c2012-05-10 12:13:36 +000013#include "GrStencilBuffer.h"
bsalomon@google.com81c3f8d2011-08-03 15:18:33 +000014
15class GrGLStencilBuffer : public GrStencilBuffer {
16public:
caryclark@google.comcf6285b2012-06-06 12:09:01 +000017 static const GrGLenum kUnknownInternalFormat = ~0U;
18 static const GrGLuint kUnknownBitCount = ~0U;
bsalomon@google.com81c3f8d2011-08-03 15:18:33 +000019 struct Format {
20 GrGLenum fInternalFormat;
21 GrGLuint fStencilBits;
22 GrGLuint fTotalBits;
23 bool fPacked;
24 };
25
bsalomon@google.com72830222013-01-23 20:25:22 +000026 GrGLStencilBuffer(GrGpu* gpu,
27 bool isWrapped,
28 GrGLint rbid,
bsalomon@google.com81c3f8d2011-08-03 15:18:33 +000029 int width, int height,
bsalomon@google.com558a75b2011-08-08 17:01:14 +000030 int sampleCnt,
rmistry@google.comfbfcd562012-08-23 18:09:54 +000031 const Format& format)
bsalomon@google.com72830222013-01-23 20:25:22 +000032 : GrStencilBuffer(gpu, isWrapped, width, height, format.fStencilBits, sampleCnt)
bsalomon@google.com81c3f8d2011-08-03 15:18:33 +000033 , fFormat(format)
34 , fRenderbufferID(rbid) {
35 }
36
bsalomon@google.com0b77d682011-08-19 13:28:54 +000037 virtual ~GrGLStencilBuffer();
bsalomon@google.com81c3f8d2011-08-03 15:18:33 +000038
robertphillips@google.comd6bbbf82012-09-05 15:46:34 +000039 virtual size_t sizeInBytes() const SK_OVERRIDE;
bsalomon@google.com81c3f8d2011-08-03 15:18:33 +000040
41 GrGLuint renderbufferID() const {
42 return fRenderbufferID;
43 }
44
bsalomon@google.com0b77d682011-08-19 13:28:54 +000045 const Format& format() const { return fFormat; }
bsalomon@google.com81c3f8d2011-08-03 15:18:33 +000046
47protected:
robertphillips@google.comd6bbbf82012-09-05 15:46:34 +000048 // overrides of GrResource
49 virtual void onRelease() SK_OVERRIDE;
50 virtual void onAbandon() SK_OVERRIDE;
bsalomon@google.com81c3f8d2011-08-03 15:18:33 +000051
52private:
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