/* * Copyright (c) 2024, Aliaksandr Kalenik * * SPDX-License-Identifier: BSD-2-Clause */ #pragma once #include #include #include #include #include #include #ifdef AK_OS_MACOS # include #endif class SkCanvas; class SkSurface; namespace Gfx { class PaintingSurface : public RefCounted { public: enum class Origin { TopLeft, BottomLeft, }; static NonnullRefPtr create_with_size(RefPtr context, Gfx::IntSize size, Gfx::BitmapFormat color_type, Gfx::AlphaType alpha_type); static NonnullRefPtr wrap_bitmap(Bitmap&); #ifdef AK_OS_MACOS static NonnullRefPtr wrap_iosurface(Core::IOSurfaceHandle const&, RefPtr, Origin = Origin::TopLeft); #endif void read_into_bitmap(Bitmap&); void write_from_bitmap(Bitmap const&); void notify_content_will_change(); IntSize size() const; IntRect rect() const; SkCanvas& canvas() const; SkSurface& sk_surface() const; template T sk_image_snapshot() const; void flush() const; ~PaintingSurface(); private: struct Impl; PaintingSurface(NonnullOwnPtr&&); NonnullOwnPtr m_impl; }; }