From e0aa84b7dc087e999e20055dcc04cb6a48d5bd62 Mon Sep 17 00:00:00 2001 From: Romain Guy Date: Tue, 3 Apr 2012 19:30:26 -0700 Subject: Optimize FBOs composition Change-Id: Ifc8eada8922509373c0e4c3b2ed75b6f08d098de --- graphics/java/android/graphics/Canvas.java | 12 +++--------- libs/hwui/OpenGLRenderer.cpp | 8 +++----- 2 files changed, 6 insertions(+), 14 deletions(-) diff --git a/graphics/java/android/graphics/Canvas.java b/graphics/java/android/graphics/Canvas.java index dcda67d..7e92973 100644 --- a/graphics/java/android/graphics/Canvas.java +++ b/graphics/java/android/graphics/Canvas.java @@ -40,14 +40,8 @@ public class Canvas { // assigned in constructors, freed in finalizer final int mNativeCanvas; - /* Our native canvas can be either a raster, gl, or picture canvas. - If we are raster, then mGL will be null, and mBitmap may or may not be - present (our default constructor creates a raster canvas but no - java-bitmap is). If we are a gl-based, then mBitmap will be null, and - mGL will not be null. Thus both cannot be non-null, but its possible - for both to be null. - */ - private Bitmap mBitmap; // if not null, mGL must be null + // may be null + private Bitmap mBitmap; // optional field set by the caller private DrawFilter mDrawFilter; @@ -66,7 +60,7 @@ public class Canvas { // Used by native code @SuppressWarnings({"UnusedDeclaration"}) - private int mSurfaceFormat; + private int mSurfaceFormat; /** * Flag for drawTextRun indicating left-to-right run direction. diff --git a/libs/hwui/OpenGLRenderer.cpp b/libs/hwui/OpenGLRenderer.cpp index e4d1ba9..9000391 100644 --- a/libs/hwui/OpenGLRenderer.cpp +++ b/libs/hwui/OpenGLRenderer.cpp @@ -594,6 +594,9 @@ void OpenGLRenderer::composeLayer(sp current, sp previous) { const bool fboLayer = current->flags & Snapshot::kFlagIsFboLayer; if (fboLayer) { + // Detach the texture from the FBO + glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, 0, 0); + // Unbind current FBO and restore previous one glBindFramebuffer(GL_FRAMEBUFFER, previous->fbo); } @@ -634,11 +637,6 @@ void OpenGLRenderer::composeLayer(sp current, sp previous) { // code path // See LayerRenderer::destroyLayer(Layer*) - // Detach the texture from the FBO - glBindFramebuffer(GL_FRAMEBUFFER, current->fbo); - glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, 0, 0); - glBindFramebuffer(GL_FRAMEBUFFER, previous->fbo); - // Put the FBO name back in the cache, if it doesn't fit, it will be destroyed mCaches.fboCache.put(current->fbo); layer->setFbo(0); -- cgit v1.1