blob: 908921a4e4611942aba19aa11ea8aab9b43a0a99 [file] [log] [blame]
bsalomon@google.com81c3f8d2011-08-03 15:18:33 +00001
2/*
3 * Copyright 2011 Google Inc.
4 *
5 * Use of this source code is governed by a BSD-style license that can be
6 * found in the LICENSE file.
7 */
8
9
10#ifndef GrGLStencilBuffer_DEFINED
11#define GrGLStencilBuffer_DEFINED
12
tomhudson@google.com6bf38b52012-02-14 15:11:59 +000013#include "gl/GrGLInterface.h"
tomhudson@google.comdd182cb2012-02-10 21:01:00 +000014#include "../GrStencilBuffer.h"
bsalomon@google.com81c3f8d2011-08-03 15:18:33 +000015
16class GrGLStencilBuffer : public GrStencilBuffer {
17public:
18 static const GrGLenum kUnknownInternalFormat = ~0;
bsalomon@google.comf7fa8062012-02-14 14:09:57 +000019 static const GrGLuint kUnknownBitCount = ~0;
bsalomon@google.com81c3f8d2011-08-03 15:18:33 +000020 struct Format {
21 GrGLenum fInternalFormat;
22 GrGLuint fStencilBits;
23 GrGLuint fTotalBits;
24 bool fPacked;
25 };
26
27 GrGLStencilBuffer(GrGpu* gpu, GrGLint rbid,
28 int width, int height,
bsalomon@google.com558a75b2011-08-08 17:01:14 +000029 int sampleCnt,
bsalomon@google.com81c3f8d2011-08-03 15:18:33 +000030 const Format& format)
bsalomon@google.com558a75b2011-08-08 17:01:14 +000031 : GrStencilBuffer(gpu, width, height, format.fStencilBits, sampleCnt)
bsalomon@google.com81c3f8d2011-08-03 15:18:33 +000032 , fFormat(format)
33 , fRenderbufferID(rbid) {
34 }
35
bsalomon@google.com0b77d682011-08-19 13:28:54 +000036 virtual ~GrGLStencilBuffer();
bsalomon@google.com81c3f8d2011-08-03 15:18:33 +000037
bsalomon@google.com0b77d682011-08-19 13:28:54 +000038 virtual size_t sizeInBytes() const;
bsalomon@google.com81c3f8d2011-08-03 15:18:33 +000039
40 GrGLuint renderbufferID() const {
41 return fRenderbufferID;
42 }
43
bsalomon@google.com0b77d682011-08-19 13:28:54 +000044 const Format& format() const { return fFormat; }
bsalomon@google.com81c3f8d2011-08-03 15:18:33 +000045
46protected:
bsalomon@google.com0b77d682011-08-19 13:28:54 +000047 virtual void onRelease();
bsalomon@google.com81c3f8d2011-08-03 15:18:33 +000048
bsalomon@google.com0b77d682011-08-19 13:28:54 +000049 virtual void onAbandon();
bsalomon@google.com81c3f8d2011-08-03 15:18:33 +000050
51private:
52 Format fFormat;
53 // may be zero for external SBs associated with external RTs
54 // (we don't require the client to give us the id, just tell
55 // us how many bits of stencil there are).
56 GrGLuint fRenderbufferID;
57
58 typedef GrStencilBuffer INHERITED;
59};
60
61#endif