@@ -1297,7 +1297,19 @@ private void AdvanceAnimations(long? timestamp = null)
12971297 var visual = _animatedVisuals [ i ] ;
12981298 if ( now >= visual . NextAnimationTick )
12991299 {
1300- changed |= visual . AdvanceAnimation ( now ) ;
1300+ var visualChanged = visual . AdvanceAnimation ( now ) ;
1301+ changed |= visualChanged ;
1302+ if ( visualChanged )
1303+ {
1304+ if ( visual is Visual renderVisual )
1305+ {
1306+ AddRenderDirtyRect ( renderVisual ) ;
1307+ }
1308+ else
1309+ {
1310+ _pendingRenderDirtyRectValid = false ;
1311+ }
1312+ }
13011313 }
13021314
13031315 next = Math . Min ( next , visual . NextAnimationTick ) ;
@@ -1413,27 +1425,7 @@ private void ProcessBindingWrites()
14131425 {
14141426 foreach ( var v in renderVisuals )
14151427 {
1416- var bounds = v . Bounds ;
1417- if ( bounds . Width <= 0 || bounds . Height <= 0 )
1418- {
1419- continue ;
1420- }
1421-
1422- // Expand by 1 cell horizontally to reduce artifacts with wide glyphs clipped at region boundaries.
1423- var x = Math . Max ( 0 , bounds . X - 1 ) ;
1424- var right = Math . Min ( LayoutConstants . MaxFinite , bounds . Right + 1 ) ;
1425- var expanded = new Rectangle ( x , bounds . Y , Math . Max ( 0 , right - x ) , bounds . Height ) ;
1426- metrics ? . AddDirtyRect ( expanded ) ;
1427-
1428- if ( ! _pendingRenderDirtyRectValid )
1429- {
1430- _pendingRenderDirtyRect = expanded ;
1431- _pendingRenderDirtyRectValid = true ;
1432- }
1433- else
1434- {
1435- _pendingRenderDirtyRect = Rectangle . Union ( _pendingRenderDirtyRect , expanded ) ;
1436- }
1428+ AddRenderDirtyRect ( v ) ;
14371429 }
14381430 }
14391431 }
@@ -1442,6 +1434,32 @@ private void ProcessBindingWrites()
14421434 _renderRequested = true ;
14431435 }
14441436
1437+ private void AddRenderDirtyRect ( Visual visual )
1438+ {
1439+ var bounds = visual . Bounds ;
1440+ if ( bounds . Width <= 0 || bounds . Height <= 0 )
1441+ {
1442+ return ;
1443+ }
1444+
1445+ // Expand by 1 cell horizontally to reduce artifacts with wide glyphs clipped at region boundaries.
1446+ var x = Math . Max ( 0 , bounds . X - 1 ) ;
1447+ var right = Math . Min ( LayoutConstants . MaxFinite , bounds . Right + 1 ) ;
1448+ var expanded = new Rectangle ( x , bounds . Y , Math . Max ( 0 , right - x ) , bounds . Height ) ;
1449+
1450+ _debugOverlayMetrics ? . AddDirtyRect ( expanded ) ;
1451+
1452+ if ( ! _pendingRenderDirtyRectValid )
1453+ {
1454+ _pendingRenderDirtyRect = expanded ;
1455+ _pendingRenderDirtyRectValid = true ;
1456+ }
1457+ else
1458+ {
1459+ _pendingRenderDirtyRect = Rectangle . Union ( _pendingRenderDirtyRect , expanded ) ;
1460+ }
1461+ }
1462+
14451463 private void Render ( )
14461464 {
14471465 EnsureFocusInScope ( ) ;
0 commit comments