mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-07-30 04:39:06 +00:00
LibWeb: Implement GLES2 context creation
For now only macOS is supported. IOSurface is used as a backing store because it will allow us to read it from Skia and write to it from OpenGL without any extra copying: - ANGLE_metal_texture_client_buffer extension is used to create EGLSurface from IOSurface. - Then the same IOSurface is wrapped into Metal texture and passed to Skia allowing to share the same memory between Skia Metal backend and ANGLE.
This commit is contained in:
parent
d133b0aded
commit
38488b9ef3
Notes:
github-actions[bot]
2024-12-03 22:37:28 +00:00
Author: https://github.com/kalenikaliaksandr
Commit: 38488b9ef3
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/2688
Reviewed-by: https://github.com/ADKaster ✅
5 changed files with 223 additions and 19 deletions
|
@ -57,13 +57,16 @@ JS::ThrowCompletionOr<GC::Ptr<WebGLRenderingContext>> WebGLRenderingContext::cre
|
|||
// We should be coming here from getContext being called on a wrapped <canvas> element.
|
||||
auto context_attributes = TRY(convert_value_to_context_attributes_dictionary(canvas_element.vm(), options));
|
||||
|
||||
auto context = OpenGLContext::create();
|
||||
auto skia_backend_context = canvas_element.navigable()->traversable_navigable()->skia_backend_context();
|
||||
auto context = OpenGLContext::create(*skia_backend_context);
|
||||
|
||||
if (!context) {
|
||||
fire_webgl_context_creation_error(canvas_element);
|
||||
return GC::Ptr<WebGLRenderingContext> { nullptr };
|
||||
}
|
||||
|
||||
context->set_size(canvas_element.bitmap_size_for_canvas(1, 1));
|
||||
|
||||
return realm.create<WebGLRenderingContext>(realm, canvas_element, context.release_nonnull(), context_attributes, context_attributes);
|
||||
}
|
||||
|
||||
|
@ -137,9 +140,9 @@ bool WebGLRenderingContext::is_context_lost() const
|
|||
return m_context_lost;
|
||||
}
|
||||
|
||||
void WebGLRenderingContext::set_size(Gfx::IntSize const&)
|
||||
void WebGLRenderingContext::set_size(Gfx::IntSize const& size)
|
||||
{
|
||||
TODO();
|
||||
m_context->set_size(size);
|
||||
}
|
||||
|
||||
void WebGLRenderingContext::reset_to_default_state()
|
||||
|
@ -148,7 +151,12 @@ void WebGLRenderingContext::reset_to_default_state()
|
|||
|
||||
RefPtr<Gfx::PaintingSurface> WebGLRenderingContext::surface()
|
||||
{
|
||||
TODO();
|
||||
return m_context->surface();
|
||||
}
|
||||
|
||||
void WebGLRenderingContext::allocate_painting_surface_if_needed()
|
||||
{
|
||||
m_context->allocate_painting_surface_if_needed();
|
||||
}
|
||||
|
||||
Optional<Vector<String>> WebGLRenderingContext::get_supported_extensions() const
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue