Add a couple of helper functions to AsyncCompositionManager draft
authorBotond Ballo <botond@mozilla.com>
Fri, 05 Aug 2016 15:27:53 -0400
changeset 397402 db6fb06d6d1da0de0ed0828eec2d90f7cb9e5286
parent 397401 ac3cb4c92b9c8c25703d119ae91dfecf96772b56
child 397403 97e5fd61b2bdeb043d64b3aec983df02aea320f1
push id25288
push userbballo@mozilla.com
push dateFri, 05 Aug 2016 19:41:51 +0000
milestone50.0a1
Add a couple of helper functions to AsyncCompositionManager MozReview-Commit-ID: EeyWigqB26L
gfx/layers/composite/AsyncCompositionManager.cpp
--- a/gfx/layers/composite/AsyncCompositionManager.cpp
+++ b/gfx/layers/composite/AsyncCompositionManager.cpp
@@ -591,16 +591,56 @@ SampleValue(float aPortion, Animation& a
                                                     data.appUnitsPerDevPixel(),
                                                     flags, &data.bounds());
 
   InfallibleTArray<TransformFunction> functions;
   functions.AppendElement(TransformMatrix(transform));
   *aValue = functions;
 }
 
+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)
+{
+  if (AsyncPanZoomController* apzc = aRoot.GetApzc()) {
+    ScrollableLayerGuid guid = apzc->GetGuid();
+    if (guid.mLayersId == aLayersId && guid.mScrollId == aViewId) {
+      return apzc;
+    }
+  }
+  for (LayerMetricsWrapper child = aRoot.GetFirstChild(); child;
+       child = child.GetNextSibling()) {
+    if (AsyncPanZoomController* apzc = FindAPZC(child, aLayersId, aViewId)) {
+      return apzc;
+    }
+  }
+  return nullptr;
+}
+
 static bool
 SampleAnimations(Layer* aLayer, TimeStamp aPoint)
 {
   bool activeAnimations = false;
 
   ForEachNode<ForwardIterator>(
       aLayer,
       [&activeAnimations, &aPoint] (Layer* layer)