Bug 882120 - Apply rounding to the layer-pixel rect in Java to fix robopan regression. r=kentuckyfriedtakahe
☠☠ backed out by 86ae36fa3ea2 ☠ ☠
authorKartikaya Gupta <kgupta@mozilla.com>
Tue, 18 Jun 2013 09:27:45 -0400
changeset 146962 35bf7e6dbf9001248158283ab7ce7e1652845019
parent 146961 045aa030111ec8dc9629361b6117d519782c46c5
child 146963 6148ae44874e6ea97be9f4e95112a03dc7ffbea2
push id2697
push userbbajaj@mozilla.com
push dateMon, 05 Aug 2013 18:49:53 +0000
treeherdermozilla-beta@dfec938c7b63 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerskentuckyfriedtakahe
bugs882120
milestone24.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 882120 - Apply rounding to the layer-pixel rect in Java to fix robopan regression. r=kentuckyfriedtakahe
mobile/android/base/gfx/GeckoLayerClient.java
mobile/android/base/gfx/RectUtils.java
--- a/mobile/android/base/gfx/GeckoLayerClient.java
+++ b/mobile/android/base/gfx/GeckoLayerClient.java
@@ -555,20 +555,22 @@ public class GeckoLayerClient implements
     public void setFirstPaintViewport(float offsetX, float offsetY, float zoom,
             float cssPageLeft, float cssPageTop, float cssPageRight, float cssPageBottom) {
         synchronized (getLock()) {
             ImmutableViewportMetrics currentMetrics = getViewportMetrics();
 
             Tab tab = Tabs.getInstance().getSelectedTab();
 
             RectF cssPageRect = new RectF(cssPageLeft, cssPageTop, cssPageRight, cssPageBottom);
+            RectF pageRect = RectUtils.scaleAndRound(cssPageRect, zoom);
+
             final ImmutableViewportMetrics newMetrics = currentMetrics
                 .setViewportOrigin(offsetX, offsetY)
                 .setZoomFactor(zoom)
-                .setPageRect(RectUtils.scale(cssPageRect, zoom), cssPageRect)
+                .setPageRect(pageRect, cssPageRect)
                 .setIsRTL(tab.getIsRTL());
             // Since we have switched to displaying a different document, we need to update any
             // viewport-related state we have lying around. This includes mGeckoViewport and
             // mViewportMetrics. Usually this information is updated via handleViewportMessage
             // while we remain on the same document.
             post(new Runnable() {
                 @Override
                 public void run() {
@@ -605,19 +607,20 @@ public class GeckoLayerClient implements
     /** This function is invoked by Gecko via JNI; be careful when modifying signature.
       * The compositor invokes this function whenever it determines that the page rect
       * has changed (based on the information it gets from layout). If setFirstPaintViewport
       * is invoked on a frame, then this function will not be. For any given frame, this
       * function will be invoked before syncViewportInfo.
       */
     public void setPageRect(float cssPageLeft, float cssPageTop, float cssPageRight, float cssPageBottom) {
         synchronized (getLock()) {
+            float ourZoom = getViewportMetrics().zoomFactor;
             RectF cssPageRect = new RectF(cssPageLeft, cssPageTop, cssPageRight, cssPageBottom);
-            float ourZoom = getViewportMetrics().zoomFactor;
-            setPageRect(RectUtils.scale(cssPageRect, ourZoom), cssPageRect);
+            RectF pageRect = RectUtils.scaleAndRound(cssPageRect, ourZoom);
+            setPageRect(pageRect, cssPageRect);
             // Here the page size of the document has changed, but the document being displayed
             // is still the same. Therefore, we don't need to send anything to browser.js; any
             // changes we need to make to the display port will get sent the next time we call
             // adjustViewport().
         }
     }
 
     /** This function is invoked by Gecko via JNI; be careful when modifying signature.
--- a/mobile/android/base/gfx/RectUtils.java
+++ b/mobile/android/base/gfx/RectUtils.java
@@ -69,16 +69,25 @@ public final class RectUtils {
     public static RectF scale(RectF rect, float scale) {
         float x = rect.left * scale;
         float y = rect.top * scale;
         return new RectF(x, y,
                          x + (rect.width() * scale),
                          y + (rect.height() * scale));
     }
 
+    public static RectF scaleAndRound(RectF rect, float scale) {
+        float left = rect.left * scale;
+        float top = rect.top * scale;
+        return new RectF(Math.round(left),
+                         Math.round(top),
+                         Math.round(left + (rect.width() * scale)),
+                         Math.round(top + (rect.height() * scale)));
+    }
+
     /** Returns the nearest integer rect of the given rect. */
     public static Rect round(RectF rect) {
         Rect r = new Rect();
         round(rect, r);
         return r;
     }
 
     public static void round(RectF rect, Rect dest) {