Bug 797942 - Update compositor size on SIZE_CHANGED or SetCompositor, but only at startup; r=snorp, a=akeybl
authorGeoff Brown <gbrown@mozilla.com>
Thu, 08 Nov 2012 12:20:37 -0700
changeset 114037 a378d29364b705889112394b073cee4d405bdc18
parent 114036 3600b4bb3aacde12c69ed5bf323dcfc4489156b1
child 114038 ae99f48a0ebbcdab8c27f926929af7c6b439f7cf
push id2618
push usergbrown@mozilla.com
push dateThu, 08 Nov 2012 19:21:30 +0000
treeherdermozilla-aurora@a378d29364b7 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssnorp, akeybl
bugs797942
milestone18.0a2
Bug 797942 - Update compositor size on SIZE_CHANGED or SetCompositor, but only at startup; r=snorp, a=akeybl
widget/android/nsWindow.cpp
--- a/widget/android/nsWindow.cpp
+++ b/widget/android/nsWindow.cpp
@@ -766,16 +766,23 @@ nsWindow::OnGlobalAndroidEvent(AndroidGe
             NS_ASSERTION(points.Length() == 2, "Size changed does not have enough coordinates");
 
             int nw = points[0].x;
             int nh = points[0].y;
 
             if (ae->Type() == AndroidGeckoEvent::FORCED_RESIZE || nw != gAndroidBounds.width ||
                 nh != gAndroidBounds.height) {
 
+                if (sCompositorParent != 0 && gAndroidBounds.width == 0) {
+                    // Propagate size change to compositor. This is sometimes essential
+                    // on startup, because the window size may not have been available
+                    // when the compositor was created.
+                    ScheduleResumeComposition(nw, nh);
+                }
+
                 gAndroidBounds.width = nw;
                 gAndroidBounds.height = nh;
 
                 // tell all the windows about the new size
                 for (size_t i = 0; i < gTopLevelWindows.Length(); ++i) {
                     if (gTopLevelWindows[i]->mIsVisible)
                         gTopLevelWindows[i]->Resize(gAndroidBounds.width,
                                                     gAndroidBounds.height,
@@ -2233,18 +2240,24 @@ nsWindow::DrawWindowOverlay(LayerManager
 nsRefPtr<mozilla::layers::CompositorParent> nsWindow::sCompositorParent = 0;
 nsRefPtr<mozilla::layers::CompositorChild> nsWindow::sCompositorChild = 0;
 bool nsWindow::sCompositorPaused = false;
 
 void
 nsWindow::SetCompositor(mozilla::layers::CompositorParent* aCompositorParent,
                         mozilla::layers::CompositorChild* aCompositorChild)
 {
+    bool sizeChangeNeeded = (aCompositorParent && !sCompositorParent && gAndroidBounds.width != 0);
+
     sCompositorParent = aCompositorParent;
     sCompositorChild = aCompositorChild;
+
+    if (sizeChangeNeeded) {
+        ScheduleResumeComposition(gAndroidBounds.width, gAndroidBounds.height);
+    }
 }
 
 void
 nsWindow::ScheduleComposite()
 {
     if (sCompositorParent) {
         sCompositorParent->ScheduleRenderOnCompositorThread();
     }