1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-24 15:25:07 +00:00
serenity/Userland/Libraries/LibAccelGfx/Canvas.h
Aliaksandr Kalenik 95c154d9bd LibAccelGfx+Meta: Introduce OpenGL painting library
This change introduces a new 2D graphics library that uses OpenGL to
perform painting operations. For now, it has extremely limited
functionality and supports only rectangle painting, but we have to
start somewhere.

Since this library is intended to be used by LibWeb, where the
WebContent process does not have an associated window, painting occurs
in an offscreen buffer created using EGL.

For now it is only possible to compile this library on linux.
Offscreen context creation on SerenityOS and MacOS will have to be
implemented separately in the future.

Co-Authored-By: Andreas Kling <awesomekling@gmail.com>
2023-10-29 17:13:23 +01:00

41 lines
885 B
C++

/*
* Copyright (c) 2023, Andreas Kling <kling@serenityos.org>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#pragma once
#include <LibAccelGfx/Context.h>
#include <LibAccelGfx/Forward.h>
#include <LibGfx/Bitmap.h>
#include <LibGfx/Rect.h>
namespace AccelGfx {
class Canvas {
public:
static Canvas create(Context& context, NonnullRefPtr<Gfx::Bitmap> bitmap);
[[nodiscard]] Gfx::IntSize size() const { return m_bitmap->size(); }
[[nodiscard]] int width() const { return m_bitmap->width(); }
[[nodiscard]] int height() const { return m_bitmap->height(); }
void flush();
[[nodiscard]] Gfx::Bitmap const& bitmap() const { return *m_bitmap; }
~Canvas();
private:
explicit Canvas(NonnullRefPtr<Gfx::Bitmap>, Context&);
void initialize();
NonnullRefPtr<Gfx::Bitmap> m_bitmap;
Context& m_context;
Context::Surface m_surface;
};
}