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/renderer/FramebufferImpl.h" 13 14 namespace rx 15 { 16 17 class BlitGL; 18 class FunctionsGL; 19 class StateManagerGL; 20 struct WorkaroundsGL; 21 22 class FramebufferGL : public FramebufferImpl 23 { 24 public: 25 FramebufferGL(const gl::FramebufferState &data, 26 const FunctionsGL *functions, 27 StateManagerGL *stateManager, 28 const WorkaroundsGL &workarounds, 29 BlitGL *blitter, 30 bool isDefault); 31 // Constructor called when we need to create a FramebufferGL from an 32 // existing framebuffer name, for example for the default framebuffer 33 // on the Mac EGL CGL backend. 34 FramebufferGL(GLuint id, 35 const gl::FramebufferState &data, 36 const FunctionsGL *functions, 37 const WorkaroundsGL &workarounds, 38 BlitGL *blitter, 39 StateManagerGL *stateManager); 40 ~FramebufferGL() override; 41 42 gl::Error discard(size_t count, const GLenum *attachments) override; 43 gl::Error invalidate(size_t count, const GLenum *attachments) override; 44 gl::Error invalidateSub(size_t count, const GLenum *attachments, const gl::Rectangle &area) override; 45 46 gl::Error clear(ContextImpl *context, GLbitfield mask) override; 47 gl::Error clearBufferfv(ContextImpl *context, 48 GLenum buffer, 49 GLint drawbuffer, 50 const GLfloat *values) override; 51 gl::Error clearBufferuiv(ContextImpl *context, 52 GLenum buffer, 53 GLint drawbuffer, 54 const GLuint *values) override; 55 gl::Error clearBufferiv(ContextImpl *context, 56 GLenum buffer, 57 GLint drawbuffer, 58 const GLint *values) override; 59 gl::Error clearBufferfi(ContextImpl *context, 60 GLenum buffer, 61 GLint drawbuffer, 62 GLfloat depth, 63 GLint stencil) override; 64 65 GLenum getImplementationColorReadFormat() const override; 66 GLenum getImplementationColorReadType() const override; 67 gl::Error readPixels(ContextImpl *context, 68 const gl::Rectangle &area, 69 GLenum format, 70 GLenum type, 71 GLvoid *pixels) const override; 72 73 gl::Error blit(ContextImpl *context, 74 const gl::Rectangle &sourceArea, 75 const gl::Rectangle &destArea, 76 GLbitfield mask, 77 GLenum filter) override; 78 79 bool checkStatus() const override; 80 81 void syncState(const gl::Framebuffer::DirtyBits &dirtyBits) override; 82 83 GLuint getFramebufferID() const; 84 bool isDefault() const; 85 86 private: 87 void syncClearState(GLbitfield mask); 88 void syncClearBufferState(GLenum buffer, GLint drawBuffer); 89 90 gl::Error readPixelsRowByRowWorkaround(const gl::Rectangle &area, 91 GLenum format, 92 GLenum type, 93 const gl::PixelPackState &pack, 94 GLvoid *pixels) const; 95 96 gl::Error readPixelsPaddingWorkaround(const gl::Rectangle &area, 97 GLenum format, 98 GLenum type, 99 const gl::PixelPackState &pack, 100 GLvoid *pixels) const; 101 102 const FunctionsGL *mFunctions; 103 StateManagerGL *mStateManager; 104 const WorkaroundsGL &mWorkarounds; 105 BlitGL *mBlitter; 106 107 GLuint mFramebufferID; 108 bool mIsDefault; 109 }; 110 111 } 112 113 #endif // LIBANGLE_RENDERER_GL_FRAMEBUFFERGL_H_ 114