Bug 950487 - Remove unnecessary UpdateCompositionBounds function on APZC. r=Cwiiis, a=1.3+
authorKartikaya Gupta <kgupta@mozilla.com>
Tue, 17 Dec 2013 14:25:57 -0500
changeset 174380 d913ebd1569f8288bae4e1eea304127188a181f2
parent 174379 63d2929a55edefcb9861dc837c2d748ddd299057
child 174381 11ba1c9fa26874e664037d06d3ed097ea1a47e3f
push id3224
push userlsblakk@mozilla.com
push dateTue, 04 Feb 2014 01:06:49 +0000
treeherdermozilla-beta@60c04d0987f1 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersCwiiis, 1
bugs950487
milestone28.0a2
Bug 950487 - Remove unnecessary UpdateCompositionBounds function on APZC. r=Cwiiis, a=1.3+
dom/ipc/TabParent.cpp
gfx/layers/composite/APZCTreeManager.cpp
gfx/layers/composite/APZCTreeManager.h
gfx/layers/ipc/AsyncPanZoomController.cpp
gfx/layers/ipc/AsyncPanZoomController.h
layout/ipc/RenderFrameParent.cpp
layout/ipc/RenderFrameParent.h
--- a/dom/ipc/TabParent.cpp
+++ b/dom/ipc/TabParent.cpp
@@ -479,20 +479,16 @@ TabParent::UpdateDimensions(const nsRect
   if (!mUpdatedDimensions || mOrientation != orientation ||
       mDimensions != size || !mRect.IsEqualEdges(rect)) {
     mUpdatedDimensions = true;
     mRect = rect;
     mDimensions = size;
     mOrientation = orientation;
 
     unused << SendUpdateDimensions(mRect, mDimensions, mOrientation);
-    if (RenderFrameParent* rfp = GetRenderFrame()) {
-      rfp->NotifyDimensionsChanged(ScreenIntSize::FromUnknownSize(
-        gfx::IntSize(mDimensions.width, mDimensions.height)));
-    }
   }
 }
 
 void
 TabParent::UpdateFrame(const FrameMetrics& aFrameMetrics)
 {
   if (!mIsDestroyed) {
     unused << SendUpdateFrame(aFrameMetrics);
@@ -1666,22 +1662,16 @@ TabParent::RecvBrowserFrameOpenWindow(PB
 }
 
 bool
 TabParent::RecvPRenderFrameConstructor(PRenderFrameParent* actor,
                                        ScrollingBehavior* scrolling,
                                        TextureFactoryIdentifier* factoryIdentifier,
                                        uint64_t* layersId)
 {
-  RenderFrameParent* rfp = GetRenderFrame();
-  if (mDimensions != nsIntSize() && rfp) {
-    rfp->NotifyDimensionsChanged(ScreenIntSize::FromUnknownSize(
-      gfx::IntSize(mDimensions.width, mDimensions.height)));
-  }
-
   return true;
 }
 
 bool
 TabParent::RecvZoomToRect(const uint32_t& aPresShellId,
                           const ViewID& aViewId,
                           const CSSRect& aRect)
 {
--- a/gfx/layers/composite/APZCTreeManager.cpp
+++ b/gfx/layers/composite/APZCTreeManager.cpp
@@ -549,30 +549,16 @@ APZCTreeManager::ReceiveInputEvent(Widge
     }
     default: {
       return ProcessEvent(aEvent, aOutTargetGuid, &aEvent);
     }
   }
 }
 
 void
-APZCTreeManager::UpdateRootCompositionBounds(const uint64_t& aLayersId,
-                                             const ScreenIntRect& aCompositionBounds)
-{
-  // There can be multiple root APZCs for a given layers id (e.g. tabs in
-  // a single-process setup) and in such a case we probably want to notify
-  // all of them.
-  nsTArray< nsRefPtr<AsyncPanZoomController> > rootApzcs;
-  GetRootAPZCsFor(aLayersId, &rootApzcs);
-  for (size_t i = 0; i < rootApzcs.Length(); i++) {
-    rootApzcs[i]->UpdateCompositionBounds(aCompositionBounds);
-  }
-}
-
-void
 APZCTreeManager::ZoomToRect(const ScrollableLayerGuid& aGuid,
                             const CSSRect& aRect)
 {
   nsRefPtr<AsyncPanZoomController> apzc = GetTargetAPZC(aGuid);
   if (apzc) {
     apzc->ZoomToRect(aRect);
   }
 }
@@ -779,27 +765,16 @@ APZCTreeManager::BuildOverscrollHandoffC
   // non-scrollgrabbing APZCs remains child -> parent.
   // (The relative order between scrollgrabbing APZCs will also remain
   // child -> parent, though that's just an artefact of the implementation
   // and users of 'scrollgrab' should not rely on this.)
   std::stable_sort(mOverscrollHandoffChain.begin(), mOverscrollHandoffChain.end(),
                    CompareByScrollPriority());
 }
 
