diff --git a/libs/hwui/OpenGLRenderer.cpp b/libs/hwui/OpenGLRenderer.cpp index c7a2014d1cf90..ca9a38e58757e 100644 --- a/libs/hwui/OpenGLRenderer.cpp +++ b/libs/hwui/OpenGLRenderer.cpp @@ -183,14 +183,7 @@ status_t OpenGLRenderer::prepareDirty(float left, float top, float right, float updateLayers(); - // If we know that we are going to redraw the entire framebuffer, - // perform a discard to let the driver know we don't need to preserve - // the back buffer for this frame. - if (mCaches.extensions.hasDiscardFramebuffer() && - left <= 0.0f && top <= 0.0f && right >= mWidth && bottom >= mHeight) { - const GLenum attachments[] = { getTargetFbo() == 0 ? GL_COLOR_EXT : GL_COLOR_ATTACHMENT0 }; - glDiscardFramebufferEXT(GL_FRAMEBUFFER, 1, attachments); - } + discardFramebuffer(left, top, right, bottom); syncState(); @@ -207,6 +200,18 @@ status_t OpenGLRenderer::prepareDirty(float left, float top, float right, float return clear(left, top, right, bottom, opaque); } +void OpenGLRenderer::discardFramebuffer(float left, float top, float right, float bottom) { + // If we know that we are going to redraw the entire framebuffer, + // perform a discard to let the driver know we don't need to preserve + // the back buffer for this frame. + if (mCaches.extensions.hasDiscardFramebuffer() && + left <= 0.0f && top <= 0.0f && right >= mWidth && bottom >= mHeight) { + const GLenum attachments[] = { getTargetFbo() == 0 ? (const GLenum) GL_COLOR_EXT : + (const GLenum) GL_COLOR_ATTACHMENT0 }; + glDiscardFramebufferEXT(GL_FRAMEBUFFER, 1, attachments); + } +} + status_t OpenGLRenderer::clear(float left, float top, float right, float bottom, bool opaque) { if (!opaque) { mCaches.enableScissor(); diff --git a/libs/hwui/OpenGLRenderer.h b/libs/hwui/OpenGLRenderer.h index c5e4c8e78d93f..f16558174b17b 100644 --- a/libs/hwui/OpenGLRenderer.h +++ b/libs/hwui/OpenGLRenderer.h @@ -365,6 +365,13 @@ protected: } private: + /** + * Discards the content of the framebuffer if supported by the driver. + * This method should be called at the beginning of a frame to optimize + * rendering on some tiler architectures. + */ + void discardFramebuffer(float left, float top, float right, float bottom); + /** * Ensures the state of the renderer is the same as the state of * the GL context. diff --git a/libs/hwui/SkiaShader.h b/libs/hwui/SkiaShader.h index 26875928cf98f..bc12b0dfed661 100644 --- a/libs/hwui/SkiaShader.h +++ b/libs/hwui/SkiaShader.h @@ -65,7 +65,7 @@ struct SkiaShader { virtual void setupProgram(Program* program, const mat4& modelView, const Snapshot& snapshot, GLuint* textureUnit); - inline SkShader *getSkShader() { + inline SkShader* getSkShader() { return mKey; }