diff --git a/Libraries/LibWeb/CMakeLists.txt b/Libraries/LibWeb/CMakeLists.txt index a29bf46f838..4de4cd68c44 100644 --- a/Libraries/LibWeb/CMakeLists.txt +++ b/Libraries/LibWeb/CMakeLists.txt @@ -847,6 +847,7 @@ set(SOURCES WebDriver/TimeoutsConfiguration.cpp WebDriver/UserPrompt.cpp WebGL/Extensions/ANGLEInstancedArrays.cpp + WebGL/Extensions/EXTColorBufferFloat.cpp WebGL/Extensions/OESVertexArrayObject.cpp WebGL/Extensions/WebGLCompressedTextureS3tc.cpp WebGL/Extensions/WebGLDrawBuffers.cpp diff --git a/Libraries/LibWeb/Forward.h b/Libraries/LibWeb/Forward.h index 42670e156de..ec6d824c740 100644 --- a/Libraries/LibWeb/Forward.h +++ b/Libraries/LibWeb/Forward.h @@ -912,6 +912,7 @@ class WebGLVertexArrayObject; namespace Web::WebGL::Extensions { class ANGLEInstancedArrays; +class EXTColorBufferFloat; class OESVertexArrayObject; class WebGLCompressedTextureS3tc; class WebGLDrawBuffers; diff --git a/Libraries/LibWeb/WebGL/Extensions/EXTColorBufferFloat.cpp b/Libraries/LibWeb/WebGL/Extensions/EXTColorBufferFloat.cpp new file mode 100644 index 00000000000..6afbeef3b15 --- /dev/null +++ b/Libraries/LibWeb/WebGL/Extensions/EXTColorBufferFloat.cpp @@ -0,0 +1,42 @@ +/* + * Copyright (c) 2025, Luke Wilde + * + * SPDX-License-Identifier: BSD-2-Clause + */ + +#include +#include +#include +#include +#include +#include + +namespace Web::WebGL::Extensions { + +GC_DEFINE_ALLOCATOR(EXTColorBufferFloat); + +JS::ThrowCompletionOr> EXTColorBufferFloat::create(JS::Realm& realm, GC::Ref context) +{ + return realm.create(realm, context); +} + +EXTColorBufferFloat::EXTColorBufferFloat(JS::Realm& realm, GC::Ref context) + : PlatformObject(realm) + , m_context(context) +{ + m_context->context().request_extension("GL_EXT_color_buffer_float"); +} + +void EXTColorBufferFloat::initialize(JS::Realm& realm) +{ + Base::initialize(realm); + WEB_SET_PROTOTYPE_FOR_INTERFACE(EXTColorBufferFloat); +} + +void EXTColorBufferFloat::visit_edges(Visitor& visitor) +{ + Base::visit_edges(visitor); + visitor.visit(m_context); +} + +} diff --git a/Libraries/LibWeb/WebGL/Extensions/EXTColorBufferFloat.h b/Libraries/LibWeb/WebGL/Extensions/EXTColorBufferFloat.h new file mode 100644 index 00000000000..e54daab2a79 --- /dev/null +++ b/Libraries/LibWeb/WebGL/Extensions/EXTColorBufferFloat.h @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2025, Luke Wilde + * + * SPDX-License-Identifier: BSD-2-Clause + */ + +#pragma once + +#include +#include + +namespace Web::WebGL::Extensions { + +class EXTColorBufferFloat : public Bindings::PlatformObject { + WEB_PLATFORM_OBJECT(EXTColorBufferFloat, Bindings::PlatformObject); + GC_DECLARE_ALLOCATOR(EXTColorBufferFloat); + +public: + static JS::ThrowCompletionOr> create(JS::Realm&, GC::Ref); + +protected: + void initialize(JS::Realm&) override; + void visit_edges(Visitor&) override; + +private: + EXTColorBufferFloat(JS::Realm&, GC::Ref); + + GC::Ref m_context; +}; + +} diff --git a/Libraries/LibWeb/WebGL/Extensions/EXTColorBufferFloat.idl b/Libraries/LibWeb/WebGL/Extensions/EXTColorBufferFloat.idl new file mode 100644 index 00000000000..c075191d2d8 --- /dev/null +++ b/Libraries/LibWeb/WebGL/Extensions/EXTColorBufferFloat.idl @@ -0,0 +1,11 @@ +#import + +// https://registry.khronos.org/webgl/extensions/EXT_color_buffer_float/ +// NOTE: Original EXT_color_buffer_float name is changed to title case, +// so it matches corresponding C++ class name, and does not require +// IDL generator to handle snake_case to TitleCase conversion. +// Having a different name is totally fine, because LegacyNoInterfaceObject +// prevents the name from being exposed to JavaScript. +[Exposed=(Window,Worker), LegacyNoInterfaceObject] +interface EXTColorBufferFloat { +}; diff --git a/Libraries/LibWeb/WebGL/WebGL2RenderingContext.cpp b/Libraries/LibWeb/WebGL/WebGL2RenderingContext.cpp index 1b4d5b156d3..4b37d31232c 100644 --- a/Libraries/LibWeb/WebGL/WebGL2RenderingContext.cpp +++ b/Libraries/LibWeb/WebGL/WebGL2RenderingContext.cpp @@ -15,6 +15,7 @@ #include #include #include +#include #include #include #include @@ -73,6 +74,7 @@ void WebGL2RenderingContext::visit_edges(Cell::Visitor& visitor) Base::visit_edges(visitor); WebGL2RenderingContextImpl::visit_edges(visitor); visitor.visit(m_canvas_element); + visitor.visit(m_ext_color_buffer_float_extension); visitor.visit(m_webgl_compressed_texture_s3tc_extension); } @@ -180,6 +182,15 @@ JS::Object* WebGL2RenderingContext::get_extension(String const& name) return m_webgl_compressed_texture_s3tc_extension; } + if (Infra::is_ascii_case_insensitive_match(name, "EXT_color_buffer_float"sv)) { + if (!m_ext_color_buffer_float_extension) { + m_ext_color_buffer_float_extension = MUST(Extensions::EXTColorBufferFloat::create(realm(), *this)); + } + + VERIFY(m_ext_color_buffer_float_extension); + return m_ext_color_buffer_float_extension; + } + return nullptr; } diff --git a/Libraries/LibWeb/WebGL/WebGL2RenderingContext.h b/Libraries/LibWeb/WebGL/WebGL2RenderingContext.h index 994d0b23abd..879189a43b7 100644 --- a/Libraries/LibWeb/WebGL/WebGL2RenderingContext.h +++ b/Libraries/LibWeb/WebGL/WebGL2RenderingContext.h @@ -82,6 +82,7 @@ private: // Extensions // "Multiple calls to getExtension with the same extension string, taking into account case-insensitive comparison, must return the same object as long as the extension is enabled." + GC::Ptr m_ext_color_buffer_float_extension; GC::Ptr m_webgl_compressed_texture_s3tc_extension; virtual void set_error(GLenum error) override; diff --git a/Libraries/LibWeb/idl_files.cmake b/Libraries/LibWeb/idl_files.cmake index ddb5f80c20c..288dd9b25aa 100644 --- a/Libraries/LibWeb/idl_files.cmake +++ b/Libraries/LibWeb/idl_files.cmake @@ -390,6 +390,7 @@ libweb_js_bindings(WebAudio/PannerNode) libweb_js_bindings(WebAudio/PeriodicWave) libweb_js_bindings(WebAudio/StereoPannerNode) libweb_js_bindings(WebGL/Extensions/ANGLEInstancedArrays) +libweb_js_bindings(WebGL/Extensions/EXTColorBufferFloat) libweb_js_bindings(WebGL/Extensions/OESVertexArrayObject) libweb_js_bindings(WebGL/Extensions/WebGLCompressedTextureS3tc) libweb_js_bindings(WebGL/Extensions/WebGLDrawBuffers)