/* * Copyright (c) 2024-2025, Aliaksandr Kalenik * * SPDX-License-Identifier: BSD-2-Clause */ #pragma once #include #include #include #include #include #include #include #ifdef AK_OS_MACOS # include #endif class SkCanvas; class SkSurface; namespace Gfx { class PaintingSurface : public AtomicRefCounted { public: enum class Origin { TopLeft, BottomLeft, }; Function on_flush; static NonnullRefPtr create_with_size(RefPtr context, IntSize size, BitmapFormat color_type, AlphaType alpha_type); static NonnullRefPtr wrap_bitmap(Bitmap&); #ifdef AK_OS_MACOS static NonnullRefPtr create_from_iosurface(Core::IOSurfaceHandle&&, NonnullRefPtr, 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(); ~PaintingSurface(); void lock_context() const; void unlock_context() const; private: struct Impl; PaintingSurface(NonnullOwnPtr&&); NonnullOwnPtr m_impl; }; }