LibCore+LibWeb: Use Metal backend for Skia painter on macOS

If Metal context and IOSurface are available, Skia painter will use
Ganesh GPU backend on macOS, which is noticeably faster than the default
CPU backend.

Painting pipeline:
1. (WebContent) Allocate IOSurface for backing store
2. (WebContent) Allocate MTLTexture that wraps IOSurface
3. (WebContent) Paint into MTLTexture using Skia
4. (Browser) Wrap IOSurface into Gfx::Painter and use
   QPainter/CoreGraphics to blit backing store into viewport.

Things we should improve in the future:
1. Upload textures for images in advance instead of doing that before
   every repaint.
2. Teach AppKit client to read directly from IOSurface instead of
   copying.
This commit is contained in:
Aliaksandr Kalenik 2024-06-26 17:56:55 +02:00 committed by Alexander Kalenik
commit 79acb998e1
Notes: sideshowbarker 2024-07-16 20:05:14 +09:00
10 changed files with 288 additions and 21 deletions

View file

@ -12,8 +12,13 @@
#include <LibWeb/HTML/SessionHistoryTraversalQueue.h>
#include <LibWeb/HTML/VisibilityState.h>
#include <LibWeb/Page/Page.h>
#include <LibWeb/Painting/DisplayListPlayerSkia.h>
#include <WebContent/BackingStoreManager.h>
#ifdef AK_OS_MACOS
# include <LibCore/MetalContext.h>
#endif
namespace Web::HTML {
// https://html.spec.whatwg.org/multipage/document-sequences.html#traversable-navigable
@ -124,6 +129,11 @@ private:
JS::NonnullGCPtr<SessionHistoryTraversalQueue> m_session_history_traversal_queue;
String m_window_handle;
#ifdef AK_OS_MACOS
OwnPtr<Web::Painting::SkiaBackendContext> m_skia_backend_context;
OwnPtr<Core::MetalContext> m_metal_context;
#endif
};
struct BrowsingContextAndDocument {