mirror of
https://github.com/RGBCube/serenity
synced 2025-05-24 14:35:06 +00:00

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>
45 lines
905 B
C++
45 lines
905 B
C++
/*
|
|
* Copyright (c) 2023, Aliaksandr Kalenik <kalenik.aliaksandr@gmail.com>
|
|
*
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
#include <AK/Assertions.h>
|
|
#include <AK/OwnPtr.h>
|
|
|
|
#ifdef AK_OS_LINUX
|
|
# include <EGL/egl.h>
|
|
#endif
|
|
|
|
namespace AccelGfx {
|
|
|
|
class Context {
|
|
public:
|
|
static Context& the();
|
|
|
|
struct Surface {
|
|
EGLSurface egl_surface { 0 };
|
|
};
|
|
|
|
Surface create_surface(int width, int height);
|
|
void destroy_surface(Surface surface);
|
|
void set_active_surface(Surface surface);
|
|
|
|
static OwnPtr<Context> create();
|
|
|
|
Context(EGLDisplay egl_display, EGLContext egl_context, EGLConfig egl_config)
|
|
: m_egl_display(egl_display)
|
|
, m_egl_context(egl_context)
|
|
, m_egl_config(egl_config)
|
|
{
|
|
}
|
|
|
|
private:
|
|
EGLDisplay m_egl_display { nullptr };
|
|
EGLContext m_egl_context { nullptr };
|
|
EGLConfig m_egl_config { nullptr };
|
|
};
|
|
|
|
}
|