blob: 87bdb4a819867ad17d8e1bacc4cfdb258fc21a96 [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:
17 static const GrGLenum kUnknownInternalFormat = ~0;
bsalomon@google.comf7fa8062012-02-14 14:09:57 +000018 static const GrGLuint kUnknownBitCount = ~0;
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
26 GrGLStencilBuffer(GrGpu* gpu, GrGLint rbid,
27 int width, int height,
bsalomon@google.com558a75b2011-08-08 17:01:14 +000028 int sampleCnt,
bsalomon@google.com81c3f8d2011-08-03 15:18:33 +000029 const Format& format)
bsalomon@google.com558a75b2011-08-08 17:01:14 +000030 : GrStencilBuffer(gpu, width, height, format.fStencilBits, sampleCnt)
bsalomon@google.com81c3f8d2011-08-03 15:18:33 +000031 , fFormat(format)
32 , fRenderbufferID(rbid) {
33 }
34
bsalomon@google.com0b77d682011-08-19 13:28:54 +000035 virtual ~GrGLStencilBuffer();
bsalomon@google.com81c3f8d2011-08-03 15:18:33 +000036
bsalomon@google.com0b77d682011-08-19 13:28:54 +000037 virtual size_t sizeInBytes() const;
bsalomon@google.com81c3f8d2011-08-03 15:18:33 +000038
39 GrGLuint renderbufferID() const {
40 return fRenderbufferID;
41 }
42
bsalomon@google.com0b77d682011-08-19 13:28:54 +000043 const Format& format() const { return fFormat; }
bsalomon@google.com81c3f8d2011-08-03 15:18:33 +000044
45protected:
bsalomon@google.com0b77d682011-08-19 13:28:54 +000046 virtual void onRelease();
bsalomon@google.com81c3f8d2011-08-03 15:18:33 +000047
bsalomon@google.com0b77d682011-08-19 13:28:54 +000048 virtual void onAbandon();
bsalomon@google.com81c3f8d2011-08-03 15:18:33 +000049
50private:
51 Format fFormat;
52 // may be zero for external SBs associated with external RTs
53 // (we don't require the client to give us the id, just tell
54 // us how many bits of stencil there are).
55 GrGLuint fRenderbufferID;
56
57 typedef GrStencilBuffer INHERITED;
58};
59
60#endif