Bug 709492 - Part 4: Send a viewport size upon loading Gecko so that we don't suppress painting for the first page. r=kats
authorPatrick Walton <pwalton@mozilla.com>
Tue, 03 Jan 2012 22:55:10 -0800
changeset 83747 c9db040a4982523afdb7c60e48adc370a37686f1
parent 83746 551b099bdfc273a69953d1155ff984a543b1573e
child 83749 ad98a08690cb7329ee47bda90ab8f9ea28c3e186
push id21790
push userbmo@edmorley.co.uk
push dateThu, 05 Jan 2012 01:00:04 +0000
treeherdermozilla-central@0cdaf0773073 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerskats
bugs709492
milestone12.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 709492 - Part 4: Send a viewport size upon loading Gecko so that we don't suppress painting for the first page. r=kats
mobile/android/base/gfx/GeckoSoftwareLayerClient.java
--- a/mobile/android/base/gfx/GeckoSoftwareLayerClient.java
+++ b/mobile/android/base/gfx/GeckoSoftwareLayerClient.java
@@ -137,16 +137,18 @@ public class GeckoSoftwareLayerClient ex
 
         layerController.setRoot(mTileLayer);
         if (mGeckoViewport != null) {
             layerController.setViewportMetrics(mGeckoViewport);
         }
 
         GeckoAppShell.registerGeckoEventListener("Viewport:UpdateAndDraw", this);
         GeckoAppShell.registerGeckoEventListener("Viewport:UpdateLater", this);
+
+        sendResizeEventIfNecessary();
     }
 
     public void beginDrawing(int width, int height) {
         beginTransaction(mTileLayer);
 
         if (mBufferSize.width != width || mBufferSize.height != height) {
             mBufferSize = new IntSize(width, height);
 
@@ -258,40 +260,46 @@ public class GeckoSoftwareLayerClient ex
      */
     public void unlockBuffer() {
         /* no-op */
     }
 
     @Override
     public void geometryChanged() {
         /* Let Gecko know if the screensize has changed */
+        sendResizeEventIfNecessary();
+        render();
+    }
+
+    /* Informs Gecko that the screen size has changed. */
+    private void sendResizeEventIfNecessary() {
         DisplayMetrics metrics = new DisplayMetrics();
         GeckoApp.mAppContext.getWindowManager().getDefaultDisplay().getMetrics(metrics);
 
-        if (metrics.widthPixels != mScreenSize.width ||
-            metrics.heightPixels != mScreenSize.height) {
-            mScreenSize = new IntSize(metrics.widthPixels, metrics.heightPixels);
-            int maxSize = getLayerController().getView().getMaxTextureSize();
-
-            // XXX Introduce tiling to solve this?
-            if (mScreenSize.width > maxSize || mScreenSize.height > maxSize)
-                throw new RuntimeException("Screen size of " + mScreenSize + " larger than maximum texture size of " + maxSize);
-
-            // Round to next power of two until we use NPOT texture support
-            IntSize bufferSize = new IntSize(Math.min(maxSize, IntSize.nextPowerOfTwo(mScreenSize.width + LayerController.MIN_BUFFER.width)),
-                                             Math.min(maxSize, IntSize.nextPowerOfTwo(mScreenSize.height + LayerController.MIN_BUFFER.height)));
-
-            Log.i(LOGTAG, "Screen-size changed to " + mScreenSize);
-            GeckoEvent event = new GeckoEvent(GeckoEvent.SIZE_CHANGED,
-                                              bufferSize.width, bufferSize.height,
-                                              metrics.widthPixels, metrics.heightPixels);
-            GeckoAppShell.sendEventToGecko(event);
+        if (metrics.widthPixels == mScreenSize.width &&
+                metrics.heightPixels == mScreenSize.height) {
+            return;
         }
 
-        render();
+        mScreenSize = new IntSize(metrics.widthPixels, metrics.heightPixels);
+        int maxSize = getLayerController().getView().getMaxTextureSize();
+
+        // XXX Introduce tiling to solve this?
+        if (mScreenSize.width > maxSize || mScreenSize.height > maxSize)
+            throw new RuntimeException("Screen size of " + mScreenSize + " larger than maximum texture size of " + maxSize);
+
+        // Round to next power of two until we use NPOT texture support
+        IntSize bufferSize = new IntSize(Math.min(maxSize, IntSize.nextPowerOfTwo(mScreenSize.width + LayerController.MIN_BUFFER.width)),
+                                         Math.min(maxSize, IntSize.nextPowerOfTwo(mScreenSize.height + LayerController.MIN_BUFFER.height)));
+
+        Log.i(LOGTAG, "Screen-size changed to " + mScreenSize);
+        GeckoEvent event = new GeckoEvent(GeckoEvent.SIZE_CHANGED,
+                                          bufferSize.width, bufferSize.height,
+                                          metrics.widthPixels, metrics.heightPixels);
+        GeckoAppShell.sendEventToGecko(event);
     }
 
     @Override
     public void viewportSizeChanged() {
         mViewportSizeChanged = true;
     }
 
     @Override