Bug 745315. Draw as soon as we get a Viewport:Changed r=kats a=joe
☠☠ backed out by 9c88cc584f04 ☠ ☠
authorJeff Muizelaar <jmuizelaar@mozilla.com>
Tue, 17 Apr 2012 20:23:35 -0400
changeset 91997 c048eb7cc7282bc0694105385a3af87778608c3f
parent 91996 162bfe6dac963f029c38c83214bf950fd1d8a510
child 91998 370f6e1f4864a0a39037cd835bab6f068df2dc50
push id8504
push userjmuizelaar@mozilla.com
push dateThu, 19 Apr 2012 21:36:13 +0000
treeherdermozilla-inbound@c048eb7cc728 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerskats, joe
bugs745315
milestone14.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 745315. Draw as soon as we get a Viewport:Changed r=kats a=joe This should reduce some unpredictibility from our drawing code and I don't see any negative concequences.
widget/android/nsAppShell.cpp
widget/android/nsWindow.cpp
--- a/widget/android/nsAppShell.cpp
+++ b/widget/android/nsAppShell.cpp
@@ -392,32 +392,16 @@ nsAppShell::ProcessNextNativeEvent(bool 
             break;
 
         nsTArray<nsIntPoint> points = curEvent->Points();
         NS_ASSERTION(points.Length() == 2, "Screenshot event does not have enough coordinates");
         bridge->TakeScreenshot(domWindow, 0, 0, points[0].x, points[0].y, points[1].x, points[1].y, curEvent->MetaState(), scale);
         break;
     }
 
-    case AndroidGeckoEvent::VIEWPORT:
-    case AndroidGeckoEvent::BROADCAST: {
-
-        if (curEvent->Characters().Length() == 0)
-            break;
-
-        nsCOMPtr<nsIObserverService> obsServ =
-            mozilla::services::GetObserverService();
-
-        const NS_ConvertUTF16toUTF8 topic(curEvent->Characters());
-        const nsPromiseFlatString& data = PromiseFlatString(curEvent->CharactersExtra());
-
-        obsServ->NotifyObservers(nsnull, topic.get(), data.get());
-        break;
-    }
-
     case AndroidGeckoEvent::LOAD_URI: {
         nsCOMPtr<nsICommandLineRunner> cmdline
             (do_CreateInstance("@mozilla.org/toolkit/command-line;1"));
         if (!cmdline)
             break;
 
         if (curEvent->Characters().Length() == 0)
             break;
@@ -659,16 +643,17 @@ nsAppShell::PostEvent(AndroidGeckoEvent 
         }
 
         // if the event wasn't on our whitelist then reset mQueuedViewportEvent
         // so that we don't coalesce future viewport events into the last viewport
         // event we added
         if (!allowCoalescingNextViewport)
             mQueuedViewportEvent = nsnull;
     }
+
     NotifyNativeEvent();
 }
 
 void
 nsAppShell::OnResume()
 {
 }
 
--- a/widget/android/nsWindow.cpp
+++ b/widget/android/nsWindow.cpp
@@ -76,16 +76,17 @@ using mozilla::unused;
 
 #include "nsTArray.h"
 
 #include "AndroidBridge.h"
 
 #include "imgIEncoder.h"
 
 #include "nsStringGlue.h"
+#include "nsAutoPtr.h"
 
 using namespace mozilla;
 using namespace mozilla::widget;
 
 NS_IMPL_ISUPPORTS_INHERITED0(nsWindow, nsBaseWidget)
 
 // The dimensions of the current android view
 static gfxIntSize gAndroidBounds = gfxIntSize(0, 0);
@@ -887,16 +888,44 @@ nsWindow::OnGlobalAndroidEvent(AndroidGe
         }
 
         case AndroidGeckoEvent::KEY_EVENT:
             win->UserActivity();
             if (win->mFocus)
                 win->mFocus->OnKeyEvent(ae);
             break;
 
+        case AndroidGeckoEvent::VIEWPORT:
+        case AndroidGeckoEvent::BROADCAST: {
+            if (ae->Characters().Length() == 0)
+                break;
+
+            nsCOMPtr<nsIObserverService> obsServ =
+                mozilla::services::GetObserverService();
+
+            const NS_ConvertUTF16toUTF8 topic(ae->Characters());
+            const nsPromiseFlatString& data = PromiseFlatString(ae->CharactersExtra());
+
+            obsServ->NotifyObservers(nsnull, topic.get(), data.get());
+
+            if (ae->Type() == AndroidGeckoEvent::VIEWPORT) {
+                // We know that we've caused a complete invalidation
+                // and don't want to wait for the refresh driver
+                // to kick off a draw so we start one now.
+                // There are other smaller invalidations for touch hilighting that
+                // happen earlier so we don't necessarily want to have the
+                // refresh driver naively start a paint when we get the first
+                // invalidation.
+                nsIntRect rect(0, 0, win->mBounds.width, win->mBounds.height);
+                nsAutoPtr<AndroidGeckoEvent> event(new AndroidGeckoEvent(AndroidGeckoEvent::DRAW, rect));
+                win->OnDraw(event);
+            }
+            break;
+        }
+
         case AndroidGeckoEvent::DRAW:
             layers::renderTraceEventStart("Global draw start", "414141");
             win->OnDraw(ae);
             layers::renderTraceEventEnd("414141");
             break;
 
         case AndroidGeckoEvent::IME_EVENT:
             win->UserActivity();