Upstream version 9.38.198.0
[platform/framework/web/crosswalk.git] / src / third_party / angle / src / libGLESv2 / Framebuffer.h
1 //
2 // Copyright (c) 2002-2013 The ANGLE Project Authors. All rights reserved.
3 // Use of this source code is governed by a BSD-style license that can be
4 // found in the LICENSE file.
5 //
6
7 // Framebuffer.h: Defines the gl::Framebuffer class. Implements GL framebuffer
8 // objects and related functionality. [OpenGL ES 2.0.24] section 4.4 page 105.
9
10 #ifndef LIBGLESV2_FRAMEBUFFER_H_
11 #define LIBGLESV2_FRAMEBUFFER_H_
12
13 #include "common/angleutils.h"
14 #include "common/RefCountObject.h"
15 #include "constants.h"
16
17 namespace rx
18 {
19 class Renderer;
20 }
21
22 namespace gl
23 {
24 class FramebufferAttachment;
25 class Colorbuffer;
26 class Depthbuffer;
27 class Stencilbuffer;
28 class DepthStencilbuffer;
29
30 class Framebuffer
31 {
32   public:
33     Framebuffer(rx::Renderer *renderer, GLuint id);
34
35     virtual ~Framebuffer();
36
37     GLuint id() const { return mId; }
38
39     void setColorbuffer(unsigned int colorAttachment, GLenum type, GLuint colorbuffer, GLint level, GLint layer);
40     void setDepthbuffer(GLenum type, GLuint depthbuffer, GLint level, GLint layer);
41     void setStencilbuffer(GLenum type, GLuint stencilbuffer, GLint level, GLint layer);
42     void setDepthStencilBuffer(GLenum type, GLuint depthStencilBuffer, GLint level, GLint layer);
43
44     void detachTexture(GLuint texture);
45     void detachRenderbuffer(GLuint renderbuffer);
46
47     FramebufferAttachment *getColorbuffer(unsigned int colorAttachment) const;
48     FramebufferAttachment *getDepthbuffer() const;
49     FramebufferAttachment *getStencilbuffer() const;
50     FramebufferAttachment *getDepthStencilBuffer() const;
51     FramebufferAttachment *getDepthOrStencilbuffer() const;
52     FramebufferAttachment *getReadColorbuffer() const;
53     GLenum getReadColorbufferType() const;
54     FramebufferAttachment *getFirstColorbuffer() const;
55
56     virtual FramebufferAttachment *getAttachment(GLenum attachment) const;
57
58     GLenum getDrawBufferState(unsigned int colorAttachment) const;
59     void setDrawBufferState(unsigned int colorAttachment, GLenum drawBuffer);
60
61     bool isEnabledColorAttachment(unsigned int colorAttachment) const;
62     bool hasEnabledColorAttachment() const;
63     bool hasStencil() const;
64     int getSamples() const;
65     bool usingExtendedDrawBuffers() const;
66
67     virtual GLenum completeness() const;
68     bool hasValidDepthStencil() const;
69
70   protected:
71     rx::Renderer *mRenderer;
72
73     GLuint mId;
74
75     FramebufferAttachment *mColorbuffers[IMPLEMENTATION_MAX_DRAW_BUFFERS];
76     GLenum mDrawBufferStates[IMPLEMENTATION_MAX_DRAW_BUFFERS];
77     GLenum mReadBufferState;
78
79     FramebufferAttachment *mDepthbuffer;
80     FramebufferAttachment *mStencilbuffer;
81
82 private:
83     DISALLOW_COPY_AND_ASSIGN(Framebuffer);
84
85     FramebufferAttachment *createAttachment(GLenum type, GLuint handle, GLint level, GLint layer) const;
86 };
87
88 class DefaultFramebuffer : public Framebuffer
89 {
90   public:
91     DefaultFramebuffer(rx::Renderer *Renderer, Colorbuffer *colorbuffer, DepthStencilbuffer *depthStencil);
92
93     virtual GLenum completeness() const;
94     virtual FramebufferAttachment *getAttachment(GLenum attachment) const;
95
96   private:
97     DISALLOW_COPY_AND_ASSIGN(DefaultFramebuffer);
98 };
99
100 }
101
102 #endif   // LIBGLESV2_FRAMEBUFFER_H_