• 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     GLenum getImplementationColorReadFormat(const gl::Context *context) const override;
62     GLenum getImplementationColorReadType(const gl::Context *context) const override;
63 
64     angle::Result readPixels(const gl::Context *context,
65                              const gl::Rectangle &area,
66                              GLenum format,
67                              GLenum type,
68                              void *pixels) override;
69 
70     angle::Result blit(const gl::Context *context,
71                        const gl::Rectangle &sourceArea,
72                        const gl::Rectangle &destArea,
73                        GLbitfield mask,
74                        GLenum filter) override;
75 
76     angle::Result getSamplePosition(const gl::Context *context,
77                                     size_t index,
78                                     GLfloat *xy) const override;
79 
80     // The GL back-end requires a full sync state before we call checkStatus.
81     bool shouldSyncStateBeforeCheckStatus() const override;
82 
83     bool checkStatus(const gl::Context *context) const override;
84 
85     angle::Result syncState(const gl::Context *context,
86                             const gl::Framebuffer::DirtyBits &dirtyBits) override;
87 
88     GLuint getFramebufferID() const;
89     bool isDefault() const;
90 
91     bool hasEmulatedAlphaChannelTextureAttachment() const;
92 
93   private:
94     void syncClearState(const gl::Context *context, GLbitfield mask);
95     void syncClearBufferState(const gl::Context *context, GLenum buffer, GLint drawBuffer);
96 
97     bool modifyInvalidateAttachmentsForEmulatedDefaultFBO(
98         size_t count,
99         const GLenum *attachments,
100         std::vector<GLenum> *modifiedAttachments) const;
101 
102     angle::Result readPixelsRowByRow(const gl::Context *context,
103                                      const gl::Rectangle &area,
104                                      GLenum format,
105                                      GLenum type,
106                                      const gl::PixelPackState &pack,
107                                      GLubyte *pixels) const;
108 
109     angle::Result readPixelsAllAtOnce(const gl::Context *context,
110                                       const gl::Rectangle &area,
111                                       GLenum format,
112                                       GLenum type,
113                                       const gl::PixelPackState &pack,
114                                       GLubyte *pixels,
115                                       bool readLastRowSeparately) const;
116 
117     void maskOutInactiveOutputDrawBuffersImpl(const gl::Context *context,
118                                               gl::DrawBufferMask targetAppliedDrawBuffers);
119 
120     angle::Result adjustSrcDstRegion(const gl::Context *context,
121                                      const gl::Rectangle &sourceArea,
122                                      const gl::Rectangle &destArea,
123                                      gl::Rectangle *newSourceArea,
124                                      gl::Rectangle *newDestArea);
125 
126     angle::Result clipSrcRegion(const gl::Context *context,
127                                 const gl::Rectangle &sourceArea,
128                                 const gl::Rectangle &destArea,
129                                 gl::Rectangle *newSourceArea,
130                                 gl::Rectangle *newDestArea);
131 
132     GLuint mFramebufferID;
133     bool mIsDefault;
134 
135     bool mHasEmulatedAlphaAttachment;
136 
137     gl::DrawBufferMask mAppliedEnabledDrawBuffers;
138 };
139 }  // namespace rx
140 
141 #endif  // LIBANGLE_RENDERER_GL_FRAMEBUFFERGL_H_
142