@@ -283,6 +283,14 @@ bool DownscaleFrom(profiler_screenshots::RenderSource* aSource, const IntRect& a
283
283
284
284
void NativeLayerRootCA::Representation::Commit (WhichRepresentation aRepresentation,
285
285
const nsTArray<RefPtr<NativeLayerCA>>& aSublayers) {
286
+ if (!mMutated &&
287
+ std::none_of (aSublayers.begin (), aSublayers.end (), [=](const RefPtr<NativeLayerCA>& layer) {
288
+ return layer->HasUpdate (aRepresentation);
289
+ })) {
290
+ // No updates, skip creating the CATransaction altogether.
291
+ return ;
292
+ }
293
+
286
294
AutoCATransaction transaction;
287
295
288
296
// Call ApplyChanges on our sublayers first, and then update the root layer's
@@ -805,6 +813,11 @@ bool DownscaleFrom(profiler_screenshots::RenderSource* aSource, const IntRect& a
805
813
mSurfaceIsFlipped , mSamplingFilter , surface);
806
814
}
807
815
816
+ bool NativeLayerCA::HasUpdate (WhichRepresentation aRepresentation) {
817
+ MutexAutoLock lock (mMutex );
818
+ return GetRepresentation (aRepresentation).HasUpdate ();
819
+ }
820
+
808
821
CALayer* NativeLayerCA::UnderlyingCALayer (WhichRepresentation aRepresentation) {
809
822
MutexAutoLock lock (mMutex );
810
823
return GetRepresentation (aRepresentation).UnderlyingCALayer ();
@@ -961,6 +974,16 @@ bool DownscaleFrom(profiler_screenshots::RenderSource* aSource, const IntRect& a
961
974
mMutatedSamplingFilter = false ;
962
975
}
963
976
977
+ bool NativeLayerCA::Representation::HasUpdate () {
978
+ if (!mWrappingCALayer ) {
979
+ return true ;
980
+ }
981
+
982
+ return mMutatedPosition || mMutatedTransform || mMutatedDisplayRect || mMutatedClipRect ||
983
+ mMutatedBackingScale || mMutatedSize || mMutatedSurfaceIsFlipped || mMutatedFrontSurface ||
984
+ mMutatedSamplingFilter ;
985
+ }
986
+
964
987
// Called when mMutex is already being held by the current thread.
965
988
Maybe<NativeLayerCA::SurfaceWithInvalidRegion> NativeLayerCA::GetUnusedSurfaceAndCleanUp (
966
989
const MutexAutoLock&) {
0 commit comments