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 void *pixels) override; 66 67 angle::Result blit(const gl::Context *context, 68 const gl::Rectangle &sourceArea, 69 const gl::Rectangle &destArea, 70 GLbitfield mask, 71 GLenum filter) override; 72 73 angle::Result getSamplePosition(const gl::Context *context, 74 size_t index, 75 GLfloat *xy) const override; 76 77 // The GL back-end requires a full sync state before we call checkStatus. 78 bool shouldSyncStateBeforeCheckStatus() const override; 79 80 bool checkStatus(const gl::Context *context) const override; 81 82 angle::Result syncState(const gl::Context *context, 83 GLenum binding, 84 const gl::Framebuffer::DirtyBits &dirtyBits) override; 85 86 GLuint getFramebufferID() const; 87 bool isDefault() const; 88 89 bool hasEmulatedAlphaChannelTextureAttachment() const; 90 91 private: 92 void syncClearState(const gl::Context *context, GLbitfield mask); 93 void syncClearBufferState(const gl::Context *context, GLenum buffer, GLint drawBuffer); 94 95 bool modifyInvalidateAttachmentsForEmulatedDefaultFBO( 96 size_t count, 97 const GLenum *attachments, 98 std::vector<GLenum> *modifiedAttachments) const; 99 100 angle::Result readPixelsRowByRow(const gl::Context *context, 101 const gl::Rectangle &area, 102 GLenum originalReadFormat, 103 GLenum format, 104 GLenum type, 105 const gl::PixelPackState &pack, 106 GLubyte *pixels) const; 107 108 angle::Result readPixelsAllAtOnce(const gl::Context *context, 109 const gl::Rectangle &area, 110 GLenum originalReadFormat, 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