From 5ad125fce1c1e0967ffd941de110a6080ac7c349 Mon Sep 17 00:00:00 2001 From: Brad Werth Date: Thu, 18 Nov 2021 21:28:44 +0000 Subject: [PATCH] Bug 1738926 Part 1: Check if sublayers need to be rebuilt. r=mstange This fixes a correctness issue. Since NativeLayerCA Representations can generate new CALayers under certain conditions, the NativeLayerRootCA must check to see if a rebuild is necessary when committing. Differential Revision: https://phabricator.services.mozilla.com/D131307 --- gfx/layers/NativeLayerCA.h | 1 + gfx/layers/NativeLayerCA.mm | 6 ++++++ 2 files changed, 7 insertions(+) diff --git a/gfx/layers/NativeLayerCA.h b/gfx/layers/NativeLayerCA.h index 6e4540dc548b..6d4a974c13c0 100644 --- a/gfx/layers/NativeLayerCA.h +++ b/gfx/layers/NativeLayerCA.h @@ -276,6 +276,7 @@ class NativeLayerCA : public NativeLayer { CALayer* UnderlyingCALayer(WhichRepresentation aRepresentation); void ApplyChanges(WhichRepresentation aRepresentation); bool HasUpdate(WhichRepresentation aRepresentation); + bool HasUpdateAffectingLayers(WhichRepresentation aRepresentation); void SetBackingScale(float aBackingScale); // Invalidates the specified region in all surfaces that are tracked by this diff --git a/gfx/layers/NativeLayerCA.mm b/gfx/layers/NativeLayerCA.mm index 89c5f20ba153..f8c050aa08a6 100644 --- a/gfx/layers/NativeLayerCA.mm +++ b/gfx/layers/NativeLayerCA.mm @@ -335,6 +335,7 @@ void NativeLayerRootCA::Representation::Commit(WhichRepresentation aRepresentati // list of sublayers. The order is important because we need layer->UnderlyingCALayer() // to be non-null, and the underlying CALayer gets lazily initialized in ApplyChanges(). for (auto layer : aSublayers) { + mustRebuild |= layer->HasUpdateAffectingLayers(aRepresentation); layer->ApplyChanges(aRepresentation); } @@ -1194,6 +1195,11 @@ bool NativeLayerCA::HasUpdate(WhichRepresentation aRepresentation) { return GetRepresentation(aRepresentation).HasUpdate(); } +bool NativeLayerCA::HasUpdateAffectingLayers(WhichRepresentation aRepresentation) { + MutexAutoLock lock(mMutex); + return GetRepresentation(aRepresentation).mMutatedSpecializeVideo; +} + CALayer* NativeLayerCA::UnderlyingCALayer(WhichRepresentation aRepresentation) { MutexAutoLock lock(mMutex); return GetRepresentation(aRepresentation).UnderlyingCALayer();