2024-01-18 20:29:09 +01:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2024, Aliaksandr Kalenik <kalenik.aliaksandr@gmail.com>
|
|
|
|
*
|
|
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
|
|
*/
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
2024-11-29 22:15:02 +01:00
|
|
|
#include <LibGfx/Forward.h>
|
|
|
|
#include <LibGfx/Size.h>
|
2024-01-18 20:29:09 +01:00
|
|
|
|
|
|
|
namespace Web::WebGL {
|
|
|
|
|
|
|
|
class OpenGLContext {
|
|
|
|
public:
|
2025-03-23 10:38:00 +00:00
|
|
|
enum class WebGLVersion {
|
|
|
|
WebGL1,
|
|
|
|
WebGL2,
|
|
|
|
};
|
|
|
|
|
|
|
|
static OwnPtr<OpenGLContext> create(NonnullRefPtr<Gfx::SkiaBackendContext>, WebGLVersion);
|
2024-01-18 20:29:09 +01:00
|
|
|
|
2024-11-29 23:15:43 +01:00
|
|
|
void notify_content_will_change();
|
2024-01-18 20:29:09 +01:00
|
|
|
void clear_buffer_to_default_values();
|
2024-11-29 22:15:02 +01:00
|
|
|
void allocate_painting_surface_if_needed();
|
2024-01-18 20:29:09 +01:00
|
|
|
|
2024-11-29 22:15:02 +01:00
|
|
|
struct Impl;
|
2025-03-23 10:38:00 +00:00
|
|
|
OpenGLContext(NonnullRefPtr<Gfx::SkiaBackendContext>, Impl, WebGLVersion);
|
2024-11-29 22:15:02 +01:00
|
|
|
|
|
|
|
~OpenGLContext();
|
|
|
|
|
|
|
|
void make_current();
|
|
|
|
|
2025-03-23 11:27:39 +00:00
|
|
|
void present(bool preserve_drawing_buffer);
|
|
|
|
|
2024-11-29 22:15:02 +01:00
|
|
|
void set_size(Gfx::IntSize const&);
|
|
|
|
|
|
|
|
RefPtr<Gfx::PaintingSurface> surface();
|
|
|
|
|
2025-01-08 13:00:12 +00:00
|
|
|
u32 default_framebuffer() const;
|
|
|
|
u32 default_renderbuffer() const;
|
|
|
|
|
2024-12-10 05:49:33 +01:00
|
|
|
Vector<String> get_supported_extensions();
|
2025-01-10 12:55:47 +00:00
|
|
|
void request_extension(char const* extension_name);
|
2024-12-10 05:49:33 +01:00
|
|
|
|
2024-11-29 22:15:02 +01:00
|
|
|
private:
|
|
|
|
NonnullRefPtr<Gfx::SkiaBackendContext> m_skia_backend_context;
|
|
|
|
Gfx::IntSize m_size;
|
|
|
|
RefPtr<Gfx::PaintingSurface> m_painting_surface;
|
|
|
|
NonnullOwnPtr<Impl> m_impl;
|
2025-01-17 15:42:17 +00:00
|
|
|
Optional<Vector<String>> m_requestable_extensions;
|
2025-03-23 10:38:00 +00:00
|
|
|
WebGLVersion m_webgl_version;
|
2024-01-18 20:29:09 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|