mirror of
https://github.com/LadybirdBrowser/ladybird
synced 2026-04-25 17:25:08 +02:00
Generalize the backing store sharing abstraction into SharedImage, which represents shared GPU memory independently of Skia and can be used to share memory between different processes or different GPU contexts.
50 lines
1.1 KiB
C++
50 lines
1.1 KiB
C++
/*
|
|
* Copyright (c) 2026, Aliaksandr Kalenik <kalenik.aliaksandr@gmail.com>
|
|
*
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
#include <AK/Noncopyable.h>
|
|
#include <AK/NonnullRefPtr.h>
|
|
#include <LibGfx/Bitmap.h>
|
|
#include <LibGfx/SharedImage.h>
|
|
|
|
#ifdef AK_OS_MACOS
|
|
# include <LibCore/IOSurface.h>
|
|
#endif
|
|
|
|
namespace Gfx {
|
|
|
|
class SharedImageBuffer {
|
|
AK_MAKE_NONCOPYABLE(SharedImageBuffer);
|
|
|
|
public:
|
|
static SharedImageBuffer create(IntSize);
|
|
static SharedImageBuffer import_from_shared_image(SharedImage);
|
|
|
|
SharedImageBuffer(SharedImageBuffer&&);
|
|
SharedImageBuffer& operator=(SharedImageBuffer&&);
|
|
~SharedImageBuffer();
|
|
|
|
SharedImage export_shared_image() const;
|
|
|
|
NonnullRefPtr<Bitmap> bitmap() const { return m_bitmap; }
|
|
|
|
#ifdef AK_OS_MACOS
|
|
Core::IOSurfaceHandle const& iosurface_handle() const { return m_iosurface_handle; }
|
|
#endif
|
|
|
|
private:
|
|
#ifdef AK_OS_MACOS
|
|
SharedImageBuffer(Core::IOSurfaceHandle&&, NonnullRefPtr<Bitmap>);
|
|
Core::IOSurfaceHandle m_iosurface_handle;
|
|
#else
|
|
explicit SharedImageBuffer(NonnullRefPtr<Bitmap>);
|
|
#endif
|
|
NonnullRefPtr<Bitmap> m_bitmap;
|
|
};
|
|
|
|
}
|