-void
-APZCTreeManager::GetRootAPZCsFor(const uint64_t& aLayersId,
-                                 nsTArray< nsRefPtr<AsyncPanZoomController> >* aOutRootApzcs)
-{
-  MonitorAutoLock lock(mTreeLock);
-  // The root may have siblings, check those too
-  for (AsyncPanZoomController* apzc = mRootApzc; apzc; apzc = apzc->GetPrevSibling()) {
-    FindRootAPZCs(apzc, aLayersId, aOutRootApzcs);
-  }
-}
-
 AsyncPanZoomController*
 APZCTreeManager::FindTargetAPZC(AsyncPanZoomController* aApzc, const ScrollableLayerGuid& aGuid)
 {
   mTreeLock.AssertCurrentThreadOwns();
 
   // This walks the tree in depth-first, reverse order, so that it encounters
   // APZCs front-to-back on the screen.
   for (AsyncPanZoomController* child = aApzc->GetLastChild(); child; child = child->GetPrevSibling()) {
@@ -866,35 +841,16 @@ APZCTreeManager::GetAPZCAtPoint(AsyncPan
   if (aApzc->VisibleRegionContains(ScreenPoint(hitTestPointForThisLayer.x, hitTestPointForThisLayer.y))) {
     APZC_LOG("Successfully matched untransformed point %f %f to visible region for APZC %p\n",
              hitTestPointForThisLayer.x, hitTestPointForThisLayer.y, aApzc);
     return aApzc;
   }
   return nullptr;
 }
 
-void
-APZCTreeManager::FindRootAPZCs(AsyncPanZoomController* aApzc,
-                               const uint64_t& aLayersId,
-                               nsTArray< nsRefPtr<AsyncPanZoomController> >* aOutRootApzcs)
-{
-  mTreeLock.AssertCurrentThreadOwns();
-
-  if (aApzc->IsRootForLayersId(aLayersId)) {
-    aOutRootApzcs->AppendElement(aApzc);
-    // If this APZC is a root for this layers id then we know nothing else
-    // in the subtree rooted here will match so we can early-exit
-    return;
-  }
-
-  for (AsyncPanZoomController* child = aApzc->GetLastChild(); child; child = child->GetPrevSibling()) {
-    FindRootAPZCs(child, aLayersId, aOutRootApzcs);
-  }
-}
-
 /* This function sets the aTransformToApzcOut and aTransformToGeckoOut out-parameters
    to some useful transformations that input events may need applied. This is best
    illustrated with an example. Consider a chain of layers, L, M, N, O, P, Q, R. Layer L
    is the layer that corresponds to the returned APZC instance, and layer R is the root
    of the layer tree. Layer M is the parent of L, N is the parent of M, and so on.
    When layer L is displayed to the screen by the compositor, the set of transforms that
    are applied to L are (in order from top to bottom):
 
--- a/gfx/layers/composite/APZCTreeManager.h
+++ b/gfx/layers/composite/APZCTreeManager.h
@@ -130,27 +130,16 @@ public:
    *
    * @param aPoint point to transform
    * @param aOutTransformedPoint resulting transformed point
    */
   void TransformCoordinateToGecko(const ScreenIntPoint& aPoint,
                                   LayoutDeviceIntPoint* aOutTransformedPoint);
 
   /**
-   * Updates the composition bounds on the root APZC for the given layers id.
-   * See FrameMetrics::mCompositionBounds for the definition of what the
-   * composition bounds are. This function is only meant for updating the
-   * composition bounds on the root APZC because that is the one that is
-   * zoomable, and the zoom may need to be adjusted immediately upon a change
-   * in the composition bounds.
-   */
-  void UpdateRootCompositionBounds(const uint64_t& aLayersId,
-                                   const ScreenIntRect& aCompositionBounds);
-
-  /**
    * Kicks an animation to zoom to a rect. This may be either a zoom out or zoom
    * in. The actual animation is done on the compositor thread after being set
    * up. |aRect| must be given in CSS pixels, relative to the document.
    */
   void ZoomToRect(const ScrollableLayerGuid& aGuid,
                   const CSSRect& aRect);
 
   /**
@@ -266,27 +255,22 @@ public:
   /* Some helper functions to find an APZC given some identifying input. These functions
      lock the tree of APZCs while they find the right one, and then return an addref'd
      pointer to it. This allows caller code to just use the target APZC without worrying
      about it going away. These are public for testing code and generally should not be
      used by other production code.
   */
   already_AddRefed<AsyncPanZoomController> GetTargetAPZC(const ScrollableLayerGuid& aGuid);
   already_AddRefed<AsyncPanZoomController> GetTargetAPZC(const ScreenPoint& aPoint);
-  void GetRootAPZCsFor(const uint64_t& aLayersId,
-                       nsTArray< nsRefPtr<AsyncPanZoomController> >* aOutRootApzcs);
   void GetInputTransforms(AsyncPanZoomController *aApzc, gfx3DMatrix& aTransformToApzcOut,
                           gfx3DMatrix& aTransformToGeckoOut);
 private:
   /* Helpers */
   AsyncPanZoomController* FindTargetAPZC(AsyncPanZoomController* aApzc, const ScrollableLayerGuid& aGuid);
   AsyncPanZoomController* GetAPZCAtPoint(AsyncPanZoomController* aApzc, const gfxPoint& aHitTestPoint);
-  void FindRootAPZCs(AsyncPanZoomController* aApzc,
-                     const uint64_t& aLayersId,
-                     nsTArray< nsRefPtr<AsyncPanZoomController> >* aOutRootApzcs);
   already_AddRefed<AsyncPanZoomController> CommonAncestor(AsyncPanZoomController* aApzc1, AsyncPanZoomController* aApzc2);
   already_AddRefed<AsyncPanZoomController> RootAPZCForLayersId(AsyncPanZoomController* aApzc);
   already_AddRefed<AsyncPanZoomController> GetTouchInputBlockAPZC(const WidgetTouchEvent& aEvent, ScreenPoint aPoint);
   nsEventStatus ProcessTouchEvent(const WidgetTouchEvent& touchEvent, ScrollableLayerGuid* aOutTargetGuid, WidgetTouchEvent* aOutEvent);
   nsEventStatus ProcessMouseEvent(const WidgetMouseEvent& mouseEvent, ScrollableLayerGuid* aOutTargetGuid, WidgetMouseEvent* aOutEvent);
   nsEventStatus ProcessEvent(const WidgetInputEvent& inputEvent, ScrollableLayerGuid* aOutTargetGuid, WidgetInputEvent* aOutEvent);
   void UpdateZoomConstraintsRecursively(AsyncPanZoomController* aApzc,
                                         bool aAllowZoom,
--- a/gfx/layers/ipc/AsyncPanZoomController.cpp
+++ b/gfx/layers/ipc/AsyncPanZoomController.cpp
@@ -1451,38 +1451,16 @@ void AsyncPanZoomController::NotifyLayer
   }
 }
 
 const FrameMetrics& AsyncPanZoomController::GetFrameMetrics() {
   mMonitor.AssertCurrentThreadIn();
   return mFrameMetrics;
 }
 
-void AsyncPanZoomController::UpdateCompositionBounds(const ScreenIntRect& aCompositionBounds) {
-  ReentrantMonitorAutoEnter lock(mMonitor);
-
-  ScreenIntRect oldCompositionBounds = mFrameMetrics.mCompositionBounds;
-  mFrameMetrics.mCompositionBounds = aCompositionBounds;
-
-  // If the window had 0 dimensions before, or does now, we don't want to
-  // repaint or update the zoom since we'll run into rendering issues and/or
-  // divide-by-zero. This manifests itself as the screen flashing. If the page
-  // has gone out of view, the buffer will be cleared elsewhere anyways.
-  if (aCompositionBounds.width && aCompositionBounds.height &&
-      oldCompositionBounds.width && oldCompositionBounds.height) {
-    float adjustmentFactor = float(aCompositionBounds.width) / float(oldCompositionBounds.width);
-    mFrameMetrics.mZoom.scale =
-      clamped(mFrameMetrics.mZoom.scale * adjustmentFactor,
-              mMinZoom.scale, mMaxZoom.scale);
-
-    // Repaint on a rotation so that our new resolution gets properly updated.
-    RequestContentRepaint();
-  }
-}
-
 void AsyncPanZoomController::ZoomToRect(CSSRect aRect) {
   SetState(ANIMATING_ZOOM);
 
   {
     ReentrantMonitorAutoEnter lock(mMonitor);
 
     ScreenIntRect compositionBounds = mFrameMetrics.mCompositionBounds;
     CSSRect cssPageRect = mFrameMetrics.mScrollableRect;
--- a/gfx/layers/ipc/AsyncPanZoomController.h
+++ b/gfx/layers/ipc/AsyncPanZoomController.h
@@ -100,25 +100,16 @@ public:
    * General handler for incoming input events. Manipulates the frame metrics
    * based on what type of input it is. For example, a PinchGestureEvent will
    * cause scaling. This should only be called externally to this class.
    * HandleInputEvent() should be used internally.
    */
   nsEventStatus ReceiveInputEvent(const InputData& aEvent);
 
   /**
-   * Updates the composition bounds, i.e. the dimensions of the final size of
-   * the frame this is tied to during composition onto, in device pixels. In
-   * general, this will just be:
-   * { x = 0, y = 0, width = surface.width, height = surface.height }, however
-   * there is no hard requirement for this.
-   */
-  void UpdateCompositionBounds(const ScreenIntRect& aCompositionBounds);
-
-  /**
    * Kicks an animation to zoom to a rect. This may be either a zoom out or zoom
    * in. The actual animation is done on the compositor thread after being set
    * up.
    */
   void ZoomToRect(CSSRect aRect);
 
   /**
    * If we have touch listeners, this should always be called when we know
--- a/layout/ipc/RenderFrameParent.cpp
+++ b/layout/ipc/RenderFrameParent.cpp
@@ -886,25 +886,16 @@ RenderFrameParent::NotifyInputEvent(cons
                                     WidgetInputEvent* aOutEvent)
 {
   if (GetApzcTreeManager()) {
     GetApzcTreeManager()->ReceiveInputEvent(aEvent, aOutTargetGuid, aOutEvent);
   }
 }
 
 void
-RenderFrameParent::NotifyDimensionsChanged(ScreenIntSize size)
-{
-  if (GetApzcTreeManager()) {
-    GetApzcTreeManager()->UpdateRootCompositionBounds(
-      mLayersId, ScreenIntRect(ScreenIntPoint(), size));
-  }
-}
-
-void
 RenderFrameParent::ActorDestroy(ActorDestroyReason why)
 {
   if (mLayersId != 0) {
     CompositorParent::DeallocateLayerTreeId(mLayersId);
     if (mContentController) {
       // Stop our content controller from requesting repaints of our
       // content.
       mContentController->ClearRenderFrame();
--- a/layout/ipc/RenderFrameParent.h
+++ b/layout/ipc/RenderFrameParent.h
@@ -104,18 +104,16 @@ public:
    * @param aOutEvent An out-parameter that contains aEvent with the async transforms
    *        unapplied. This can be passed to Gecko for hit testing and normal event
    *        dispatch. This argument may not be null.
    */
   void NotifyInputEvent(const WidgetInputEvent& aEvent,
                         ScrollableLayerGuid* aOutTargetGuid,
                         WidgetInputEvent* aOutEvent);
 
-  void NotifyDimensionsChanged(ScreenIntSize size);
-
   void ZoomToRect(uint32_t aPresShellId, ViewID aViewId, const CSSRect& aRect);
 
   void ContentReceivedTouch(const ScrollableLayerGuid& aGuid,
                             bool aPreventDefault);
 
   void UpdateZoomConstraints(uint32_t aPresShellId,
                              ViewID aViewId,
                              bool aIsRoot,