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.
42 lines
878 B
C++
42 lines
878 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 <AK/RefCounted.h>
|
|
#include <AK/RefPtr.h>
|
|
#include <LibCore/IOSurface.h>
|
|
|
|
namespace Gfx {
|
|
|
|
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 RefCounted<MetalContext> {
|
|
public:
|
|
virtual void const* device() const = 0;
|
|
virtual void const* queue() const = 0;
|
|
|
|
virtual OwnPtr<MetalTexture> create_texture_from_iosurface(Core::IOSurfaceHandle const&) = 0;
|
|
|
|
virtual ~MetalContext() {};
|
|
};
|
|
|
|
RefPtr<MetalContext> get_metal_context();
|
|
|
|
}
|