blob: 3bd642f4609d5a18a301917cdf3cc9f0b1b84a65 [file] [log] [blame]
bsalomon3724e572016-03-30 18:56:19 -07001
robertphillips@google.comdd743fe2012-04-05 14:40:53 +00002/*
3 * Copyright 2012 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#ifndef GrFrameBufferObj_DEFINED
10#define GrFrameBufferObj_DEFINED
11
12#include "GrFakeRefObj.h"
13class GrFBBindableObj;
14
15////////////////////////////////////////////////////////////////////////////////
16// TODO: when a framebuffer obj is bound the GL_SAMPLES query must return 0
17// TODO: GL_STENCIL_BITS must also be redirected to the framebuffer
18class GrFrameBufferObj : public GrFakeRefObj {
Mike Kleinfc6c37b2016-09-27 09:34:10 -040019 GR_DEFINE_CREATOR(GrFrameBufferObj)
robertphillips@google.comdd743fe2012-04-05 14:40:53 +000020
21public:
22 GrFrameBufferObj()
23 : GrFakeRefObj()
24 , fBound(false)
halcanary96fcdcc2015-08-27 07:41:13 -070025 , fColorBuffer(nullptr)
26 , fDepthBuffer(nullptr)
27 , fStencilBuffer(nullptr) {
robertphillips@google.comdd743fe2012-04-05 14:40:53 +000028 }
29
30 virtual ~GrFrameBufferObj() {
halcanary96fcdcc2015-08-27 07:41:13 -070031 fColorBuffer = nullptr;
32 fDepthBuffer = nullptr;
33 fStencilBuffer = nullptr;
robertphillips@google.comdd743fe2012-04-05 14:40:53 +000034 }
35
36 void setBound() { fBound = true; }
37 void resetBound() { fBound = false; }
38 bool getBound() const { return fBound; }
39
40 void setColor(GrFBBindableObj *buffer);
41 GrFBBindableObj *getColor() { return fColorBuffer; }
42
43 void setDepth(GrFBBindableObj *buffer);
44 GrFBBindableObj *getDepth() { return fDepthBuffer; }
45
46 void setStencil(GrFBBindableObj *buffer);
47 GrFBBindableObj *getStencil() { return fStencilBuffer; }
48
mtklein36352bf2015-03-25 18:17:31 -070049 void deleteAction() override {
robertphillips@google.comdd743fe2012-04-05 14:40:53 +000050
halcanary96fcdcc2015-08-27 07:41:13 -070051 setColor(nullptr);
52 setDepth(nullptr);
53 setStencil(nullptr);
robertphillips@google.comdd743fe2012-04-05 14:40:53 +000054
55 this->INHERITED::deleteAction();
56 }
57
58protected:
59private:
60 bool fBound; // is this frame buffer currently bound via "glBindFramebuffer"?
61 GrFBBindableObj * fColorBuffer;
62 GrFBBindableObj * fDepthBuffer;
63 GrFBBindableObj * fStencilBuffer;
64
65 typedef GrFakeRefObj INHERITED;
66};
67
68#endif // GrFrameBufferObj_DEFINED