Bug 732756 - Fix layers with a mask appearing squashed. r=pcwalton
authorChris Lord <chrislord.net@gmail.com>
Mon, 12 Mar 2012 18:49:01 +0000
changeset 89339 2dd6ac8eb1a47f3bcbed4bcf024d68b3a825ae95
parent 89338 299ddb63317e48ddb14b7245ef4f8c3ac2f8dea4
child 89340 b52bae0250f719571ae6cadff9f941668ac1fd83
push id22242
push userkgupta@mozilla.com
push dateWed, 14 Mar 2012 15:19:09 +0000
treeherdermozilla-central@936ef50fa498 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerspcwalton
bugs732756
milestone13.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 732756 - Fix layers with a mask appearing squashed. r=pcwalton If a mask was set on a layer, each sub-rectangle would end up drawing with the full texture extents.
mobile/android/base/gfx/SingleTileLayer.java
--- a/mobile/android/base/gfx/SingleTileLayer.java
+++ b/mobile/android/base/gfx/SingleTileLayer.java
@@ -78,28 +78,25 @@ public class SingleTileLayer extends Til
     @Override
     public void draw(RenderContext context) {
         // mTextureIDs may be null here during startup if Layer.java's draw method
         // failed to acquire the transaction lock and call performUpdates.
         if (!initialized())
             return;
 
         RectF bounds;
-        int[] cropRect;
         Rect position = getPosition();
         RectF viewport = context.viewport;
 
         if (repeats()) {
             bounds = new RectF(0.0f, 0.0f, viewport.width(), viewport.height());
             int width = Math.round(viewport.width());
             int height = Math.round(viewport.height());
-            cropRect = new int[] { 0, 0, width, height };
         } else {
             bounds = getBounds(context);
-            cropRect = new int[] { 0, 0, position.width(), position.height() };
         }
 
         Rect intBounds = new Rect();
         bounds.roundOut(intBounds);
         Region maskedBounds = new Region(intBounds);
         if (mMask != null) {
             maskedBounds.op(mMask, Region.Op.DIFFERENCE);
             if (maskedBounds.isEmpty())
@@ -112,16 +109,21 @@ public class SingleTileLayer extends Til
         for (Rect subRect = new Rect(); i.next(subRect);) {
             // Compensate for rounding errors at the edge of the tile caused by
             // the roundOut above
             RectF subRectF = new RectF(Math.max(bounds.left, (float)subRect.left),
                                        Math.max(bounds.top, (float)subRect.top),
                                        Math.min(bounds.right, (float)subRect.right),
                                        Math.min(bounds.bottom, (float)subRect.bottom));
 
+            int[] cropRect = new int[] { Math.round(subRectF.left - bounds.left),
+                                         Math.round(subRectF.bottom - bounds.top),
+                                         Math.round(subRectF.right - bounds.left),
+                                         Math.round(subRectF.top - bounds.top) };
+
             float height = subRectF.height();
             float left = subRectF.left - viewport.left;
             float top = viewport.height() - (subRectF.top + height - viewport.top);
 
             float[] coords = {
                 //x, y, z, texture_x, texture_y
                 left/viewport.width(), top/viewport.height(), 0,
                 cropRect[0]/(float)position.width(), cropRect[1]/(float)position.height(),