Skip to content

Commit e0aa84b

Browse files
author
Romain Guy
committed
Optimize FBOs composition
Change-Id: Ifc8eada8922509373c0e4c3b2ed75b6f08d098de
1 parent 5c88fc7 commit e0aa84b

File tree

2 files changed

+6
-14
lines changed

2 files changed

+6
-14
lines changed

graphics/java/android/graphics/Canvas.java

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -40,14 +40,8 @@ public class Canvas {
4040
// assigned in constructors, freed in finalizer
4141
final int mNativeCanvas;
4242

43-
/* Our native canvas can be either a raster, gl, or picture canvas.
44-
If we are raster, then mGL will be null, and mBitmap may or may not be
45-
present (our default constructor creates a raster canvas but no
46-
java-bitmap is). If we are a gl-based, then mBitmap will be null, and
47-
mGL will not be null. Thus both cannot be non-null, but its possible
48-
for both to be null.
49-
*/
50-
private Bitmap mBitmap; // if not null, mGL must be null
43+
// may be null
44+
private Bitmap mBitmap;
5145

5246
// optional field set by the caller
5347
private DrawFilter mDrawFilter;
@@ -66,7 +60,7 @@ public class Canvas {
6660

6761
// Used by native code
6862
@SuppressWarnings({"UnusedDeclaration"})
69-
private int mSurfaceFormat;
63+
private int mSurfaceFormat;
7064

7165
/**
7266
* Flag for drawTextRun indicating left-to-right run direction.

libs/hwui/OpenGLRenderer.cpp

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -594,6 +594,9 @@ void OpenGLRenderer::composeLayer(sp<Snapshot> current, sp<Snapshot> previous) {
594594
const bool fboLayer = current->flags & Snapshot::kFlagIsFboLayer;
595595

596596
if (fboLayer) {
597+
// Detach the texture from the FBO
598+
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, 0, 0);
599+
597600
// Unbind current FBO and restore previous one
598601
glBindFramebuffer(GL_FRAMEBUFFER, previous->fbo);
599602
}
@@ -634,11 +637,6 @@ void OpenGLRenderer::composeLayer(sp<Snapshot> current, sp<Snapshot> previous) {
634637
// code path
635638
// See LayerRenderer::destroyLayer(Layer*)
636639

637-
// Detach the texture from the FBO
638-
glBindFramebuffer(GL_FRAMEBUFFER, current->fbo);
639-
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, 0, 0);
640-
glBindFramebuffer(GL_FRAMEBUFFER, previous->fbo);
641-
642640
// Put the FBO name back in the cache, if it doesn't fit, it will be destroyed
643641
mCaches.fboCache.put(current->fbo);
644642
layer->setFbo(0);

0 commit comments

Comments
 (0)