Optimize rect-shaped layers.
This brings back an optimization disabled in HC-MR1. This time the
correct geometry is generated to avoid unnecessary blending.
Change-Id: Id56404dc46bb84c75facc25c18488a690741b592
diff --git a/libs/hwui/LayerRenderer.cpp b/libs/hwui/LayerRenderer.cpp
index f92e20b..ba110ec 100644
--- a/libs/hwui/LayerRenderer.cpp
+++ b/libs/hwui/LayerRenderer.cpp
@@ -92,11 +92,7 @@
void LayerRenderer::generateMesh() {
#if RENDER_LAYERS_AS_REGIONS
-#if RENDER_LAYERS_RECT_AS_RECT
if (mLayer->region.isRect() || mLayer->region.isEmpty()) {
-#else
- if (mLayer->region.isEmpty()) {
-#endif
if (mLayer->mesh) {
delete mLayer->mesh;
delete mLayer->meshIndices;
@@ -105,6 +101,20 @@
mLayer->meshIndices = NULL;
mLayer->meshElementCount = 0;
}
+
+ const android::Rect& bounds = mLayer->region.getBounds();
+ mLayer->regionRect.set(bounds.leftTop().x, bounds.leftTop().y,
+ bounds.rightBottom().x, bounds.rightBottom().y);
+
+ const float texX = 1.0f / float(mLayer->width);
+ const float texY = 1.0f / float(mLayer->height);
+ const float height = mLayer->layer.getHeight();
+ mLayer->texCoords.set(
+ mLayer->regionRect.left * texX,
+ (height - mLayer->regionRect.top) * texY,
+ mLayer->regionRect.right * texX,
+ (height - mLayer->regionRect.bottom) * texY);
+
return;
}