• 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 isDefault, 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     GLuint getFramebufferID() const;
90     void updateDefaultFramebufferID(GLuint framebufferID);
91     bool isDefault() const;
92 
93     bool hasEmulatedAlphaChannelTextureAttachment() const;
94 
95   private:
96     void syncClearState(const gl::Context *context, GLbitfield mask);
97     void syncClearBufferState(const gl::Context *context, GLenum buffer, GLint drawBuffer);
98 
99     bool modifyInvalidateAttachmentsForEmulatedDefaultFBO(
100         size_t count,
101         const GLenum *attachments,
102         std::vector<GLenum> *modifiedAttachments) const;
103 
104     angle::Result readPixelsRowByRow(const gl::Context *context,
105                                      const gl::Rectangle &area,
106                                      GLenum originalReadFormat,
107                                      GLenum format,
108                                      GLenum type,
109                                      const gl::PixelPackState &pack,
110                                      GLubyte *pixels) const;
111 
112     angle::Result readPixelsAllAtOnce(const gl::Context *context,
113                                       const gl::Rectangle &area,
114                                       GLenum originalReadFormat,
115                                       GLenum format,
116                                       GLenum type,
117                                       const gl::PixelPackState &pack,
118                                       GLubyte *pixels,
119                                       bool readLastRowSeparately) const;
120 
121     void maskOutInactiveOutputDrawBuffersImpl(const gl::Context *context,
122                                               gl::DrawBufferMask targetAppliedDrawBuffers);
123 
124     angle::Result adjustSrcDstRegion(const gl::Context *context,
125                                      const gl::Rectangle &sourceArea,
126                                      const gl::Rectangle &destArea,
127                                      gl::Rectangle *newSourceArea,
128                                      gl::Rectangle *newDestArea);
129 
130     angle::Result clipSrcRegion(const gl::Context *context,
131                                 const gl::Rectangle &sourceArea,
132                                 const gl::Rectangle &destArea,
133                                 gl::Rectangle *newSourceArea,
134                                 gl::Rectangle *newDestArea);
135 
136     GLuint mFramebufferID;
137     bool mIsDefault;
138 
139     bool mHasEmulatedAlphaAttachment;
140 
141     gl::DrawBufferMask mAppliedEnabledDrawBuffers;
142 };
143 }  // namespace rx
144 
145 #endif  // LIBANGLE_RENDERER_GL_FRAMEBUFFERGL_H_
146