mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-01-23 09:46:04 -05:00
79acb998e1
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.
39 lines
789 B
C++
39 lines
789 B
C++
/*
|
|
* Copyright (c) 2024, Aliaksandr Kalenik <kalenik.aliaksandr@gmail.com>
|
|
*
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
#if !defined(AK_OS_MACOS)
|
|
static_assert(false, "This file must only be used for macOS");
|
|
#endif
|
|
|
|
#include <AK/Forward.h>
|
|
#include <LibCore/IOSurface.h>
|
|
|
|
namespace Core {
|
|
|
|
class MetalTexture {
|
|
public:
|
|
virtual void const* texture() const = 0;
|
|
virtual size_t width() const = 0;
|
|
virtual size_t height() const = 0;
|
|
|
|
virtual ~MetalTexture() {};
|
|
};
|
|
|
|
class MetalContext {
|
|
public:
|
|
virtual void const* device() const = 0;
|
|
virtual void const* queue() const = 0;
|
|
|
|
virtual OwnPtr<MetalTexture> create_texture_from_iosurface(IOSurfaceHandle const&) = 0;
|
|
|
|
virtual ~MetalContext() {};
|
|
};
|
|
|
|
OwnPtr<MetalContext> get_metal_context();
|
|
|
|
}
|