mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-22 23:50:19 +00: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.
46 lines
973 B
C++
46 lines
973 B
C++
/*
|
|
* Copyright (c) 2024, Aliaksandr Kalenik <kalenik.aliaksandr@gmail.com>
|
|
*
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
#include <AK/Forward.h>
|
|
#include <AK/Noncopyable.h>
|
|
#include <AK/OwnPtr.h>
|
|
#include <LibCore/MachPort.h>
|
|
|
|
namespace Core {
|
|
|
|
class IOSurfaceHandle {
|
|
AK_MAKE_NONCOPYABLE(IOSurfaceHandle);
|
|
|
|
public:
|
|
IOSurfaceHandle(IOSurfaceHandle&& other);
|
|
IOSurfaceHandle& operator=(IOSurfaceHandle&& other);
|
|
|
|
static IOSurfaceHandle create(int width, int height);
|
|
static IOSurfaceHandle from_mach_port(MachPort const& port);
|
|
|
|
MachPort create_mach_port() const;
|
|
|
|
size_t width() const;
|
|
size_t height() const;
|
|
size_t bytes_per_element() const;
|
|
size_t bytes_per_row() const;
|
|
void* data() const;
|
|
|
|
void* core_foundation_pointer() const;
|
|
|
|
~IOSurfaceHandle();
|
|
|
|
private:
|
|
struct IOSurfaceRefWrapper;
|
|
|
|
IOSurfaceHandle(OwnPtr<IOSurfaceRefWrapper>&&);
|
|
|
|
OwnPtr<IOSurfaceRefWrapper> m_ref_wrapper;
|
|
};
|
|
|
|
}
|