Skip to content

Commit

Permalink
[GTK] Do not keep processing frames while the view is unrealized when…
Browse files Browse the repository at this point in the history
… using DMA-BUF renderer

https://bugs.webkit.org/show_bug.cgi?id=260146

Reviewed by Michael Catanzaro.

This is what the wpe renderer does, we don't send the frame done message
until the view is realized.

* Source/WebKit/UIProcess/gtk/AcceleratedBackingStoreDMABuf.cpp:
(WebKit::AcceleratedBackingStoreDMABuf::frame):
(WebKit::AcceleratedBackingStoreDMABuf::realize):
(WebKit::AcceleratedBackingStoreDMABuf::update):
(WebKit::AcceleratedBackingStoreDMABuf::snapshot):
(WebKit::AcceleratedBackingStoreDMABuf::paint):

Canonical link: https://commits.webkit.org/266911@main
  • Loading branch information
carlosgcampos committed Aug 15, 2023
1 parent 1bce7e5 commit 811d01d
Showing 1 changed file with 11 additions and 16 deletions.
27 changes: 11 additions & 16 deletions Source/WebKit/UIProcess/gtk/AcceleratedBackingStoreDMABuf.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -443,12 +443,6 @@ void AcceleratedBackingStoreDMABuf::frame()
if (m_committedSource) {
m_committedSource->frame();
gtk_widget_queue_draw(m_webPage.viewWidget());
} else {
if (m_isSoftwareRast)
std::swap(m_surface.frontBitmap, m_surface.displayBitmap);
else
std::swap(m_surface.frontFD, m_surface.displayFD);
frameDone();
}
}

Expand Down Expand Up @@ -479,7 +473,7 @@ void AcceleratedBackingStoreDMABuf::realize()
return;

m_committedSource = createSource();
if (m_committedSource->prepareForRendering())
if (m_frameCompletionHandler || m_committedSource->prepareForRendering())
gtk_widget_queue_draw(m_webPage.viewWidget());
}

Expand Down Expand Up @@ -533,7 +527,10 @@ void AcceleratedBackingStoreDMABuf::update(const LayerTreeContext& context)
return;

if (m_surface.id) {
frameDone();
if (m_frameCompletionHandler) {
willDisplayFrame();
frameDone();
}
m_webPage.process().removeMessageReceiver(Messages::AcceleratedBackingStoreDMABuf::messageReceiverName(), m_surface.id);
}

Expand All @@ -545,29 +542,27 @@ void AcceleratedBackingStoreDMABuf::update(const LayerTreeContext& context)
#if USE(GTK4)
void AcceleratedBackingStoreDMABuf::snapshot(GtkSnapshot* gtkSnapshot)
{
if (m_frameCompletionHandler)
willDisplayFrame();

if (!m_committedSource)
return;

if (m_frameCompletionHandler)
if (m_frameCompletionHandler) {
willDisplayFrame();
m_committedSource->prepareForRendering();
}

m_committedSource->snapshot(gtkSnapshot);
frameDone();
}
#else
bool AcceleratedBackingStoreDMABuf::paint(cairo_t* cr, const WebCore::IntRect& clipRect)
{
if (m_frameCompletionHandler)
willDisplayFrame();

if (!m_committedSource)
return false;

if (m_frameCompletionHandler)
if (m_frameCompletionHandler) {
willDisplayFrame();
m_committedSource->prepareForRendering();
}

m_committedSource->paint(m_webPage.viewWidget(), cr, clipRect);
frameDone();
Expand Down

0 comments on commit 811d01d

Please sign in to comment.