Skip to content

Commit c898f59

Browse files
committed
[GTK][WPE][Coordinated Graphics] The combination of damage tracking and async scrolling causes flickering
https://bugs.webkit.org/show_bug.cgi?id=305441 Reviewed by Carlos Garcia Campos. The damage tracking tracks the area that is actually drawn, and updates only the painted area. If async scrolling scrolled to the area no tiles were covered while the main thread was busy, new tiles would be created and drawn after the main thread was unblocked. However, the area was not recorded as the damage area. Changed CoordinatedPlatformLayer::updateBackingStore() to collect the area where new tiles are created, and add to the damage area. Co-authored-by: Pawel Lampe <plampe@igalia.com> * Source/WebCore/platform/graphics/texmap/coordinated/CoordinatedBackingStoreProxy.cpp: (WebCore::CoordinatedBackingStoreProxy::updateIfNeeded): (WebCore::CoordinatedBackingStoreProxy::createOrDestroyTiles): * Source/WebCore/platform/graphics/texmap/coordinated/CoordinatedBackingStoreProxy.h: * Source/WebCore/platform/graphics/texmap/coordinated/CoordinatedPlatformLayer.cpp: (WebCore::CoordinatedPlatformLayer::updateBackingStore): Canonical link: https://commits.webkit.org/306987@main
1 parent 7c66118 commit c898f59

File tree

3 files changed

+18
-6
lines changed

3 files changed

+18
-6
lines changed

‎Source/WebCore/platform/graphics/texmap/coordinated/CoordinatedBackingStoreProxy.cpp‎

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -97,12 +97,12 @@ Ref<CoordinatedBackingStoreProxy> CoordinatedBackingStoreProxy::create()
9797
return adoptRef(*new CoordinatedBackingStoreProxy());
9898
}
9999

100-
OptionSet<CoordinatedBackingStoreProxy::UpdateResult> CoordinatedBackingStoreProxy::updateIfNeeded(const IntRect& unscaledVisibleRect, const IntRect& unscaledContentsRect, float contentsScale, bool shouldCreateAndDestroyTiles, const Vector<IntRect, 1>& dirtyRegion, CoordinatedPlatformLayer& layer)
100+
OptionSet<CoordinatedBackingStoreProxy::UpdateResult> CoordinatedBackingStoreProxy::updateIfNeeded(const IntRect& unscaledVisibleRect, const IntRect& unscaledContentsRect, float contentsScale, bool shouldCreateAndDestroyTiles, const Vector<IntRect, 1>& dirtyRegion, Damage& damage, CoordinatedPlatformLayer& layer)
101101
{
102102
Vector<uint32_t> tilesToCreate;
103103
Vector<uint32_t> tilesToRemove;
104104
if (shouldCreateAndDestroyTiles)
105-
createOrDestroyTiles(unscaledVisibleRect, unscaledContentsRect, enclosingIntRect(layer.visibleRect()).size(), contentsScale, layer.maxTextureSize(), tilesToCreate, tilesToRemove);
105+
createOrDestroyTiles(unscaledVisibleRect, unscaledContentsRect, enclosingIntRect(layer.visibleRect()).size(), contentsScale, layer.maxTextureSize(), damage, tilesToCreate, tilesToRemove);
106106

107107
if (!m_tiles.isEmpty())
108108
invalidateRegion(dirtyRegion);
@@ -201,7 +201,7 @@ void CoordinatedBackingStoreProxy::invalidateRegion(const Vector<IntRect, 1>& di
201201
}
202202
}
203203

