LibGfx+LibWeb: Specify bottom left origin for WebGL's PaintingSurface

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/
This commit is contained in:
Aliaksandr Kalenik 2024-12-20 16:46:12 +01:00 committed by Alexander Kalenik
commit 30d915c361
Notes: github-actions[bot] 2024-12-20 19:48:39 +00:00
4 changed files with 20 additions and 19 deletions

View file

@ -24,11 +24,16 @@ 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>);
static NonnullRefPtr<PaintingSurface> wrap_iosurface(Core::IOSurfaceHandle const&, RefPtr<SkiaBackendContext>, Origin = Origin::TopLeft);
#endif
void read_into_bitmap(Bitmap&);
@ -47,9 +52,6 @@ public:
void flush() const;
bool flip_vertically() const { return m_flip_vertically; }
void set_flip_vertically() { m_flip_vertically = true; }
~PaintingSurface();
private:
@ -58,7 +60,6 @@ private:
PaintingSurface(NonnullOwnPtr<Impl>&&);
NonnullOwnPtr<Impl> m_impl;
bool m_flip_vertically { false };
};
}