@@ -860,6 +860,10 @@ void CoordinatedGraphicsLayer::flushCompositingStateForThisLayerOnly()
860860
861861 // Determine the backing store presence. Content is painted later, in the updateContentBuffers() traversal.
862862 if (shouldHaveBackingStore ()) {
863+ // The layer has a backingStore. Check whether we need to apply a concrete scale factor to it
864+ // because of some animation or transformation. If we don't do this, the backingStore will always
865+ // have a factor of 1, which will produce blurry results when the layer is scaled up.
866+ updateAnimationOrTransformScaleFactor ();
863867 if (!m_nicosia.backingStore ) {
864868 m_nicosia.backingStore = Nicosia::BackingStore::create ();
865869 m_nicosia.delta .backingStoreChanged = true ;
@@ -1077,7 +1081,7 @@ void CoordinatedGraphicsLayer::deviceOrPageScaleFactorChanged()
10771081
10781082float CoordinatedGraphicsLayer::effectiveContentsScale ()
10791083{
1080- return selfOrAncestorHaveNonAffineTransforms () ? 1 : deviceScaleFactor () * pageScaleFactor ();
1084+ return selfOrAncestorHaveNonAffineTransforms () ? 1 : deviceScaleFactor () * pageScaleFactor () * m_animationOrTransformScaleFactor ;
10811085}
10821086
10831087IntRect CoordinatedGraphicsLayer::transformedVisibleRect ()
@@ -1437,6 +1441,12 @@ bool CoordinatedGraphicsLayer::addAnimation(const KeyframeValueList& valueList,
14371441 m_animations.add (Nicosia::Animation (keyframesName, valueList, boxSize, *anim, m_lastAnimationStartTime, 0_s, Nicosia::Animation::AnimationState::Playing));
14381442 m_animationStartedTimer.startOneShot (0_s);
14391443 didChangeAnimations ();
1444+
1445+ // If the animation is of type AnimatedProperty::Transform, it may be a scale animation. Check whether
1446+ // we need to update the scale factor due to a new scale animation being added.
1447+ if (valueList.property () == AnimatedProperty::Transform)
1448+ updateAnimationScaleFactor ();
1449+
14401450 return true ;
14411451}
14421452
@@ -1450,6 +1460,9 @@ void CoordinatedGraphicsLayer::removeAnimation(const String& animationName, std:
14501460{
14511461 m_animations.remove (animationName);
14521462 didChangeAnimations ();
1463+ // An animation has been removed, and it could be a scale animation, so check whether
1464+ // we need to update the animation scale factor.
1465+ updateAnimationScaleFactor ();
14531466}
14541467
14551468void CoordinatedGraphicsLayer::suspendAnimations (MonotonicTime time)
@@ -1492,6 +1505,34 @@ PlatformLayer* CoordinatedGraphicsLayer::platformLayer() const
14921505}
14931506#endif
14941507
1508+ void CoordinatedGraphicsLayer::updateAnimationScaleFactor ()
1509+ {
1510+ m_animationScaleFactor = m_animations.maximumScaleFactor ();
1511+ }
1512+
1513+ void CoordinatedGraphicsLayer::updateAnimationOrTransformScaleFactor ()
1514+ {
1515+ TransformationMatrix::Decomposed2Type decomposed2;
1516+
1517+ float parentScale = 1.0 ;
1518+ if (parent ()) {
1519+ if (!downcast<CoordinatedGraphicsLayer>(*parent ()).m_layerTransform .combinedForChildren ().decompose2 (decomposed2))
1520+ return ;
1521+ parentScale = std::max (decomposed2.scaleX , decomposed2.scaleY );
1522+ }
1523+
1524+ if (!transform ().decompose2 (decomposed2))
1525+ return ;
1526+ float localScale = std::max (decomposed2.scaleX , decomposed2.scaleY );
1527+
1528+ float newScale = parentScale * std::max (m_animationScaleFactor, localScale);
1529+
1530+ if (newScale != m_animationOrTransformScaleFactor) {
1531+ m_animationOrTransformScaleFactor = newScale;
1532+ m_pendingContentsScaleAdjustment = true ;
1533+ }
1534+ }
1535+
14951536static void dumpInnerLayer (TextStream& textStream, const String& label, CoordinatedGraphicsLayer* layer, OptionSet<LayerTreeAsTextOptions> options)
14961537{
14971538 if (!layer)
0 commit comments