Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ws: Save and expose damage buffer information #184

Closed
wants to merge 1 commit into from

Conversation

lauromoura
Copy link

The wl_surface.damage_buffer request can be used by clients to inform that a given region (in buffer coordinates) is damaged. This request is used by eglSwapBuffersWithDamage[EXT|KHR], with one call for each rect.

For more info: https://wayland-book.com/surfaces-in-depth/damaging-surfaces.html

This commit stores this information and exposes it to exported EGL image clients.

It also bumps the nested compositor interface to version 4, which provides the damage_buffer support.

The wl_surface.damage_buffer request can be used by clients to inform
that a given region (in buffer coordinates) is damaged. This request is
used by eglSwapBuffersWithDamage[EXT|KHR], with one call for each rect.

For more info: https://wayland-book.com/surfaces-in-depth/damaging-surfaces.html

This commit stores this information and exposes it to exported EGL image
clients.

It also bumps the nested compositor interface to version 4, which
provides the damage_buffer support.
lauromoura added a commit to lauromoura/WebKit that referenced this pull request Mar 19, 2024
https://bugs.webkit.org/show_bug.cgi?id=265777

Reviewed by NOBODY (OOPS!).

Allows the WPE to report what parts of the new frame changed since the
last frame. This allows the compositor to optimize the drawing by updating
a smaller region. While usually negligible on the desktop, this behavior
can bring benefits in less capable systems like embedded boards by
copying less memory around.

Note that currently the entire frame is still composited inside WebKit,
only the difference rects are reported. In the future, the composition
might be optimized to compose only the changed regions of the screen.

This works by collecting the damage information from various sources
like CoordinatedGraphicsLayer::setNeedsDisplay[InRect] and
TextureMapperLayer animation code and agreggating them in the
CoordinatedGraphicsScene when composing the frame. This information
is forwarded to the ThreadingCompositor, which uses it with
eglSwapBuffersWithDamage.

In the current WPEBackend-fdo architecture, this information is passed
to its nested Wayland compositor and made available in the backend API.

Support in the new WPE API will be added in https://bugs.webkit.org/show_bug.cgi?id=265653

Use -DENABLE_BUFFER_DAMAGE_TRACKING cmake option to enable the feature
at compile time.

Related to WPEBackend-fdo Igalia/WPEBackend-fdo#184

* Source/WebCore/platform/SourcesNicosia.txt:
* Source/WebCore/platform/TextureMapper.cmake:
* Source/WebCore/platform/graphics/egl/GLContext.cpp:
(WebCore::GLContext::GLContext):
(WebCore::GLContext::swapBuffersWithDamage):
* Source/WebCore/platform/graphics/egl/GLContext.h:
(WebCore::GLContext::m_eglSwapBuffersWithDamage):
* Source/WebCore/platform/graphics/nicosia/NicosiaBufferDamage.cpp: Added.
(Nicosia::checkDamageBufUnifiedRegion):
(Nicosia::bufDamageUnifiedRegion):
* Source/WebCore/platform/graphics/nicosia/NicosiaBufferDamage.h: Added.
* Source/WebCore/platform/graphics/nicosia/NicosiaCompositionLayer.h:
* Source/WebCore/platform/graphics/texmap/TextureMapperLayer.cpp:
(WebCore::TextureMapperLayer::paintSelf):
(WebCore::TextureMapperLayer::addChild):
(WebCore::TextureMapperLayer::removeFromParent):
(WebCore::TextureMapperLayer::removeAllChildren):
(WebCore::TextureMapperLayer::applyAnimationsRecursively):
(WebCore::TextureMapperLayer::acceptDamageVisitor):
(WebCore::TextureMapperLayer::dismissDamageVisitor):
(WebCore::TextureMapperLayer::markDamaged):
(WebCore::TextureMapperLayer::clearDamaged):
(WebCore::TextureMapperLayer::recordDamage):
* Source/WebCore/platform/graphics/texmap/TextureMapperLayer.h:
* Source/WebCore/platform/graphics/texmap/coordinated/CoordinatedGraphicsLayer.cpp:
(WebCore::CoordinatedGraphicsLayer::setContentsOpaque):
(WebCore::CoordinatedGraphicsLayer::setContentsNeedsDisplay):
(WebCore::CoordinatedGraphicsLayer::addDamageRegion):
(WebCore::CoordinatedGraphicsLayer::setNeedsDisplay):
(WebCore::CoordinatedGraphicsLayer::setNeedsDisplayInRect):
(WebCore::CoordinatedGraphicsLayer::flushCompositingStateForThisLayerOnly):
(WebCore::CoordinatedGraphicsLayer::computeTransformedVisibleRect):
* Source/WebCore/platform/graphics/texmap/coordinated/CoordinatedGraphicsLayer.h:
* Source/WebKit/Platform/Logging.h:
* Source/WebKit/Shared/CoordinatedGraphics/CoordinatedGraphicsScene.cpp:
(WebKit::CoordinatedGraphicsScene::paintToCurrentGLContext):
(WebKit::CoordinatedGraphicsScene::updateSceneState):
(WebKit::CoordinatedGraphicsScene::ensureRootLayer):
(WebKit::CoordinatedGraphicsScene::purgeGLResources):
(WebKit::CoordinatedGraphicsScene::recordDamage):
* Source/WebKit/Shared/CoordinatedGraphics/CoordinatedGraphicsScene.h:
(WebKit::CoordinatedGraphicsScene::lastDamagedRects const):
* Source/WebKit/Shared/CoordinatedGraphics/threadedcompositor/ThreadedCompositor.cpp:
(WebKit::ThreadedCompositor::renderLayerTree):
* Source/cmake/WebKitFeatures.cmake:
* Tools/wpe/backends/fdo/WindowViewBackend.cpp:
(WPEToolingBackends::WindowViewBackend::displayBuffer):
@lauromoura
Copy link
Author

