Correctly compute tex coords for rect layers.
Bug #4192695

This change also fixes Javadoc links in the framework.

Change-Id: Ia548bcb18baba5d6fe6a4a04a2278e3a3bd465b2
diff --git a/libs/hwui/Layer.h b/libs/hwui/Layer.h
index 26e240f..6c4a2a9 100644
--- a/libs/hwui/Layer.h
+++ b/libs/hwui/Layer.h
@@ -53,6 +53,23 @@
     }
 
     /**
+     * Sets this layer's region to a rectangle. Computes the appropriate
+     * texture coordinates.
+     */
+    void setRegionAsRect() {
+        const android::Rect& bounds = region.getBounds();
+        regionRect.set(bounds.leftTop().x, bounds.leftTop().y,
+               bounds.rightBottom().x, bounds.rightBottom().y);
+
+        const float texX = 1.0f / float(width);
+        const float texY = 1.0f / float(height);
+        const float height = layer.getHeight();
+        texCoords.set(
+               regionRect.left * texX, (height - regionRect.top) * texY,
+               regionRect.right * texX, (height - regionRect.bottom) * texY);
+    }
+
+    /**
      * Bounds of the layer.
      */
     Rect layer;
diff --git a/libs/hwui/LayerRenderer.cpp b/libs/hwui/LayerRenderer.cpp
index ba110ec..ca1e7ae 100644
--- a/libs/hwui/LayerRenderer.cpp
+++ b/libs/hwui/LayerRenderer.cpp
@@ -102,19 +102,7 @@
             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);
-
+        mLayer->setRegionAsRect();
         return;
     }
 
diff --git a/libs/hwui/OpenGLRenderer.cpp b/libs/hwui/OpenGLRenderer.cpp
index dd0cca2..e926d99 100644
--- a/libs/hwui/OpenGLRenderer.cpp
+++ b/libs/hwui/OpenGLRenderer.cpp
@@ -647,10 +647,10 @@
 void OpenGLRenderer::composeLayerRegion(Layer* layer, const Rect& rect) {
 #if RENDER_LAYERS_AS_REGIONS
     if (layer->region.isRect()) {
-        const android::Rect& bounds = layer->region.getBounds();
-        layer->regionRect.set(bounds.leftTop().x, bounds.leftTop().y,
-                bounds.rightBottom().x, bounds.rightBottom().y);
+        layer->setRegionAsRect();
+
         composeLayerRect(layer, layer->regionRect);
+
         layer->region.clear();
         return;
     }