/* * Copyright (c) 2024, Aliaksandr Kalenik * * SPDX-License-Identifier: BSD-2-Clause */ #pragma once #include #include #include #ifdef AK_OS_MACOS # include #endif namespace Web::Painting { class BackingStore { AK_MAKE_NONCOPYABLE(BackingStore); public: virtual Gfx::IntSize size() const = 0; virtual Gfx::Bitmap& bitmap() const = 0; BackingStore() { } virtual ~BackingStore() { } }; class BitmapBackingStore final : public BackingStore { public: BitmapBackingStore(RefPtr); Gfx::IntSize size() const override { return m_bitmap->size(); } Gfx::Bitmap& bitmap() const override { return *m_bitmap; } private: RefPtr m_bitmap; }; #ifdef AK_OS_MACOS class IOSurfaceBackingStore final : public BackingStore { public: IOSurfaceBackingStore(Core::IOSurfaceHandle&&); Gfx::IntSize size() const override; Core::IOSurfaceHandle& iosurface_handle() { return m_iosurface_handle; } Gfx::Bitmap& bitmap() const override { return *m_bitmap_wrapper; } private: Core::IOSurfaceHandle m_iosurface_handle; RefPtr m_bitmap_wrapper; }; #endif }