Skip to content

Commit 825a7cc

Browse files
committed
[GTK] Remove the code to keep previous layer tree host alive
https://bugs.webkit.org/show_bug.cgi?id=261672 Reviewed by Alejandro G. Castro. This was used for the ondemand mode when we allowed to exit accelerated compositing mode, but now we force always compositing the first time we enter accelerated compositing mode. The only way to exit accelerated compositing is by setting the policy to never, in which case we don't want to keep the previous layer tree host since it's unlikely we enter it again soon. * Source/WebKit/WebProcess/WebPage/CoordinatedGraphics/DrawingAreaCoordinatedGraphics.cpp: (WebKit::DrawingAreaCoordinatedGraphics::DrawingAreaCoordinatedGraphics): (WebKit::DrawingAreaCoordinatedGraphics::scroll): (WebKit::DrawingAreaCoordinatedGraphics::mainFrameContentSizeChanged): (WebKit::DrawingAreaCoordinatedGraphics::deviceOrPageScaleFactorChanged): (WebKit::DrawingAreaCoordinatedGraphics::didChangeViewportAttributes): (WebKit::DrawingAreaCoordinatedGraphics::attachViewOverlayGraphicsLayer): (WebKit::DrawingAreaCoordinatedGraphics::updateGeometry): (WebKit::DrawingAreaCoordinatedGraphics::enterAcceleratedCompositingMode): (WebKit::DrawingAreaCoordinatedGraphics::exitAcceleratedCompositingMode): (WebKit::DrawingAreaCoordinatedGraphics::discardPreviousLayerTreeHost): Deleted. * Source/WebKit/WebProcess/WebPage/CoordinatedGraphics/DrawingAreaCoordinatedGraphics.h: * Source/WebKit/WebProcess/WebPage/CoordinatedGraphics/LayerTreeHost.cpp: (WebKit::LayerTreeHost::scrollNonCompositedContents): (WebKit::LayerTreeHost::sizeDidChange): (WebKit::LayerTreeHost::contentsSizeChanged): (WebKit::LayerTreeHost::didChangeViewportAttributes): (WebKit::LayerTreeHost::deviceOrPageScaleFactorChanged): (WebKit::LayerTreeHost::setIsDiscardable): Deleted. * Source/WebKit/WebProcess/WebPage/CoordinatedGraphics/LayerTreeHost.h: (WebKit::LayerTreeHost::didChangeViewportAttributes): (WebKit::LayerTreeHost::setIsDiscardable): Deleted. Canonical link: https://commits.webkit.org/269463@main
1 parent e20b694 commit 825a7cc

File tree

4 files changed

+16
-112
lines changed

4 files changed

+16
-112
lines changed

Source/WebKit/WebProcess/WebPage/CoordinatedGraphics/DrawingAreaCoordinatedGraphics.cpp

