mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-05-30 06:52:52 +00:00
LibWeb/WebGL: Implement getSupportedExtensions()
This commit is contained in:
parent
af4f0c5a81
commit
145bb0f849
Notes:
github-actions[bot]
2024-12-13 08:20:40 +00:00
Author: https://github.com/kalenikaliaksandr
Commit: 145bb0f849
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/2878
Reviewed-by: https://github.com/ADKaster
Reviewed-by: https://github.com/gmta
6 changed files with 90 additions and 6 deletions
|
@ -204,4 +204,86 @@ RefPtr<Gfx::PaintingSurface> OpenGLContext::surface()
|
|||
return m_painting_surface;
|
||||
}
|
||||
|
||||
Vector<StringView> s_available_webgl_extensions {
|
||||
// Khronos ratified WebGL Extensions
|
||||
"ANGLE_instanced_arrays"sv,
|
||||
"EXT_blend_minmax"sv,
|
||||
"EXT_frag_depth"sv,
|
||||
"EXT_shader_texture_lod"sv,
|
||||
"EXT_texture_filter_anisotropic"sv,
|
||||
"OES_element_index_uint"sv,
|
||||
"OES_standard_derivatives"sv,
|
||||
"OES_texture_float"sv,
|
||||
"OES_texture_float_linear"sv,
|
||||
"OES_texture_half_float"sv,
|
||||
"OES_texture_half_float_linear"sv,
|
||||
"OES_vertex_array_object"sv,
|
||||
"WEBGL_compressed_texture_s3tc"sv,
|
||||
"WEBGL_debug_renderer_info"sv,
|
||||
"WEBGL_debug_shaders"sv,
|
||||
"WEBGL_depth_texture"sv,
|
||||
"WEBGL_draw_buffers"sv,
|
||||
"WEBGL_lose_context"sv,
|
||||
|
||||
// Community approved WebGL Extensions
|
||||
"EXT_clip_control"sv,
|
||||
"EXT_color_buffer_float"sv,
|
||||
"EXT_color_buffer_half_float"sv,
|
||||
"EXT_conservative_depth"sv,
|
||||
"EXT_depth_clamp"sv,
|
||||
"EXT_disjoint_timer_query"sv,
|
||||
"EXT_disjoint_timer_query_webgl2"sv,
|
||||
"EXT_float_blend"sv,
|
||||
"EXT_polygon_offset_clamp"sv,
|
||||
"EXT_render_snorm"sv,
|
||||
"EXT_sRGB"sv,
|
||||
"EXT_texture_compression_bptc"sv,
|
||||
"EXT_texture_compression_rgtc"sv,
|
||||
"EXT_texture_mirror_clamp_to_edge"sv,
|
||||
"EXT_texture_norm16"sv,
|
||||
"KHR_parallel_shader_compile"sv,
|
||||
"NV_shader_noperspective_interpolation"sv,
|
||||
"OES_draw_buffers_indexed"sv,
|
||||
"OES_fbo_render_mipmap"sv,
|
||||
"OES_sample_variables"sv,
|
||||
"OES_shader_multisample_interpolation"sv,
|
||||
"OVR_multiview2"sv,
|
||||
"WEBGL_blend_func_extended"sv,
|
||||
"WEBGL_clip_cull_distance"sv,
|
||||
"WEBGL_color_buffer_float"sv,
|
||||
"WEBGL_compressed_texture_astc"sv,
|
||||
"WEBGL_compressed_texture_etc"sv,
|
||||
"WEBGL_compressed_texture_etc1"sv,
|
||||
"WEBGL_compressed_texture_pvrtc"sv,
|
||||
"WEBGL_compressed_texture_s3tc_srgb"sv,
|
||||
"WEBGL_multi_draw"sv,
|
||||
"WEBGL_polygon_mode"sv,
|
||||
"WEBGL_provoking_vertex"sv,
|
||||
"WEBGL_render_shared_exponent"sv,
|
||||
"WEBGL_stencil_texturing"sv,
|
||||
};
|
||||
|
||||
Vector<String> OpenGLContext::get_supported_extensions()
|
||||
{
|
||||
#ifdef AK_OS_MACOS
|
||||
make_current();
|
||||
|
||||
auto const* extensions_string = reinterpret_cast<char const*>(glGetString(GL_EXTENSIONS));
|
||||
StringView extensions_view(extensions_string, strlen(extensions_string));
|
||||
|
||||
Vector<String> extensions;
|
||||
for (auto const& extension : extensions_view.split_view(' ')) {
|
||||
auto extension_name_without_gl_prefix = extension.substring_view(3);
|
||||
// FIXME: WebGL 1 and WebGL 2 have different sets of available extensions, but for now we simply
|
||||
// filter out everything that is not listed in https://registry.khronos.org/webgl/extensions/
|
||||
if (s_available_webgl_extensions.contains_slow(extension_name_without_gl_prefix))
|
||||
extensions.append(MUST(String::from_utf8(extension_name_without_gl_prefix)));
|
||||
}
|
||||
|
||||
return extensions;
|
||||
#else
|
||||
return {};
|
||||
#endif
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -30,6 +30,8 @@ public:
|
|||
|
||||
RefPtr<Gfx::PaintingSurface> surface();
|
||||
|
||||
Vector<String> get_supported_extensions();
|
||||
|
||||
private:
|
||||
NonnullRefPtr<Gfx::SkiaBackendContext> m_skia_backend_context;
|
||||
Gfx::IntSize m_size;
|
||||
|
|
|
@ -145,9 +145,9 @@ void WebGL2RenderingContext::allocate_painting_surface_if_needed()
|
|||
context().allocate_painting_surface_if_needed();
|
||||
}
|
||||
|
||||
Optional<Vector<String>> WebGL2RenderingContext::get_supported_extensions() const
|
||||
Optional<Vector<String>> WebGL2RenderingContext::get_supported_extensions()
|
||||
{
|
||||
return {};
|
||||
return context().get_supported_extensions();
|
||||
}
|
||||
|
||||
JS::Object* WebGL2RenderingContext::get_extension(String const&)
|
||||
|
|
|
@ -41,7 +41,7 @@ public:
|
|||
void set_size(Gfx::IntSize const&);
|
||||
void reset_to_default_state();
|
||||
|
||||
Optional<Vector<String>> get_supported_extensions() const;
|
||||
Optional<Vector<String>> get_supported_extensions();
|
||||
JS::Object* get_extension(String const& name);
|
||||
|
||||
WebIDL::Long drawing_buffer_width() const;
|
||||
|
|
|
@ -161,9 +161,9 @@ void WebGLRenderingContext::allocate_painting_surface_if_needed()
|
|||
context().allocate_painting_surface_if_needed();
|
||||
}
|
||||
|
||||
Optional<Vector<String>> WebGLRenderingContext::get_supported_extensions() const
|
||||
Optional<Vector<String>> WebGLRenderingContext::get_supported_extensions()
|
||||
{
|
||||
return {};
|
||||
return context().get_supported_extensions();
|
||||
}
|
||||
|
||||
JS::Object* WebGLRenderingContext::get_extension(String const&)
|
||||
|
|
|
@ -40,7 +40,7 @@ public:
|
|||
void set_size(Gfx::IntSize const&);
|
||||
void reset_to_default_state();
|
||||
|
||||
Optional<Vector<String>> get_supported_extensions() const;
|
||||
Optional<Vector<String>> get_supported_extensions();
|
||||
JS::Object* get_extension(String const& name);
|
||||
|
||||
WebIDL::Long drawing_buffer_width() const;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue