Skip to content

Commit f0b98a4

Browse files
authored
Merge pull request #1411 from WebPlatformForEmbedded/pgorszkowski/2.38/fix_issue_1379
[WPE][GTK] visible rect in case animations is not correctly calculated
2 parents 22b825d + 0213783 commit f0b98a4

File tree

2 files changed

+33
-2
lines changed

2 files changed

+33
-2
lines changed

Source/WebCore/platform/graphics/texmap/coordinated/CoordinatedGraphicsLayer.cpp

+30-2
Original file line numberDiff line numberDiff line change
@@ -1113,6 +1113,18 @@ IntRect CoordinatedGraphicsLayer::transformedVisibleRect()
11131113
return enclosingIntRect(rect);
11141114
}
11151115

1116+
IntRect CoordinatedGraphicsLayer::transformedVisibleRectIncludingFuture()
1117+
{
1118+
auto visibleRectIncludingFuture = transformedVisibleRect();
1119+
if (m_cachedInverseTransform != m_cachedFutureInverseTransform) {
1120+
FloatRect rect = m_cachedFutureInverseTransform.clampedBoundsOfProjectedQuad(FloatQuad(m_coordinator->visibleContentsRect()));
1121+
clampToContentsRectIfRectIsInfinite(rect, size());
1122+
visibleRectIncludingFuture.unite(enclosingIntRect(rect));
1123+
}
1124+
1125+
return visibleRectIncludingFuture;
1126+
}
1127+
11161128
void CoordinatedGraphicsLayer::requestBackingStoreUpdate()
11171129
{
11181130
setNeedsVisibleRectAdjustment();
@@ -1185,7 +1197,7 @@ void CoordinatedGraphicsLayer::updateContentBuffers()
11851197

11861198
if (m_pendingVisibleRectAdjustment) {
11871199
m_pendingVisibleRectAdjustment = false;
1188-
layerState.mainBackingStore->createTilesIfNeeded(transformedVisibleRect(), IntRect(0, 0, m_size.width(), m_size.height()));
1200+
layerState.mainBackingStore->createTilesIfNeeded(transformedVisibleRectIncludingFuture(), IntRect(0, 0, m_size.width(), m_size.height()));
11891201
}
11901202

11911203
if (is<CoordinatedAnimatedBackingStoreClient>(m_nicosia.animatedBackingStoreClient)) {
@@ -1375,8 +1387,13 @@ void CoordinatedGraphicsLayer::computeTransformedVisibleRect()
13751387

13761388
m_shouldUpdateVisibleRect = false;
13771389
TransformationMatrix currentTransform = transform();
1378-
if (m_movingVisibleRect)
1390+
TransformationMatrix futureTransform = currentTransform;
1391+
if (m_movingVisibleRect) {
13791392
client().getCurrentTransform(this, currentTransform);
1393+
Nicosia::Animation::ApplicationResult futureApplicationResults;
1394+
m_animations.applyKeepingInternalState(futureApplicationResults, MonotonicTime::now() + 300_ms);
1395+
futureTransform = futureApplicationResults.transform.value_or(currentTransform);
1396+
}
13801397
m_layerTransform.setLocalTransform(currentTransform);
13811398

13821399
m_layerTransform.setAnchorPoint(m_adjustedAnchorPoint);
@@ -1389,6 +1406,17 @@ void CoordinatedGraphicsLayer::computeTransformedVisibleRect()
13891406

13901407
m_cachedInverseTransform = m_layerTransform.combined().inverse().value_or(TransformationMatrix());
13911408

1409+
m_layerFutureTransform = m_layerTransform;
1410+
m_cachedFutureInverseTransform = m_cachedInverseTransform;
1411+
1412+
CoordinatedGraphicsLayer* parentLayer = downcast<CoordinatedGraphicsLayer>(parent());
1413+
1414+
if (currentTransform != futureTransform || (parentLayer && parentLayer->m_layerTransform.combinedForChildren() != parentLayer->m_layerFutureTransform.combinedForChildren())) {
1415+
m_layerFutureTransform.setLocalTransform(futureTransform);
1416+
m_layerFutureTransform.combineTransforms(parentLayer ? parentLayer->m_layerFutureTransform.combinedForChildren() : TransformationMatrix());
1417+
m_cachedFutureInverseTransform = m_layerFutureTransform.combined().inverse().value_or(TransformationMatrix());
1418+
}
1419+
13921420
// The combined transform will be used in tiledBackingStoreVisibleRect.
13931421
setNeedsVisibleRectAdjustment();
13941422
}

Source/WebCore/platform/graphics/texmap/coordinated/CoordinatedGraphicsLayer.h

+3
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,7 @@ class WEBCORE_EXPORT CoordinatedGraphicsLayer : public GraphicsLayer {
134134
void computePixelAlignment(FloatPoint& position, FloatSize&, FloatPoint3D& anchorPoint, FloatSize& alignmentOffset);
135135

136136
IntRect transformedVisibleRect();
137+
IntRect transformedVisibleRectIncludingFuture();
137138

138139
void invalidateCoordinator();
139140
void setCoordinatorIncludingSubLayersIfNeeded(CoordinatedGraphicsLayerClient*);
@@ -211,7 +212,9 @@ class WEBCORE_EXPORT CoordinatedGraphicsLayer : public GraphicsLayer {
211212

212213
Nicosia::PlatformLayer::LayerID m_id;
213214
GraphicsLayerTransform m_layerTransform;
215+
GraphicsLayerTransform m_layerFutureTransform;
214216
TransformationMatrix m_cachedInverseTransform;
217+
TransformationMatrix m_cachedFutureInverseTransform;
215218
FloatSize m_pixelAlignmentOffset;
216219
FloatSize m_adjustedSize;
217220
FloatPoint m_adjustedPosition;

0 commit comments

Comments
 (0)