commit db48e85b637a4bb7da82773fcc94df7dc714a5c9
parent 4c982435788b70ad8361c83b15a6702eb18ec8d4
Author: Markus Stange <mstange.moz@gmail.com>
Date: Thu, 2 Oct 2025 20:49:11 +0000
Bug 1987007 - Fold WillUpdateAffectLayers into ApplyChanges. r=bradwerth
Differential Revision: https://phabricator.services.mozilla.com/D267142
Diffstat:
2 files changed, 21 insertions(+), 18 deletions(-)
diff --git a/gfx/layers/NativeLayerCA.h b/gfx/layers/NativeLayerCA.h
@@ -316,8 +316,12 @@ class NativeLayerCA : public NativeLayer {
};
UpdateType HasUpdate(WhichRepresentation aRepresentation);
- bool WillUpdateAffectLayers(WhichRepresentation aRepresentation);
- bool ApplyChanges(WhichRepresentation aRepresentation, UpdateType aUpdate);
+
+ // Apply pending updates to the underlaying CALayer. Sets *aMustRebuild to
+ // true if the update requires changing which set of CALayers should be in the
+ // parent.
+ bool ApplyChanges(WhichRepresentation aRepresentation, UpdateType aUpdate,
+ bool* aMustRebuild);
void SetBackingScale(float aBackingScale);
diff --git a/gfx/layers/NativeLayerCA.mm b/gfx/layers/NativeLayerCA.mm
@@ -471,8 +471,10 @@ void NativeLayerRootCA::CommitRepresentation(
bool allUpdatesSucceeded = std::all_of(
aSublayers.begin(), aSublayers.end(),
[=](const RefPtr<NativeLayerCA>& layer) {
+ bool ignoredMustRebuild = false;
return layer->ApplyChanges(aRepresentation,
- NativeLayerCA::UpdateType::OnlyVideo);
+ NativeLayerCA::UpdateType::OnlyVideo,
+ &ignoredMustRebuild);
});
if (allUpdatesSucceeded) {
@@ -488,8 +490,8 @@ void NativeLayerRootCA::CommitRepresentation(
AutoCATransaction transaction;
nsTArray<NativeLayerCA*> sublayersWithExtent;
for (auto layer : aSublayers) {
- mustRebuild |= layer->WillUpdateAffectLayers(aRepresentation);
- layer->ApplyChanges(aRepresentation, NativeLayerCA::UpdateType::All);
+ layer->ApplyChanges(aRepresentation, NativeLayerCA::UpdateType::All,
+ &mustRebuild);
CALayer* caLayer = layer->UnderlyingCALayer(aRepresentation);
if (!caLayer.masksToBounds || !CGRectIsEmpty(caLayer.bounds)) {
// This layer has an extent. If it didn't before, we need to rebuild.
@@ -1490,7 +1492,8 @@ Maybe<CGRect> NativeLayerCA::CalculateClipGeometry(
}
bool NativeLayerCA::ApplyChanges(WhichRepresentation aRepresentation,
- NativeLayerCA::UpdateType aUpdate) {
+ NativeLayerCA::UpdateType aUpdate,
+ bool* aMustRebuild) {
MutexAutoLock lock(mMutex);
CFTypeRefPtr<IOSurfaceRef> surface;
IntSize size = mSize;
@@ -1510,11 +1513,14 @@ bool NativeLayerCA::ApplyChanges(WhichRepresentation aRepresentation,
surface = mTextureHost->GetSurface()->GetIOSurfaceRef();
}
- return GetRepresentation(aRepresentation)
- .ApplyChanges(aUpdate, size, mIsOpaque, mPosition, mTransform,
- displayRect, mClipRect, mRoundedClipRect, mBackingScale,
- surfaceIsFlipped, mSamplingFilter, mSpecializeVideo,
- surface, mColor, mIsDRM, IsVideo(lock));
+ auto& r = GetRepresentation(aRepresentation);
+ if (r.mMutatedSpecializeVideo || !r.UnderlyingCALayer()) {
+ *aMustRebuild = true;
+ }
+ return r.ApplyChanges(aUpdate, size, mIsOpaque, mPosition, mTransform,
+ displayRect, mClipRect, mRoundedClipRect, mBackingScale,
+ surfaceIsFlipped, mSamplingFilter, mSpecializeVideo,
+ surface, mColor, mIsDRM, IsVideo(lock));
}
CALayer* NativeLayerCA::UnderlyingCALayer(WhichRepresentation aRepresentation) {
@@ -2110,13 +2116,6 @@ NativeLayerCA::UpdateType NativeLayerCA::Representation::HasUpdate(
return UpdateType::None;
}
-bool NativeLayerCA::WillUpdateAffectLayers(
- WhichRepresentation aRepresentation) {
- MutexAutoLock lock(mMutex);
- auto& r = GetRepresentation(aRepresentation);
- return r.mMutatedSpecializeVideo || !r.UnderlyingCALayer();
-}
-
bool DownscaleTargetNLRS::DownscaleFrom(
profiler_screenshots::RenderSource* aSource, const IntRect& aSourceRect,
const IntRect& aDestRect) {