Add a couple of helper functions to AsyncCompositionManager
MozReview-Commit-ID: EeyWigqB26L
--- 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)