• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 //
2 // Copyright 2015 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 // FramebufferGL.h: Defines the class interface for FramebufferGL.
8 
9 #ifndef LIBANGLE_RENDERER_GL_FRAMEBUFFERGL_H_
10 #define LIBANGLE_RENDERER_GL_FRAMEBUFFERGL_H_
11 
12 #include "libANGLE/Context.h"
13 #include "libANGLE/renderer/FramebufferImpl.h"
14 
15 namespace rx
16 {
17 
18 class BlitGL;
19 class ClearMultiviewGL;
20 class FunctionsGL;
21 class StateManagerGL;
22 
23 class FramebufferGL : public FramebufferImpl
24 {
25   public:
26     FramebufferGL(const gl::FramebufferState &data, GLuint id, bool emulatedAlpha);
27     ~FramebufferGL() override;
28 
29     void destroy(const gl::Context *context) override;
30 
31     angle::Result discard(const gl::Context *context,
32                           size_t count,
33                           const GLenum *attachments) override;
34     angle::Result invalidate(const gl::Context *context,
35                              size_t count,
36                              const GLenum *attachments) override;
37     angle::Result invalidateSub(const gl::Context *context,
38                                 size_t count,
39                                 const GLenum *attachments,
40                                 const gl::Rectangle &area) override;
41 
42     angle::Result clear(const gl::Context *context, GLbitfield mask) override;
43     angle::Result clearBufferfv(const gl::Context *context,
44                                 GLenum buffer,
45                                 GLint drawbuffer,
46                                 const GLfloat *values) override;
47     angle::Result clearBufferuiv(const gl::Context *context,
48                                  GLenum buffer,
49                                  GLint drawbuffer,
50                                  const GLuint *values) override;
51     angle::Result clearBufferiv(const gl::Context *context,
52                                 GLenum buffer,
53                                 GLint drawbuffer,
54                                 const GLint *values) override;
55     angle::Result clearBufferfi(const gl::Context *context,
56                                 GLenum buffer,
57                                 GLint drawbuffer,
58                                 GLfloat depth,
59                                 GLint stencil) override;
60 
61     angle::Result readPixels(const gl::Context *context,
62                              const gl::Rectangle &area,
63                              GLenum format,
64                              GLenum type,
65                              const gl::PixelPackState &pack,
66                              gl::Buffer *packBuffer,
67                              void *pixels) override;
68 
69     angle::Result blit(const gl::Context *context,
70                        const gl::Rectangle &sourceArea,
71                        const gl::Rectangle &destArea,
72                        GLbitfield mask,
73                        GLenum filter) override;
74 
75     angle::Result getSamplePosition(const gl::Context *context,
76                                     size_t index,
77                                     GLfloat *xy) const override;
78 
79     // The GL back-end requires a full sync state before we call checkStatus.
80     bool shouldSyncStateBeforeCheckStatus() const override;
81 
82     gl::FramebufferStatus checkStatus(const gl::Context *context) const override;
83 
84     angle::Result syncState(const gl::Context *context,
85                             GLenum binding,
86                             const gl::Framebuffer::DirtyBits &dirtyBits,
87                             gl::Command command) override;
88 
89     void updateDefaultFramebufferID(GLuint framebufferID);
isDefault()90     bool isDefault() const { return mState.isDefault(); }
91 
setHasEmulatedAlphaAttachment(bool hasEmulatedAlphaAttachment)92     void setHasEmulatedAlphaAttachment(bool hasEmulatedAlphaAttachment)
93     {
94         mHasEmulatedAlphaAttachment = hasEmulatedAlphaAttachment;
95     }
96     bool hasEmulatedAlphaChannelTextureAttachment() const;
97 
setFramebufferID(GLuint id)98     void setFramebufferID(GLuint id) { mFramebufferID = id; }
getFramebufferID()99     GLuint getFramebufferID() const { return mFramebufferID; }
100 
101   private:
102     void syncClearState(const gl::Context *context, GLbitfield mask);
103     void syncClearBufferState(const gl::Context *context, GLenum buffer, GLint drawBuffer);
104 
105     bool modifyInvalidateAttachmentsForEmulatedDefaultFBO(
106         size_t count,
107         const GLenum *attachments,
108         std::vector<GLenum> *modifiedAttachments) const;
109 
110     angle::Result readPixelsRowByRow(const gl::Context *context,
111                                      const gl::Rectangle &area,
112                                      GLenum originalReadFormat,
113                                      GLenum format,
114                                      GLenum type,
115                                      const gl::PixelPackState &pack,
116                                      GLubyte *pixels) const;
117 
118     angle::Result readPixelsAllAtOnce(const gl::Context *context,
119                                       const gl::Rectangle &area,
120                                       GLenum originalReadFormat,
121                                       GLenum format,
122                                       GLenum type,
123                                       const gl::PixelPackState &pack,
124                                       GLubyte *pixels,
125                                       bool readLastRowSeparately) const;
126 
127     void maskOutInactiveOutputDrawBuffersImpl(const gl::Context *context,
128                                               gl::DrawBufferMask targetAppliedDrawBuffers);
129 
130     angle::Result adjustSrcDstRegion(const gl::Context *context,
131                                      const gl::Rectangle &sourceArea,
132                                      const gl::Rectangle &destArea,
133                                      gl::Rectangle *newSourceArea,
134                                      gl::Rectangle *newDestArea);
135 
136     angle::Result clipSrcRegion(const gl::Context *context,
137                                 const gl::Rectangle &sourceArea,
138                                 const gl::Rectangle &destArea,
139                                 gl::Rectangle *newSourceArea,
140                                 gl::Rectangle *newDestArea);
141 
142     GLuint mFramebufferID;
143     bool mHasEmulatedAlphaAttachment;
144     gl::DrawBufferMask mAppliedEnabledDrawBuffers;
145 };
146 }  // namespace rx
147 
148 #endif  // LIBANGLE_RENDERER_GL_FRAMEBUFFERGL_H_
149