204-
void CoordinatedBackingStoreProxy::createOrDestroyTiles(const IntRect& unscaledVisibleRect, const IntRect& unscaledContentsRect, const IntSize& unscaledViewportSize, float contentsScale, int maxTextureSize, Vector<uint32_t>& tilesToCreate, Vector<uint32_t>& tilesToRemove)
204+
void CoordinatedBackingStoreProxy::createOrDestroyTiles(const IntRect& unscaledVisibleRect, const IntRect& unscaledContentsRect, const IntSize& unscaledViewportSize, float contentsScale, int maxTextureSize, Damage& damage, Vector<uint32_t>& tilesToCreate, Vector<uint32_t>& tilesToRemove)
205205
{
206206
float coverAreaMultiplier = MemoryPressureHandler::singleton().isUnderMemoryPressure() ? 1.0f : 2.0f;
207207
bool contentsScaleChanged = m_contentsScale != contentsScale;
@@ -332,6 +332,13 @@ void CoordinatedBackingStoreProxy::createOrDestroyTiles(const IntRect& unscaledV
332332

333333
for (const auto& position : tilePositionsToCreate) {
334334
auto tile = Tile(generateTileID(), position, tileRectForPosition(position));
335+
#if ENABLE(DAMAGE_TRACKING)
336+
IntRect unscaledDirtyRect = tile.dirtyRect;
337+
unscaledDirtyRect.scale(1 / contentsScale);
338+
damage.add(unscaledDirtyRect);
339+
#else
340+
UNUSED_PARAM(damage);
341+
#endif
335342
tilesToCreate.append(tile.id);
336343
m_tiles.add(position, WTF::move(tile));
337344
}

‎Source/WebCore/platform/graphics/texmap/coordinated/CoordinatedBackingStoreProxy.h‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
namespace WebCore {
3434
class CoordinatedPlatformLayer;
3535
class CoordinatedTileBuffer;
36+
class Damage;
3637
class GraphicsLayer;
3738

3839
class CoordinatedBackingStoreProxy final : public ThreadSafeRefCounted<CoordinatedBackingStoreProxy> {
@@ -78,7 +79,7 @@ class CoordinatedBackingStoreProxy final : public ThreadSafeRefCounted<Coordinat
7879
TilesPending = 1 << 1,
7980
TilesChanged = 1 << 2
8081
};
81-
OptionSet<UpdateResult> updateIfNeeded(const IntRect& unscaledVisibleRect, const IntRect& unscaledContentsRect, float contentsScale, bool shouldCreateAndDestroyTiles, const Vector<IntRect, 1>&, CoordinatedPlatformLayer&);
82+
OptionSet<UpdateResult> updateIfNeeded(const IntRect& unscaledVisibleRect, const IntRect& unscaledContentsRect, float contentsScale, bool shouldCreateAndDestroyTiles, const Vector<IntRect, 1>&, Damage&, CoordinatedPlatformLayer&);
8283
Update takePendingUpdate();
8384

8485
void waitUntilPaintingComplete();
@@ -130,7 +131,7 @@ class CoordinatedBackingStoreProxy final : public ThreadSafeRefCounted<Coordinat
130131
CoordinatedBackingStoreProxy() = default;
131132

132133
void invalidateRegion(const Vector<IntRect, 1>&);
133-
void createOrDestroyTiles(const IntRect& unscaledVisibleRect, const IntRect& unscaledContentsRect, const IntSize& unscaledViewportSize, float contentsScale, int maxTextureSize, Vector<uint32_t>& tilesToCreate, Vector<uint32_t>& tilesToRemove);
134+
void createOrDestroyTiles(const IntRect& unscaledVisibleRect, const IntRect& unscaledContentsRect, const IntSize& unscaledViewportSize, float contentsScale, int maxTextureSize, Damage&, Vector<uint32_t>& tilesToCreate, Vector<uint32_t>& tilesToRemove);
134135
IntSize computeTileSize(const IntSize& viewportSize, int maxTextureSize) const;
135136
std::pair<IntRect, IntRect> computeCoverAndKeepRect() const;
136137
void adjustForContentsRect(IntRect&) const;

‎Source/WebCore/platform/graphics/texmap/coordinated/CoordinatedPlatformLayer.cpp‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -749,9 +749,13 @@ void CoordinatedPlatformLayer::updateBackingStore()
749749
if (m_dirtyRegion.isEmpty() && !m_pendingTilesCreation && !m_needsTilesUpdate)
750750
return;
751751

752+
Damage damage(m_size, Damage::Mode::Rectangles);
752753
IntRect contentsRect(IntPoint::zero(), IntSize(m_size));
753-
auto updateResult = m_backingStoreProxy->updateIfNeeded(m_transformedVisibleRectIncludingFuture, contentsRect, m_contentsScale, m_pendingTilesCreation || m_needsTilesUpdate, m_dirtyRegion, *this);
754+
auto updateResult = m_backingStoreProxy->updateIfNeeded(m_transformedVisibleRectIncludingFuture, contentsRect, m_contentsScale, m_pendingTilesCreation || m_needsTilesUpdate, m_dirtyRegion, damage, *this);
754755
m_needsTilesUpdate = false;
756+
#if ENABLE(DAMAGE_TRACKING)
757+
addDamage(WTF::move(damage));
758+
#endif
755759
m_dirtyRegion.clear();
756760
if (m_animatedBackingStoreClient)
757761
m_animatedBackingStoreClient->update(m_visibleRect, m_backingStoreProxy->coverRect(), m_size, m_contentsScale);

0 commit comments

Comments
 (0)