Bug 1321428 - Add a couple of helper functions to AsyncCompositionManager. r=kats draft
authorBotond Ballo <botond@mozilla.com>
Fri, 05 Aug 2016 15:27:53 -0400
changeset 542201 8609e1cfc7e52793739986c1fc7540dcdc123964
parent 542200 5f1938fd2be6dfe7423c3fd66b1d2f6898f05214
child 542202 af5a4d47d9fe6df1c1ef7a465ec9c486e6f9fa4c
push id50961
push userbballo@mozilla.com
push dateFri, 24 Mar 2017 22:03:27 +0000
reviewerskats
bugs1321428
milestone55.0a1
Bug 1321428 - Add a couple of helper functions to AsyncCompositionManager. r=kats MozReview-Commit-ID: EeyWigqB26L
gfx/layers/composite/AsyncCompositionManager.cpp
--- a/gfx/layers/composite/AsyncCompositionManager.cpp
+++ b/gfx/layers/composite/AsyncCompositionManager.cpp
@@ -640,16 +640,56 @@ ApplyAnimatedValue(Layer* aLayer,
                                  transformData);
       break;
     }
     default:
       MOZ_ASSERT_UNREACHABLE("Unhandled animated property");
   }
 }
 
+static uint64_t
+LayersIdFor(Layer* aLayer)
+{
+  Layer* layer = aLayer;
+  while (layer) {
+    if (layer->AsRefLayer()) {
+      return layer->AsRefLayer()->GetReferentId();
+    }
+    layer = layer->GetParent();
+  }
+
+  // Return the root layer tree ID.
+  if (LayerManager* manager = aLayer->Manager()) {
+    if (Compositor* compositor = manager->AsLayerManagerComposite()->GetCompositor()) {
+      if (CompositorBridgeParent* parent = compositor->GetCompositorBridgeParent()) {
+        return parent->RootLayerTreeId();
+      }
+    }
+  }
+  return 0;
+}
+
+static AsyncPanZoomController*
+FindAPZC(LayerMetricsWrapper aRoot, uint64_t aLayersId, FrameMetrics::ViewID aViewId)
+{
+  LayerMetricsWrapper result = DepthFirstSearch<ForwardIterator>(
+      aRoot,
+      [aLayersId, aViewId] (LayerMetricsWrapper aLayer)
+      {
+        if (AsyncPanZoomController* apzc = aLayer.GetApzc()) {
+          ScrollableLayerGuid guid = apzc->GetGuid();
+          if (guid.mLayersId == aLayersId && guid.mScrollId == aViewId) {
+            return true;
+          }
+        }
+        return false;
+      });
+  return result.IsValid() ? result.GetApzc() : nullptr;
+}
+
 static bool
 SampleAnimations(Layer* aLayer,
                  CompositorAnimationStorage* aStorage,
                  TimeStamp aPoint,
                  uint64_t* aLayerAreaAnimated)
 {
   bool activeAnimations = false;