mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-07-24 18:02:20 +00:00
The Skia Ganesh backend we currently use doesn't support painting from multiple threads, which could happen before this change when the main thread used Skia to paint on the HTML canvas while the rendering thread was working on display list rasterization. Fixes https://github.com/LadybirdBrowser/ladybird/issues/4172
56 lines
1.1 KiB
C++
56 lines
1.1 KiB
C++
/*
|
|
* Copyright (c) 2024, Aliaksandr Kalenik <kalenik.aliaksandr@gmail.com>
|
|
*
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
#include <AK/Noncopyable.h>
|
|
#include <AK/RefCounted.h>
|
|
#include <LibThreading/Mutex.h>
|
|
|
|
#ifdef USE_VULKAN
|
|
# include <LibGfx/VulkanContext.h>
|
|
#endif
|
|
|
|
#ifdef AK_OS_MACOS
|
|
# include <LibGfx/MetalContext.h>
|
|
#endif
|
|
|
|
class GrDirectContext;
|
|
class SkSurface;
|
|
|
|
namespace Gfx {
|
|
|
|
class MetalContext;
|
|
|
|
class SkiaBackendContext : public RefCounted<SkiaBackendContext> {
|
|
AK_MAKE_NONCOPYABLE(SkiaBackendContext);
|
|
AK_MAKE_NONMOVABLE(SkiaBackendContext);
|
|
|
|
public:
|
|
#ifdef USE_VULKAN
|
|
static RefPtr<SkiaBackendContext> create_vulkan_context(VulkanContext&);
|
|
#endif
|
|
|
|
#ifdef AK_OS_MACOS
|
|
static RefPtr<SkiaBackendContext> create_metal_context(MetalContext&);
|
|
#endif
|
|
|
|
SkiaBackendContext() { }
|
|
virtual ~SkiaBackendContext() { }
|
|
|
|
virtual void flush_and_submit(SkSurface*) { }
|
|
virtual GrDirectContext* sk_context() const = 0;
|
|
|
|
virtual MetalContext& metal_context() = 0;
|
|
|
|
void lock() { m_mutex.lock(); }
|
|
void unlock() { m_mutex.unlock(); }
|
|
|
|
private:
|
|
Threading::Mutex m_mutex;
|
|
};
|
|
|
|
}
|