• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 //
2 // Copyright (c) 2014 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 // FramebufferAttachment.h: Defines the wrapper class gl::FramebufferAttachment, as well as the
8 // objects and related functionality. [OpenGL ES 2.0.24] section 4.4.3 page 108.
9 
10 #ifndef LIBGLESV2_FRAMEBUFFERATTACHMENT_H_
11 #define LIBGLESV2_FRAMEBUFFERATTACHMENT_H_
12 
13 #include "common/angleutils.h"
14 #include "common/RefCountObject.h"
15 #include "Texture.h"
16 
17 #include "angle_gl.h"
18 
19 namespace rx
20 {
21 class Renderer;
22 class RenderTarget;
23 class TextureStorage;
24 }
25 
26 namespace gl
27 {
28 class Renderbuffer;
29 
30 // FramebufferAttachment implements a GL framebuffer attachment.
31 // Attachments are "light" containers, which store pointers to ref-counted GL objects.
32 // We support GL texture (2D/3D/Cube/2D array) and renderbuffer object attachments.
33 // Note: Our old naming scheme used the term "Renderbuffer" for both GL renderbuffers and for
34 // framebuffer attachments, which confused their usage.
35 
36 class FramebufferAttachment
37 {
38   public:
39     explicit FramebufferAttachment(GLenum binding);
40     virtual ~FramebufferAttachment();
41 
42     // Helper methods
43     GLuint getRedSize() const;
44     GLuint getGreenSize() const;
45     GLuint getBlueSize() const;
46     GLuint getAlphaSize() const;
47     GLuint getDepthSize() const;
48     GLuint getStencilSize() const;
49     GLenum getComponentType() const;
50     GLenum getColorEncoding() const;
51     bool isTexture() const;
52 
isTextureWithId(GLuint textureId)53     bool isTextureWithId(GLuint textureId) const { return isTexture() && id() == textureId; }
isRenderbufferWithId(GLuint renderbufferId)54     bool isRenderbufferWithId(GLuint renderbufferId) const { return !isTexture() && id() == renderbufferId; }
55 
getBinding()56     GLenum getBinding() const { return mBinding; }
57 
58     // Child class interface
59     virtual GLsizei getWidth() const = 0;
60     virtual GLsizei getHeight() const = 0;
61     virtual GLenum getInternalFormat() const = 0;
62     virtual GLenum getActualFormat() const = 0;
63     virtual GLsizei getSamples() const = 0;
64 
65     virtual GLuint id() const = 0;
66     virtual GLenum type() const = 0;
67     virtual GLint mipLevel() const = 0;
68     virtual GLint layer() const = 0;
69 
70     virtual Texture *getTexture() = 0;
71     virtual const ImageIndex *getTextureImageIndex() const = 0;
72     virtual Renderbuffer *getRenderbuffer() = 0;
73 
74   private:
75     DISALLOW_COPY_AND_ASSIGN(FramebufferAttachment);
76 
77     GLenum mBinding;
78 };
79 
80 class TextureAttachment : public FramebufferAttachment
81 {
82   public:
83     TextureAttachment(GLenum binding, Texture *texture, const ImageIndex &index);
84     virtual ~TextureAttachment();
85 
86     virtual GLsizei getSamples() const;
87     virtual GLuint id() const;
88 
89     virtual GLsizei getWidth() const;
90     virtual GLsizei getHeight() const;
91     virtual GLenum getInternalFormat() const;
92     virtual GLenum getActualFormat() const;
93 
94     virtual GLenum type() const;
95     virtual GLint mipLevel() const;
96     virtual GLint layer() const;
97 
98     virtual Texture *getTexture();
99     virtual const ImageIndex *getTextureImageIndex() const;
100     virtual Renderbuffer *getRenderbuffer();
101 
102   private:
103     DISALLOW_COPY_AND_ASSIGN(TextureAttachment);
104 
105     BindingPointer<Texture> mTexture;
106     ImageIndex mIndex;
107 };
108 
109 class RenderbufferAttachment : public FramebufferAttachment
110 {
111   public:
112     RenderbufferAttachment(GLenum binding, Renderbuffer *renderbuffer);
113 
114     virtual ~RenderbufferAttachment();
115 
116     virtual GLsizei getWidth() const;
117     virtual GLsizei getHeight() const;
118     virtual GLenum getInternalFormat() const;
119     virtual GLenum getActualFormat() const;
120     virtual GLsizei getSamples() const;
121 
122     virtual GLuint id() const;
123     virtual GLenum type() const;
124     virtual GLint mipLevel() const;
125     virtual GLint layer() const;
126 
127     virtual Texture *getTexture();
128     virtual const ImageIndex *getTextureImageIndex() const;
129     virtual Renderbuffer *getRenderbuffer();
130 
131   private:
132     DISALLOW_COPY_AND_ASSIGN(RenderbufferAttachment);
133 
134     BindingPointer<Renderbuffer> mRenderbuffer;
135 };
136 
137 }
138 
139 #endif // LIBGLESV2_FRAMEBUFFERATTACHMENT_H_
140