Bug 941138 - Move the code to update the cached transform. r=botond
authorKartikaya Gupta <kgupta@mozilla.com>
Fri, 17 Jan 2014 09:52:49 -0500
changeset 163966 ff662b5b45f4dcd08c4b64dba00c6ac4f99c4ab6
parent 163965 965cf4cbedc833a357c2f738d362a669ed48466a
child 163967 cb989ceae01be259962228b1a7b54250dcb85775
push id26021
push userryanvm@gmail.com
push dateFri, 17 Jan 2014 19:46:56 +0000
treeherdermozilla-central@316466d0b962 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbotond
bugs941138
milestone29.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 941138 - Move the code to update the cached transform. r=botond
gfx/layers/composite/APZCTreeManager.cpp
--- a/gfx/layers/composite/APZCTreeManager.cpp
+++ b/gfx/layers/composite/APZCTreeManager.cpp
@@ -395,37 +395,30 @@ APZCTreeManager::GetTouchInputBlockAPZC(
                                         ScreenPoint aPoint)
 {
   nsRefPtr<AsyncPanZoomController> apzc = GetTargetAPZC(aPoint);
   if (aEvent.touches.Length() == 1) {
     // If we have one touch point, this might be the start of a pan.
     // Prepare for possible overscroll handoff.
     BuildOverscrollHandoffChain(apzc);
   }
-  gfx3DMatrix transformToApzc, transformToGecko;
-  // Reset the cached apz transform
-  mCachedTransformToApzcForInputBlock = transformToApzc;
   if (!apzc) {
     return apzc.forget();
   }
   for (size_t i = 1; i < aEvent.touches.Length(); i++) {
     nsIntPoint point = aEvent.touches[i]->mRefPoint;
     nsRefPtr<AsyncPanZoomController> apzc2 =
       GetTargetAPZC(ScreenPoint(point.x, point.y));
     apzc = CommonAncestor(apzc.get(), apzc2.get());
     APZC_LOG("Using APZC %p as the common ancestor\n", apzc.get());
     // For now, we only ever want to do pinching on the root APZC for a given layers id. So
     // when we find the common ancestor of multiple points, also walk up to the root APZC.
     apzc = RootAPZCForLayersId(apzc);
     APZC_LOG("Using APZC %p as the root APZC for multi-touch\n", apzc.get());
   }
-  if (apzc) {
-    // Cache apz transform so it can be used for future events in this block.
-    GetInputTransforms(apzc, mCachedTransformToApzcForInputBlock, transformToGecko);
-  }
   return apzc.forget();
 }
 
 nsEventStatus
 APZCTreeManager::ProcessTouchEvent(const WidgetTouchEvent& aEvent,
                                    ScrollableLayerGuid* aOutTargetGuid,
                                    WidgetTouchEvent* aOutEvent)
 {
@@ -434,16 +427,24 @@ APZCTreeManager::ProcessTouchEvent(const
   nsEventStatus ret = nsEventStatus_eIgnore;
   if (!aEvent.touches.Length()) {
     return ret;
   }
   if (aEvent.message == NS_TOUCH_START) {
     mTouchCount++;
     ScreenPoint point = ScreenPoint(aEvent.touches[0]->mRefPoint.x, aEvent.touches[0]->mRefPoint.y);
     mApzcForInputBlock = GetTouchInputBlockAPZC(aEvent, point);
+    if (mApzcForInputBlock) {
+      // Cache apz transform so it can be used for future events in this block.
+      gfx3DMatrix transformToGecko;
+      GetInputTransforms(mApzcForInputBlock, mCachedTransformToApzcForInputBlock, transformToGecko);
+    } else {
+      // Reset the cached apz transform
+      mCachedTransformToApzcForInputBlock = gfx3DMatrix();
+    }
   }
 
   if (mApzcForInputBlock) {
     mApzcForInputBlock->GetGuid(aOutTargetGuid);
     // For computing the input for the APZC, used the cached transform.
     // This ensures that the sequence of touch points an APZC sees in an
     // input block are all in the same coordinate space.
     gfx3DMatrix transformToApzc = mCachedTransformToApzcForInputBlock;