@@ -864,6 +864,10 @@ void CoordinatedGraphicsLayer::flushCompositingStateForThisLayerOnly()
864864
865865 // Determine the backing store presence. Content is painted later, in the updateContentBuffers() traversal.
866866 if (shouldHaveBackingStore ()) {
867+ // The layer has a backingStore. Check whether we need to apply a concrete scale factor to it
868+ // because of some animation or transformation. If we don't do this, the backingStore will always
869+ // have a factor of 1, which will produce blurry results when the layer is scaled up.
870+ updateAnimationOrTransformScaleFactor ();
867871 if (!m_nicosia.backingStore ) {
868872 m_nicosia.backingStore = Nicosia::BackingStore::create ();
869873 m_nicosia.delta .backingStoreChanged = true ;
@@ -1076,7 +1080,7 @@ void CoordinatedGraphicsLayer::deviceOrPageScaleFactorChanged()
10761080
10771081float CoordinatedGraphicsLayer::effectiveContentsScale ()
10781082{
1079- return selfOrAncestorHaveNonAffineTransforms () ? 1 : deviceScaleFactor () * pageScaleFactor ();
1083+ return selfOrAncestorHaveNonAffineTransforms () ? 1 : deviceScaleFactor () * pageScaleFactor () * m_animationOrTransformScaleFactor ;
10801084}
10811085
10821086IntRect CoordinatedGraphicsLayer::transformedVisibleRect ()
@@ -1436,6 +1440,12 @@ bool CoordinatedGraphicsLayer::addAnimation(const KeyframeValueList& valueList,
14361440 m_animations.add (Nicosia::Animation (keyframesName, valueList, boxSize, *anim, m_lastAnimationStartTime, 0_s, Nicosia::Animation::AnimationState::Playing));
14371441 m_animationStartedTimer.startOneShot (0_s);
14381442 didChangeAnimations ();
1443+
1444+ // If the animation is of type AnimatedProperty::Transform, it may be a scale animation. Check whether
1445+ // we need to update the scale factor due to a new scale animation being added.
1446+ if (valueList.property () == AnimatedProperty::Transform)
1447+ updateAnimationScaleFactor ();
1448+
14391449 return true ;
14401450}
14411451
@@ -1449,6 +1459,9 @@ void CoordinatedGraphicsLayer::removeAnimation(const String& animationName, std:
14491459{
14501460 m_animations.remove (animationName);
14511461 didChangeAnimations ();
1462+ // An animation has been removed, and it could be a scale animation, so check whether
1463+ // we need to update the animation scale factor.
1464+ updateAnimationScaleFactor ();
14521465}
14531466
14541467void CoordinatedGraphicsLayer::suspendAnimations (MonotonicTime time)
@@ -1491,6 +1504,34 @@ PlatformLayer* CoordinatedGraphicsLayer::platformLayer() const
14911504}
14921505#endif
14931506
1507+ void CoordinatedGraphicsLayer::updateAnimationScaleFactor ()
1508+ {
1509+ m_animationScaleFactor = m_animations.maximumScaleFactor ();
1510+ }
1511+
1512+ void CoordinatedGraphicsLayer::updateAnimationOrTransformScaleFactor ()
1513+ {
1514+ TransformationMatrix::Decomposed2Type decomposed2;
1515+
1516+ float parentScale = 1.0 ;
1517+ if (parent ()) {
1518+ if (!downcast<CoordinatedGraphicsLayer>(*parent ()).m_layerTransform .combinedForChildren ().decompose2 (decomposed2))
1519+ return ;
1520+ parentScale = std::max (decomposed2.scaleX , decomposed2.scaleY );
1521+ }
1522+
1523+ if (!transform ().decompose2 (decomposed2))
1524+ return ;
1525+ float localScale = std::max (decomposed2.scaleX , decomposed2.scaleY );
1526+
1527+ float newScale = parentScale * std::max (m_animationScaleFactor, localScale);
1528+
1529+ if (newScale != m_animationOrTransformScaleFactor) {
1530+ m_animationOrTransformScaleFactor = newScale;
1531+ m_pendingContentsScaleAdjustment = true ;
1532+ }
1533+ }
1534+
14941535static void dumpInnerLayer (TextStream& textStream, const String& label, CoordinatedGraphicsLayer* layer, OptionSet<LayerTreeAsTextOptions> options)
14951536{
14961537 if (!layer)
0 commit comments