Bug 867269 - Fix breakage in SyncFrameMetrics override. r=nrc
authorKartikaya Gupta <kgupta@mozilla.com>
Wed, 01 May 2013 10:49:27 -0400
changeset 141418 ea568a1576e52ce35ef522502e3868011216defc
parent 141417 120ca4a6afc3c72d2fb1b59804c372f63662453d
child 141419 343120d265be014cc947b906b73b22730f5dd6ab
push id2579
push userakeybl@mozilla.com
push dateMon, 24 Jun 2013 18:52:47 +0000
treeherdermozilla-beta@b69b7de8a05a [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersnrc
bugs867269
milestone23.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 867269 - Fix breakage in SyncFrameMetrics override. r=nrc
gfx/layers/composite/AsyncCompositionManager.cpp
gfx/layers/composite/AsyncCompositionManager.h
gfx/layers/ipc/AsyncPanZoomController.cpp
gfx/layers/ipc/AsyncPanZoomController.h
widget/android/nsWindow.cpp
--- a/gfx/layers/composite/AsyncCompositionManager.cpp
+++ b/gfx/layers/composite/AsyncCompositionManager.cpp
@@ -339,27 +339,33 @@ AsyncCompositionManager::ApplyAsyncConte
   if (!container) {
     return appliedTransform;
   }
 
   if (AsyncPanZoomController* controller = aLayer->GetAsyncPanZoomController()) {
     LayerComposite* layerComposite = aLayer->AsLayerComposite();
 
     ViewTransform treeTransform;
-    gfxPoint scrollOffset;
+    gfx::Point scrollOffset;
     *aWantNextFrame |=
       controller->SampleContentTransformForFrame(aCurrentFrame,
                                                  container,
                                                  &treeTransform,
-                                                 &scrollOffset);
+                                                 scrollOffset);
 
+    const gfx3DMatrix& rootTransform = mLayerManager->GetRoot()->GetTransform();
+    const FrameMetrics& metrics = container->GetFrameMetrics();
+    gfx::Rect displayPortLayersPixels(metrics.mCriticalDisplayPort.IsEmpty() ?
+                                      metrics.mDisplayPort : metrics.mCriticalDisplayPort);
     gfx::Margin fixedLayerMargins(0, 0, 0, 0);
     float offsetX = 0, offsetY = 0;
-    SyncFrameMetrics(aLayer, treeTransform, scrollOffset, fixedLayerMargins,
-                     offsetX, offsetY, mIsFirstPaint, mLayersUpdated);
+    SyncFrameMetrics(scrollOffset, treeTransform.mScale.width, metrics.mScrollableRect,
+                     mLayersUpdated, displayPortLayersPixels, 1 / rootTransform.GetXScale(),
+                     mIsFirstPaint, fixedLayerMargins, offsetX, offsetY);
+
     mIsFirstPaint = false;
     mLayersUpdated = false;
 
     // Apply the render offset
     mLayerManager->GetCompositor()->SetScreenRenderOffset(gfx::Point(offsetX, offsetY));
 
     gfx3DMatrix transform(gfx3DMatrix(treeTransform) * aLayer->GetTransform());
     // The transform already takes the resolution scale into account.  Since we
@@ -584,10 +590,30 @@ AsyncCompositionManager::SyncViewportInf
                                             aLayersUpdated,
                                             aScrollOffset,
                                             aScaleX, aScaleY,
                                             aFixedLayerMargins,
                                             aOffsetX, aOffsetY);
 #endif
 }
 
+void
+AsyncCompositionManager::SyncFrameMetrics(const gfx::Point& aOffset,
+                                          float aZoom,
+                                          const gfx::Rect& aCssPageRect,
+                                          bool aLayersUpdated,
+                                          const gfx::Rect& aDisplayPort,
+                                          float aDisplayResolution,
+                                          bool aIsFirstPaint,
+                                          gfx::Margin& aFixedLayerMargins,
+                                          float& aOffsetX, float& aOffsetY)
+{
+#ifdef MOZ_ANDROID_WIDGET
+  AndroidBridge::Bridge()->SyncFrameMetrics(aOffset, aZoom, aCssPageRect,
+                                            aLayersUpdated, aDisplayPort,
+                                            aDisplayResolution, aIsFirstPaint,
+                                            aFixedLayerMargins,
+                                            aOffsetX, aOffsetY);
+#endif
+}
+
 } // namespace layers
 } // namespace mozilla
--- a/gfx/layers/composite/AsyncCompositionManager.h
+++ b/gfx/layers/composite/AsyncCompositionManager.h
@@ -125,21 +125,25 @@ private:
   void SetPageRect(const gfx::Rect& aCssPageRect);
   void SyncViewportInfo(const nsIntRect& aDisplayPort,
                         float aDisplayResolution,
                         bool aLayersUpdated,
                         nsIntPoint& aScrollOffset,
                         float& aScaleX, float& aScaleY,
                         gfx::Margin& aFixedLayerMargins,
                         float& aOffsetX, float& aOffsetY);
-  virtual void SyncFrameMetrics(Layer* aLayer, const ViewTransform& aTreeTransform,
-                                const gfxPoint& aScrollOffset, gfx::Margin& aFixedLayerMargins,
-                                float& aOffsetX, float& aOffsetY,
-                                bool aIsFirstPaint, bool aLayersUpdated)
-  {}
+  void SyncFrameMetrics(const gfx::Point& aOffset,
+                        float aZoom,
+                        const gfx::Rect& aCssPageRect,
+                        bool aLayersUpdated,
+                        const gfx::Rect& aDisplayPort,
+                        float aDisplayResolution,
+                        bool aIsFirstPaint,
+                        gfx::Margin& aFixedLayerMargins,
+                        float& aOffsetX, float& aOffsetY);
 
   /**
    * Recursively applies the given translation to all top-level fixed position
    * layers that are descendants of the given layer.
    * aScaleDiff is considered to be the scale transformation applied when
    * displaying the layers, and is used to make sure the anchor points of
    * fixed position layers remain in the same position.
    */