Lines changed: 13 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -59,14 +59,10 @@ DrawingAreaCoordinatedGraphics::DrawingAreaCoordinatedGraphics(WebPage& webPage,
5959
: DrawingArea(DrawingAreaType::CoordinatedGraphics, parameters.drawingAreaIdentifier, webPage)
6060
, m_isPaintingSuspended(!(parameters.activityState & ActivityState::IsVisible))
6161
, m_exitCompositingTimer(RunLoop::main(), this, &DrawingAreaCoordinatedGraphics::exitAcceleratedCompositingMode)
62-
, m_discardPreviousLayerTreeHostTimer(RunLoop::main(), this, &DrawingAreaCoordinatedGraphics::discardPreviousLayerTreeHost)
6362
, m_displayTimer(RunLoop::main(), this, &DrawingAreaCoordinatedGraphics::displayTimerFired)
6463
{
65-
#if USE(GLIB_EVENT_LOOP)
66-
m_discardPreviousLayerTreeHostTimer.setPriority(RunLoopSourcePriority::ReleaseUnusedResourcesTimer);
67-
#if !PLATFORM(WPE)
64+
#if USE(GLIB_EVENT_LOOP) && !PLATFORM(WPE)
6865
m_displayTimer.setPriority(RunLoopSourcePriority::NonAcceleratedDrawingTimer);
69-
#endif
7066
#endif
7167

7268
updatePreferences(parameters.store);
@@ -116,9 +112,6 @@ void DrawingAreaCoordinatedGraphics::scroll(const IntRect& scrollRect, const Int
116112
if (scrollRect.isEmpty())
117113
return;
118114

119-
if (m_previousLayerTreeHost)
120-
m_previousLayerTreeHost->scrollNonCompositedContents(scrollRect);
121-
122115
if (!m_scrollRect.isEmpty() && scrollRect != m_scrollRect) {
123116
unsigned scrollArea = scrollRect.width() * scrollRect.height();
124117
unsigned currentScrollArea = m_scrollRect.width() * m_scrollRect.height();
@@ -264,25 +257,19 @@ void DrawingAreaCoordinatedGraphics::mainFrameContentSizeChanged(WebCore::FrameI
264257
{
265258
if (m_layerTreeHost)
266259
m_layerTreeHost->contentsSizeChanged(size);
267-
else if (m_previousLayerTreeHost)
268-
m_previousLayerTreeHost->contentsSizeChanged(size);
269260
}
270261

271262
#if USE(COORDINATED_GRAPHICS) || USE(TEXTURE_MAPPER)
272263
void DrawingAreaCoordinatedGraphics::deviceOrPageScaleFactorChanged()
273264
{
274265
if (m_layerTreeHost)
275266
m_layerTreeHost->deviceOrPageScaleFactorChanged();
276-
else if (m_previousLayerTreeHost)
277-
m_previousLayerTreeHost->deviceOrPageScaleFactorChanged();
278267
}
279268

280269
void DrawingAreaCoordinatedGraphics::didChangeViewportAttributes(ViewportAttributes&& attrs)
281270
{
282271
if (m_layerTreeHost)
283272
m_layerTreeHost->didChangeViewportAttributes(WTFMove(attrs));
284-
else if (m_previousLayerTreeHost)
285-
m_previousLayerTreeHost->didChangeViewportAttributes(WTFMove(attrs));
286273
}
287274

288275
bool DrawingAreaCoordinatedGraphics::enterAcceleratedCompositingModeIfNeeded()
@@ -409,8 +396,6 @@ void DrawingAreaCoordinatedGraphics::attachViewOverlayGraphicsLayer(WebCore::Fra
409396
{
410397
if (m_layerTreeHost)
411398
m_layerTreeHost->setViewOverlayRootLayer(viewOverlayRootLayer);
412-
else if (m_previousLayerTreeHost)
413-
m_previousLayerTreeHost->setViewOverlayRootLayer(viewOverlayRootLayer);
414399
}
415400

416401
void DrawingAreaCoordinatedGraphics::updateGeometry(const IntSize& size, CompletionHandler<void()>&& completionHandler)
@@ -427,8 +412,7 @@ void DrawingAreaCoordinatedGraphics::updateGeometry(const IntSize& size, Complet
427412
if (m_layerTreeHost) {
428413
previousLayerTreeContext = m_layerTreeHost->layerTreeContext();
429414
m_layerTreeHost->sizeDidChange(webPage->size());
430-
} else if (m_previousLayerTreeHost)
431-
m_previousLayerTreeHost->sizeDidChange(m_webPage->size());
415+
}
432416

433417
if (m_layerTreeHost) {
434418
auto layerTreeContext = m_layerTreeHost->layerTreeContext();
@@ -522,12 +506,6 @@ void DrawingAreaCoordinatedGraphics::exitAcceleratedCompositingModeSoon()
522506
m_exitCompositingTimer.startOneShot(0_s);
523507
}
524508

525-
void DrawingAreaCoordinatedGraphics::discardPreviousLayerTreeHost()
526-
{
527-
m_discardPreviousLayerTreeHostTimer.stop();
528-
m_previousLayerTreeHost = nullptr;
529-
}
530-
531509
void DrawingAreaCoordinatedGraphics::suspendPainting()
532510
{
533511
ASSERT(!m_isPaintingSuspended);
@@ -569,7 +547,6 @@ void DrawingAreaCoordinatedGraphics::enterAcceleratedCompositingMode(GraphicsLay
569547
m_alwaysUseCompositing = true;
570548
}
571549
#endif
572-
m_discardPreviousLayerTreeHostTimer.stop();
573550

574551
m_exitCompositingTimer.stop();
575552
m_wantsToExitAcceleratedCompositingMode = false;
@@ -583,33 +560,22 @@ void DrawingAreaCoordinatedGraphics::enterAcceleratedCompositingMode(GraphicsLay
583560
#endif
584561

585562
ASSERT(!m_layerTreeHost);
586-
if (m_previousLayerTreeHost) {
587-
m_layerTreeHost = WTFMove(m_previousLayerTreeHost);
588-
#if !HAVE(DISPLAY_LINK)
589-
changeWindowScreen();
590-
#endif
591-
m_layerTreeHost->setIsDiscardable(false);
592-
m_layerTreeHost->resumeRendering();
593-
if (!m_layerTreeStateIsFrozen)
594-
m_layerTreeHost->setLayerFlushSchedulingEnabled(true);
595-
} else {
596563
#if USE(GRAPHICS_LAYER_TEXTURE_MAPPER) || HAVE(DISPLAY_LINK)
597-
m_layerTreeHost = makeUnique<LayerTreeHost>(m_webPage);
564+
m_layerTreeHost = makeUnique<LayerTreeHost>(m_webPage);
598565
#elif USE(COORDINATED_GRAPHICS)
599-
m_layerTreeHost = makeUnique<LayerTreeHost>(m_webPage, std::numeric_limits<uint32_t>::max() - m_identifier.toUInt64());
566+
m_layerTreeHost = makeUnique<LayerTreeHost>(m_webPage, std::numeric_limits<uint32_t>::max() - m_identifier.toUInt64());
600567
#else
601-
m_layerTreeHost = nullptr;
602-
return;
568+
m_layerTreeHost = nullptr;
569+
return;
603570
#endif
571+
604572
#if !HAVE(DISPLAY_LINK)
605-
changeWindowScreen();
573+
changeWindowScreen();
606574
#endif
607-
if (m_layerTreeStateIsFrozen)
608-
m_layerTreeHost->setLayerFlushSchedulingEnabled(false);
609-
if (m_isPaintingSuspended)
610-
m_layerTreeHost->pauseRendering();
611-
}
612-
575+
if (m_layerTreeStateIsFrozen)
576+
m_layerTreeHost->setLayerFlushSchedulingEnabled(false);
577+
if (m_isPaintingSuspended)
578+
m_layerTreeHost->pauseRendering();
613579
if (!m_inUpdateGeometry)
614580
m_layerTreeHost->setShouldNotifyAfterNextScheduledLayerFlush(true);
615581

@@ -651,11 +617,7 @@ void DrawingAreaCoordinatedGraphics::exitAcceleratedCompositingMode()
651617
m_wantsToExitAcceleratedCompositingMode = false;
652618

653619
ASSERT(m_layerTreeHost);
654-
m_previousLayerTreeHost = WTFMove(m_layerTreeHost);
655-
m_previousLayerTreeHost->setIsDiscardable(true);
656-
m_previousLayerTreeHost->pauseRendering();
657-
m_previousLayerTreeHost->setLayerFlushSchedulingEnabled(false);
658-
m_discardPreviousLayerTreeHostTimer.startOneShot(5_s);
620+
m_layerTreeHost = nullptr;
659621

660622
Ref webPage = m_webPage.get();
661623
#if !HAVE(DISPLAY_LINK)

Source/WebKit/WebProcess/WebPage/CoordinatedGraphics/DrawingAreaCoordinatedGraphics.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,6 @@ class DrawingAreaCoordinatedGraphics final : public DrawingArea {
9797

9898
void exitAcceleratedCompositingModeSoon();
9999
bool exitAcceleratedCompositingModePending() const { return m_exitCompositingTimer.isActive(); }
100-
void discardPreviousLayerTreeHost();
101100

102101
void suspendPainting();
103102
void resumePainting();
@@ -133,9 +132,6 @@ class DrawingAreaCoordinatedGraphics final : public DrawingArea {
133132
// The layer tree host that handles accelerated compositing.
134133
std::unique_ptr<LayerTreeHost> m_layerTreeHost;
135134

136-
std::unique_ptr<LayerTreeHost> m_previousLayerTreeHost;
137-
RunLoop::Timer m_discardPreviousLayerTreeHostTimer;
138-
139135
WebCore::Region m_dirtyRegion;
140136
WebCore::IntRect m_scrollRect;
141137
WebCore::IntSize m_scrollOffset;

Source/WebKit/WebProcess/WebPage/CoordinatedGraphics/LayerTreeHost.cpp

Lines changed: 3 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -213,10 +213,7 @@ void LayerTreeHost::scrollNonCompositedContents(const IntRect& rect)
213213
return;
214214

215215
m_viewportController.didScroll(rect.location());
216-
if (m_isDiscardable)
217-
m_discardableSyncActions.add(DiscardableSyncActions::UpdateViewport);
218-
else
219-
didChangeViewport();
216+
didChangeViewport();
220217
}
221218

222219
void LayerTreeHost::forceRepaint()
@@ -256,12 +253,6 @@ void LayerTreeHost::forceRepaintAsync(CompletionHandler<void()>&& callback)
256253

257254
void LayerTreeHost::sizeDidChange(const IntSize& size)
258255
{
259-
if (m_isDiscardable) {
260-
m_discardableSyncActions.add(DiscardableSyncActions::UpdateSize);
261-
m_viewportController.didChangeViewportSize(size);
262-
return;
263-
}
264-
265256
if (m_surface->hostResize(size))
266257
m_layerTreeContext.contextID = m_surface->surfaceID();
267258

@@ -296,19 +287,13 @@ GraphicsLayerFactory* LayerTreeHost::graphicsLayerFactory()
296287
void LayerTreeHost::contentsSizeChanged(const IntSize& newSize)
297288
{
298289
m_viewportController.didChangeContentsSize(newSize);
299-
if (m_isDiscardable)
300-
m_discardableSyncActions.add(DiscardableSyncActions::UpdateViewport);
301-
else
302-
didChangeViewport();
290+
didChangeViewport();
303291
}
304292

305293
void LayerTreeHost::didChangeViewportAttributes(ViewportAttributes&& attr)
306294
{
307295
m_viewportController.didChangeViewportAttributes(WTFMove(attr));
308-
if (m_isDiscardable)
309-
m_discardableSyncActions.add(DiscardableSyncActions::UpdateViewport);
310-
else
311-
didChangeViewport();
296+
didChangeViewport();
312297
}
313298

314299
void LayerTreeHost::didChangeViewport()
@@ -350,37 +335,8 @@ void LayerTreeHost::didChangeViewport()
350335
}
351336
}
352337

353-
void LayerTreeHost::setIsDiscardable(bool discardable)
354-
{
355-
m_isDiscardable = discardable;
356-
if (m_isDiscardable) {
357-
m_discardableSyncActions = OptionSet<DiscardableSyncActions>();
358-
return;
359-
}
360-
361-
if (m_discardableSyncActions.isEmpty())
362-
return;
363-
364-
if (m_discardableSyncActions.contains(DiscardableSyncActions::UpdateSize)) {
365-
// Size changes already sets the scale factor and updates the viewport.
366-
sizeDidChange(m_webPage.size());
367-
return;
368-
}
369-
370-
if (m_discardableSyncActions.contains(DiscardableSyncActions::UpdateScale))
371-
deviceOrPageScaleFactorChanged();
372-
373-
if (m_discardableSyncActions.contains(DiscardableSyncActions::UpdateViewport))
374-
didChangeViewport();
375-
}
376-
377338
void LayerTreeHost::deviceOrPageScaleFactorChanged()
378339
{
379-
if (m_isDiscardable) {
380-
m_discardableSyncActions.add(DiscardableSyncActions::UpdateScale);
381-
return;
382-
}
383-
384340
if (m_surface->hostResize(m_webPage.size()))
385341
m_layerTreeContext.contextID = m_surface->surfaceID();
386342

Source/WebKit/WebProcess/WebPage/CoordinatedGraphics/LayerTreeHost.h

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -100,8 +100,6 @@ class LayerTreeHost
100100
void contentsSizeChanged(const WebCore::IntSize&);
101101
void didChangeViewportAttributes(WebCore::ViewportAttributes&&);
102102

103-
void setIsDiscardable(bool);
104-
105103
void deviceOrPageScaleFactorChanged();
106104

107105
#if !HAVE(DISPLAY_LINK)
@@ -153,11 +151,6 @@ class LayerTreeHost
153151
void applyTransientZoomToLayers(double, WebCore::FloatPoint);
154152
#endif
155153

156-
enum class DiscardableSyncActions {
157-
UpdateSize = 1 << 1,
158-
UpdateViewport = 1 << 2,
159-
UpdateScale = 1 << 3
160-
};
161154
#endif // USE(COORDINATED_GRAPHICS)
162155

163156
WebPage& m_webPage;
@@ -170,8 +163,6 @@ class LayerTreeHost
170163
bool m_scheduledWhileWaitingForRenderer { false };
171164
float m_lastPageScaleFactor { 1 };
172165
WebCore::IntPoint m_lastScrollPosition;
173-
bool m_isDiscardable { false };
174-
OptionSet<DiscardableSyncActions> m_discardableSyncActions;
175166
WebCore::GraphicsLayer* m_viewOverlayRootLayer { nullptr };
176167
std::unique_ptr<AcceleratedSurface> m_surface;
177168
RefPtr<ThreadedCompositor> m_compositor;
@@ -219,7 +210,6 @@ inline void LayerTreeHost::resumeRendering() { }
219210
inline WebCore::GraphicsLayerFactory* LayerTreeHost::graphicsLayerFactory() { return nullptr; }
220211
inline void LayerTreeHost::contentsSizeChanged(const WebCore::IntSize&) { }
221212
inline void LayerTreeHost::didChangeViewportAttributes(WebCore::ViewportAttributes&&) { }
222-
inline void LayerTreeHost::setIsDiscardable(bool) { }
223213
inline void LayerTreeHost::deviceOrPageScaleFactorChanged() { }
224214
#if PLATFORM(GTK)
225215
inline void LayerTreeHost::adjustTransientZoom(double, WebCore::FloatPoint) { }

0 commit comments

Comments
 (0)