diff --git a/gfx/layers/wr/WebRenderCommandBuilder.cpp b/gfx/layers/wr/WebRenderCommandBuilder.cpp index 7b3a811c96bd..b3cc48d10a50 100644 --- a/gfx/layers/wr/WebRenderCommandBuilder.cpp +++ b/gfx/layers/wr/WebRenderCommandBuilder.cpp @@ -1439,12 +1439,6 @@ void WebRenderCommandBuilder::BuildWebRenderCommands( mClipManager.BeginBuild(mManager, aBuilder); { - if (!mZoomProp && gfxPrefs::APZAllowZooming() && XRE_IsContentProcess()) { - mZoomProp.emplace(); - mZoomProp->effect_type = wr::WrAnimationType::Transform; - mZoomProp->id = AnimationHelper::GetNextCompositorAnimationsId(); - } - nsPresContext* presContext = aDisplayListBuilder->RootReferenceFrame()->PresContext(); bool isTopLevelContent = @@ -1453,7 +1447,6 @@ void WebRenderCommandBuilder::BuildWebRenderCommands( wr::StackingContextParams params; params.mFilters = std::move(aFilters.filters); params.mFilterDatas = std::move(aFilters.filter_datas); - params.animation = mZoomProp.ptrOr(nullptr); params.cache_tiles = isTopLevelContent; params.clip = wr::WrStackingContextClip::ClipChain(aBuilder.CurrentClipChainId()); @@ -1472,9 +1465,6 @@ void WebRenderCommandBuilder::BuildWebRenderCommands( // Make a "root" layer data that has everything else as descendants mLayerScrollData.emplace_back(); mLayerScrollData.back().InitializeRoot(mLayerScrollData.size() - 1); - if (mZoomProp) { - mLayerScrollData.back().SetZoomAnimationId(mZoomProp->id); - } auto callback = [&aScrollData](ScrollableLayerGuid::ViewID aScrollId) -> bool { return aScrollData.HasMetadataFor(aScrollId).isSome(); diff --git a/gfx/layers/wr/WebRenderCommandBuilder.h b/gfx/layers/wr/WebRenderCommandBuilder.h index 767d0fa55773..e1556a3ed79f 100644 --- a/gfx/layers/wr/WebRenderCommandBuilder.h +++ b/gfx/layers/wr/WebRenderCommandBuilder.h @@ -194,10 +194,6 @@ class WebRenderCommandBuilder { wr::usize mBuilderDumpIndex; wr::usize mDumpIndent; - // When zooming is enabled, this stores the animation property that we use - // to manipulate the zoom from APZ. - Maybe mZoomProp; - public: // Whether consecutive inactive display items should be grouped into one // blob image. diff --git a/layout/painting/nsDisplayList.cpp b/layout/painting/nsDisplayList.cpp index b2765dc4b64f..92803ef71b2a 100644 --- a/layout/painting/nsDisplayList.cpp +++ b/layout/painting/nsDisplayList.cpp @@ -6360,6 +6360,10 @@ bool nsDisplayOwnLayer::IsScrollbarContainer() const { layers::ScrollbarLayerType::Container; } +bool nsDisplayOwnLayer::IsZoomingLayer() const { + return GetType() == DisplayItemType::TYPE_ASYNC_ZOOM; +} + bool nsDisplayOwnLayer::ShouldBuildLayerEvenIfInvisible( nsDisplayListBuilder* aBuilder) const { // Render scroll thumb layers even if they are invisible, because async @@ -6392,10 +6396,12 @@ bool nsDisplayOwnLayer::CreateWebRenderCommands( const StackingContextHelper& aSc, RenderRootStateManager* aManager, nsDisplayListBuilder* aDisplayListBuilder) { Maybe prop; - if (aManager->LayerManager()->AsyncPanZoomEnabled() && IsScrollThumbLayer()) { - // APZ is enabled and this is a scroll thumb, so we need to create and - // set an animation id. That way APZ can move this scrollthumb around as - // needed. + bool needsProp = aManager->LayerManager()->AsyncPanZoomEnabled() && + (IsScrollThumbLayer() || IsZoomingLayer()); + if (needsProp) { + // APZ is enabled and this is a scroll thumb or zooming layer, so we need + // to create and set an animation id. That way APZ can adjust the position/ + // zoom of this content asynchronously as needed. RefPtr animationData = aManager->CommandBuilder() .CreateOrRecycleWebRenderUserData(this); @@ -6423,25 +6429,34 @@ bool nsDisplayOwnLayer::CreateWebRenderCommands( bool nsDisplayOwnLayer::UpdateScrollData( mozilla::layers::WebRenderScrollData* aData, mozilla::layers::WebRenderLayerScrollData* aLayerData) { - bool ret = false; - - if (IsScrollThumbLayer() || IsScrollbarContainer()) { - ret = true; - if (aLayerData) { - aLayerData->SetScrollbarData(mScrollbarData); - if (IsScrollThumbLayer()) { - aLayerData->SetScrollbarAnimationId(mWrAnimationId); - LayoutDeviceRect bounds = LayoutDeviceIntRect::FromAppUnits( - mBounds, mFrame->PresContext()->AppUnitsPerDevPixel()); - // Assume a resolution of 1.0 for now because this is a WebRender - // codepath and we don't really handle resolution on the Gecko side - LayerIntRect layerBounds = - RoundedOut(bounds * LayoutDeviceToLayerScale(1.0f)); - aLayerData->SetVisibleRegion(LayerIntRegion(layerBounds)); - } - } + bool isRelevantToApz = + (IsScrollThumbLayer() || IsScrollbarContainer() || IsZoomingLayer()); + if (!isRelevantToApz) { + return false; } - return ret; + + if (!aLayerData) { + return true; + } + + if (IsZoomingLayer()) { + aLayerData->SetZoomAnimationId(mWrAnimationId); + return true; + } + + aLayerData->SetScrollbarData(mScrollbarData); + if (IsScrollThumbLayer()) { + aLayerData->SetScrollbarAnimationId(mWrAnimationId); + LayoutDeviceRect bounds = LayoutDeviceIntRect::FromAppUnits( + mBounds, mFrame->PresContext()->AppUnitsPerDevPixel()); + // We use a resolution of 1.0 because this is a WebRender codepath which + // always uses containerless scrolling, and so resolution doesn't apply to + // scrollbars. + LayerIntRect layerBounds = + RoundedOut(bounds * LayoutDeviceToLayerScale(1.0f)); + aLayerData->SetVisibleRegion(LayerIntRegion(layerBounds)); + } + return true; } void nsDisplayOwnLayer::WriteDebugInfo(std::stringstream& aStream) { diff --git a/layout/painting/nsDisplayList.h b/layout/painting/nsDisplayList.h index 2f1c754e1be0..185cae3a58cc 100644 --- a/layout/painting/nsDisplayList.h +++ b/layout/painting/nsDisplayList.h @@ -5727,6 +5727,7 @@ class nsDisplayOwnLayer : public nsDisplayWrapList { nsDisplayOwnLayerFlags GetFlags() { return mFlags; } bool IsScrollThumbLayer() const; bool IsScrollbarContainer() const; + bool IsZoomingLayer() const; protected: nsDisplayOwnLayerFlags mFlags;