--- a/gfx/layers/ipc/AsyncPanZoomController.cpp
+++ b/gfx/layers/ipc/AsyncPanZoomController.cpp
@@ -1110,17 +1110,17 @@ AsyncPanZoomController::FireAsyncScrollO
     SendAsyncScrollEvent();
   }
   mAsyncScrollTimeoutTask = nullptr;
 }
 
 bool AsyncPanZoomController::SampleContentTransformForFrame(const TimeStamp& aSampleTime,
                                                             ContainerLayer* aLayer,
                                                             ViewTransform* aNewTransform,
-                                                            gfxPoint* aScrollOffset) {
+                                                            gfx::Point& aScrollOffset) {
   // The eventual return value of this function. The compositor needs to know
   // whether or not to advance by a frame as soon as it can. For example, if a
   // fling is happening, it has to keep compositing so that the animation is
   // smooth. If an animation frame is requested, it is the compositor's
   // responsibility to schedule a composite.
   bool requestAnimationFrame = false;
 
   const gfx3DMatrix& currentTransform = aLayer->GetTransform();
@@ -1219,17 +1219,18 @@ bool AsyncPanZoomController::SampleConte
     MessageLoop::current()->PostDelayedTask(FROM_HERE,
                                             mAsyncScrollTimeoutTask,
                                             mAsyncScrollTimeout);
   }
 
   gfxPoint scrollCompensation(
     (scrollOffset / rootScale - metricsScrollOffset) * localScale);
   *aNewTransform = ViewTransform(-scrollCompensation, localScale);
-  *aScrollOffset = scrollOffset * localScale;
+  aScrollOffset.x = scrollOffset.x * localScale.width;
+  aScrollOffset.y = scrollOffset.y * localScale.height;
 
   mLastSampleTime = aSampleTime;
 
   return requestAnimationFrame;
 }
 
 void AsyncPanZoomController::NotifyLayersUpdated(const FrameMetrics& aViewportFrame, bool aIsFirstPaint) {
   MonitorAutoLock monitor(mMonitor);
--- a/gfx/layers/ipc/AsyncPanZoomController.h
+++ b/gfx/layers/ipc/AsyncPanZoomController.h
@@ -173,17 +173,17 @@ public:
    *
    * Return value indicates whether or not any currently running animation
    * should continue. That is, if true, the compositor should schedule another
    * composite.
    */
   bool SampleContentTransformForFrame(const TimeStamp& aSampleTime,
                                       ContainerLayer* aLayer,
                                       ViewTransform* aNewTransform,
-                                      gfxPoint* aScrollOffset);
+                                      gfx::Point& aScrollOffset);
 
   /**
    * A shadow layer update has arrived. |aViewportFrame| is the new FrameMetrics
    * for the top-level frame. |aIsFirstPaint| is a flag passed from the shadow
    * layers code indicating that the frame metrics being sent with this call are
    * the initial metrics and the initial paint of the frame has just happened.
    */
   void NotifyLayersUpdated(const FrameMetrics& aViewportFrame, bool aIsFirstPaint);
--- a/widget/android/nsWindow.cpp
+++ b/widget/android/nsWindow.cpp
@@ -2487,34 +2487,16 @@ public:
         CompositorParent::ShadowLayersUpdated(aLayerTree, aTargetConfig, isFirstPaint);
         Layer* targetLayer = GetLayerManager()->GetPrimaryScrollableLayer();
         AsyncPanZoomController* controller = nsWindow::GetPanZoomController();
         if (targetLayer && targetLayer->AsContainerLayer() && controller) {
             targetLayer->SetAsyncPanZoomController(controller);
             controller->NotifyLayersUpdated(targetLayer->AsContainerLayer()->GetFrameMetrics(), isFirstPaint);
         }
     }
-
-    virtual void SyncFrameMetrics(Layer* aLayer, const ViewTransform& aTreeTransform,
-                                  const gfxPoint& aScrollOffset, mozilla::gfx::Margin& aFixedLayerMargins,
-                                  float& aOffsetX, float& aOffsetY,
-                                  bool aIsFirstPaint, bool aLayersUpdated) MOZ_OVERRIDE
-    {
-        const gfx3DMatrix& rootTransform = GetLayerManager()->GetRoot()->GetTransform();
-        ContainerLayer* container = aLayer->AsContainerLayer();
-        const FrameMetrics& metrics = container->GetFrameMetrics();
-
-        mozilla::gfx::Rect displayPortLayersPixels(metrics.mCriticalDisplayPort.IsEmpty() ?
-                                          metrics.mDisplayPort : metrics.mCriticalDisplayPort);
-        mozilla::gfx::Point scrollOffset(aScrollOffset.x, aScrollOffset.y);
-
-        AndroidBridge::Bridge()->SyncFrameMetrics(scrollOffset, aTreeTransform.mScale.width, metrics.mScrollableRect,
-                                                  aLayersUpdated, displayPortLayersPixels, 1 / rootTransform.GetXScale(),
-                                                  aIsFirstPaint, aFixedLayerMargins, aOffsetX, aOffsetY);
-    }
 };
 
 CompositorParent*
 nsWindow::NewCompositorParent(int aSurfaceWidth, int aSurfaceHeight)
 {
     return new AndroidCompositorParent(this, true, aSurfaceWidth, aSurfaceHeight);
 }