diff options
author | Romain Guy <romainguy@google.com> | 2011-01-22 00:32:12 -0800 |
---|---|---|
committer | Romain Guy <romainguy@google.com> | 2011-01-22 00:35:23 -0800 |
commit | c88e357d1ed9dadfc0efb3dfbe92f24460674ef5 (patch) | |
tree | af36de378d845f6db755c13191d8118f9711fd8b /libs/hwui | |
parent | acf36126e4620a0cc36d4e5b1268d15777ea4361 (diff) | |
download | frameworks_base-c88e357d1ed9dadfc0efb3dfbe92f24460674ef5.zip frameworks_base-c88e357d1ed9dadfc0efb3dfbe92f24460674ef5.tar.gz frameworks_base-c88e357d1ed9dadfc0efb3dfbe92f24460674ef5.tar.bz2 |
Fix regression with hardware layers.
The renderer was checking whether the layer's region is a rect to
draw it with a simple quad. This test was done against the layer's
region structure, which was cleared after generating the mesh.
Unfortunately Region::isRect() returns true when the region is
empty, which was causing the renderer to always use a quad to
draw a mesh on screen.
Change-Id: If4b874579ee0cedcb67367c9efa5c0c98ca55231
Diffstat (limited to 'libs/hwui')
-rw-r--r-- | libs/hwui/LayerRenderer.cpp | 7 | ||||
-rw-r--r-- | libs/hwui/OpenGLRenderer.cpp | 48 |
2 files changed, 29 insertions, 26 deletions
diff --git a/libs/hwui/LayerRenderer.cpp b/libs/hwui/LayerRenderer.cpp index a167429..1c89577 100644 --- a/libs/hwui/LayerRenderer.cpp +++ b/libs/hwui/LayerRenderer.cpp @@ -29,6 +29,10 @@ namespace uirenderer { void LayerRenderer::prepare(bool opaque) { LAYER_RENDERER_LOGD("Rendering into layer, fbo = %d", mLayer->fbo); +#if RENDER_LAYERS_AS_REGIONS + mLayer->region.clear(); +#endif + glBindFramebuffer(GL_FRAMEBUFFER, mLayer->fbo); OpenGLRenderer::prepare(opaque); @@ -79,7 +83,6 @@ void LayerRenderer::generateMesh() { mLayer->meshIndices = NULL; mLayer->meshElementCount = 0; } - mLayer->region.clear(); return; } @@ -131,8 +134,6 @@ void LayerRenderer::generateMesh() { indices[index + 4] = quad + 1; // top-right indices[index + 5] = quad + 3; // bottom-right } - - mLayer->region.clear(); #endif } diff --git a/libs/hwui/OpenGLRenderer.cpp b/libs/hwui/OpenGLRenderer.cpp index b06bbd0..92aa4bd 100644 --- a/libs/hwui/OpenGLRenderer.cpp +++ b/libs/hwui/OpenGLRenderer.cpp @@ -1568,29 +1568,31 @@ void OpenGLRenderer::drawLayer(Layer* layer, float x, float y, SkPaint* paint) { #if RENDER_LAYERS_AS_REGIONS - if (layer->region.isRect()) { - const Rect r(x, y, x + layer->layer.getWidth(), y + layer->layer.getHeight()); - composeLayerRect(layer, r); - } else if (!layer->region.isEmpty() && layer->mesh) { - const Rect& rect = layer->layer; - - setupDraw(); - setupDrawWithTexture(); - setupDrawColor(alpha, alpha, alpha, alpha); - setupDrawColorFilter(); - setupDrawBlending(layer->blend || layer->alpha < 255, layer->mode, false); - setupDrawProgram(); - setupDrawDirtyRegionsDisabled(); - setupDrawPureColorUniforms(); - setupDrawColorFilterUniforms(); - setupDrawTexture(layer->texture); - setupDrawModelViewTranslate(rect.left, rect.top, rect.right, rect.bottom); - setupDrawMesh(&layer->mesh[0].position[0], &layer->mesh[0].texture[0]); - - glDrawElements(GL_TRIANGLES, layer->meshElementCount, - GL_UNSIGNED_SHORT, layer->meshIndices); - - finishDrawTexture(); + if (!layer->region.isEmpty()) { + if (layer->region.isRect()) { + const Rect r(x, y, x + layer->layer.getWidth(), y + layer->layer.getHeight()); + composeLayerRect(layer, r); + } else if (layer->mesh) { + const Rect& rect = layer->layer; + + setupDraw(); + setupDrawWithTexture(); + setupDrawColor(alpha, alpha, alpha, alpha); + setupDrawColorFilter(); + setupDrawBlending(layer->blend || layer->alpha < 255, layer->mode, false); + setupDrawProgram(); + setupDrawDirtyRegionsDisabled(); + setupDrawPureColorUniforms(); + setupDrawColorFilterUniforms(); + setupDrawTexture(layer->texture); + setupDrawModelViewTranslate(rect.left, rect.top, rect.right, rect.bottom); + setupDrawMesh(&layer->mesh[0].position[0], &layer->mesh[0].texture[0]); + + glDrawElements(GL_TRIANGLES, layer->meshElementCount, + GL_UNSIGNED_SHORT, layer->meshIndices); + + finishDrawTexture(); + } } #else const Rect r(x, y, x + layer->layer.getWidth(), y + layer->layer.getHeight()); |