mirror of
https://github.com/fergalmoran/ladybird.git
synced 2025-12-22 09:19:03 +00:00
Previously, constructing a PaintingSurface from an IOSurface required wrapping IOSurface into a Metal texture before passing it to the PaintingSurface constructor. This process was cumbersome, as the caller needed access to a MetalContext to perform the wrapping. With this change SkiaBackendContext maintains a reference to the MetalContext which makes it possible to do: IOSurface -> MetalTexture -> SkSurface within a PaintingSurface constructor.
50 lines
1007 B
C++
50 lines
1007 B
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>
|
|
|
|
#ifdef AK_OS_MACOS
|
|
# include <LibGfx/MetalContext.h>
|
|
#endif
|
|
|
|
#ifdef USE_VULKAN
|
|
# include <LibGfx/VulkanContext.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(Gfx::VulkanContext&);
|
|
#endif
|
|
|
|
#ifdef AK_OS_MACOS
|
|
static RefPtr<Gfx::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;
|
|
};
|
|
|
|
}
|