Superseded by #188

@lauromoura lauromoura closed this Mar 19, 2024
Scony pushed a commit to Scony/WebKit that referenced this pull request Mar 20, 2024
https://bugs.webkit.org/show_bug.cgi?id=265777

Reviewed by NOBODY (OOPS!).

Allows the WPE to report what parts of the new frame changed since the
last frame. This allows the compositor to optimize the drawing by updating
a smaller region. While usually negligible on the desktop, this behavior
can bring benefits in less capable systems like embedded boards by
copying less memory around.

Note that currently the entire frame is still composited inside WebKit,
only the difference rects are reported. In the future, the composition
might be optimized to compose only the changed regions of the screen.

This works by collecting the damage information from various sources
like CoordinatedGraphicsLayer::setNeedsDisplay[InRect] and
TextureMapperLayer animation code and agreggating them in the
CoordinatedGraphicsScene when composing the frame. This information
is forwarded to the ThreadingCompositor, which uses it with
eglSwapBuffersWithDamage.

In the current WPEBackend-fdo architecture, this information is passed
to its nested Wayland compositor and made available in the backend API.

Support in the new WPE API will be added in https://bugs.webkit.org/show_bug.cgi?id=265653

Use -DENABLE_BUFFER_DAMAGE_TRACKING cmake option to enable the feature
at compile time.

Related to WPEBackend-fdo Igalia/WPEBackend-fdo#184

* Source/WebCore/platform/SourcesNicosia.txt:
* Source/WebCore/platform/TextureMapper.cmake:
* Source/WebCore/platform/graphics/egl/GLContext.cpp:
(WebCore::GLContext::GLContext):
(WebCore::GLContext::swapBuffersWithDamage):
* Source/WebCore/platform/graphics/egl/GLContext.h:
(WebCore::GLContext::m_eglSwapBuffersWithDamage):
* Source/WebCore/platform/graphics/nicosia/NicosiaBufferDamage.cpp: Added.
(Nicosia::checkDamageBufUnifiedRegion):
(Nicosia::bufDamageUnifiedRegion):
* Source/WebCore/platform/graphics/nicosia/NicosiaBufferDamage.h: Added.
* Source/WebCore/platform/graphics/nicosia/NicosiaCompositionLayer.h:
* Source/WebCore/platform/graphics/texmap/TextureMapperLayer.cpp:
(WebCore::TextureMapperLayer::paintSelf):
(WebCore::TextureMapperLayer::addChild):
(WebCore::TextureMapperLayer::removeFromParent):
(WebCore::TextureMapperLayer::removeAllChildren):
(WebCore::TextureMapperLayer::applyAnimationsRecursively):
(WebCore::TextureMapperLayer::acceptDamageVisitor):
(WebCore::TextureMapperLayer::dismissDamageVisitor):
(WebCore::TextureMapperLayer::markDamaged):
(WebCore::TextureMapperLayer::clearDamaged):
(WebCore::TextureMapperLayer::recordDamage):
* Source/WebCore/platform/graphics/texmap/TextureMapperLayer.h:
* Source/WebCore/platform/graphics/texmap/coordinated/CoordinatedGraphicsLayer.cpp:
(WebCore::CoordinatedGraphicsLayer::setContentsOpaque):
(WebCore::CoordinatedGraphicsLayer::setContentsNeedsDisplay):
(WebCore::CoordinatedGraphicsLayer::addDamageRegion):
(WebCore::CoordinatedGraphicsLayer::setNeedsDisplay):
(WebCore::CoordinatedGraphicsLayer::setNeedsDisplayInRect):
(WebCore::CoordinatedGraphicsLayer::flushCompositingStateForThisLayerOnly):
(WebCore::CoordinatedGraphicsLayer::computeTransformedVisibleRect):
* Source/WebCore/platform/graphics/texmap/coordinated/CoordinatedGraphicsLayer.h:
* Source/WebKit/Platform/Logging.h:
* Source/WebKit/Shared/CoordinatedGraphics/CoordinatedGraphicsScene.cpp:
(WebKit::CoordinatedGraphicsScene::paintToCurrentGLContext):
(WebKit::CoordinatedGraphicsScene::updateSceneState):
(WebKit::CoordinatedGraphicsScene::ensureRootLayer):
(WebKit::CoordinatedGraphicsScene::purgeGLResources):
(WebKit::CoordinatedGraphicsScene::recordDamage):
* Source/WebKit/Shared/CoordinatedGraphics/CoordinatedGraphicsScene.h:
(WebKit::CoordinatedGraphicsScene::lastDamagedRects const):
* Source/WebKit/Shared/CoordinatedGraphics/threadedcompositor/ThreadedCompositor.cpp:
(WebKit::ThreadedCompositor::renderLayerTree):
* Source/cmake/WebKitFeatures.cmake:
* Tools/wpe/backends/fdo/WindowViewBackend.cpp:
(WPEToolingBackends::WindowViewBackend::displayBuffer):
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant