mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-01-22 09:12:13 -05:00
30d915c361
By doing that we eliminate the need for the vertical flip flag. As a side effect it fixes the bug when doing: `canvasContext2d.drawImage(canvasWithWebGLContext, 0, 0);` produced a flipped image because we didn't account for different origin while serializing PaintingSurface into Gfx::Bitmap. Visual progress on https://ciechanow.ski/curves-and-surfaces/
65 lines
1.4 KiB
C++
65 lines
1.4 KiB
C++
/*
|
|
* Copyright (c) 2024, Aliaksandr Kalenik <kalenik.aliaksandr@gmail.com>
|
|
*
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
#include <AK/NonnullOwnPtr.h>
|
|
#include <AK/RefCounted.h>
|
|
#include <AK/RefPtr.h>
|
|
#include <LibGfx/Color.h>
|
|
#include <LibGfx/Size.h>
|
|
#include <LibGfx/SkiaBackendContext.h>
|
|
|
|
#ifdef AK_OS_MACOS
|
|
# include <LibGfx/MetalContext.h>
|
|
#endif
|
|
|
|
class SkCanvas;
|
|
class SkSurface;
|
|
|
|
namespace Gfx {
|
|
|
|
class PaintingSurface : public RefCounted<PaintingSurface> {
|
|
public:
|
|
enum class Origin {
|
|
TopLeft,
|
|
BottomLeft,
|
|
};
|
|
|
|
static NonnullRefPtr<PaintingSurface> create_with_size(RefPtr<SkiaBackendContext> context, Gfx::IntSize size, Gfx::BitmapFormat color_type, Gfx::AlphaType alpha_type);
|
|
static NonnullRefPtr<PaintingSurface> wrap_bitmap(Bitmap&);
|
|
|
|
#ifdef AK_OS_MACOS
|
|
static NonnullRefPtr<PaintingSurface> wrap_iosurface(Core::IOSurfaceHandle const&, RefPtr<SkiaBackendContext>, 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<typename T>
|
|
T sk_image_snapshot() const;
|
|
|
|
void flush() const;
|
|
|
|
~PaintingSurface();
|
|
|
|
private:
|
|
struct Impl;
|
|
|
|
PaintingSurface(NonnullOwnPtr<Impl>&&);
|
|
|
|
NonnullOwnPtr<Impl> m_impl;
|
|
};
|
|
|
|
}
|