Bug 1321428 - Add a couple of helper functions to AsyncCompositionManager. r=kats
MozReview-Commit-ID: EeyWigqB26L
--- 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;