mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-04-20 11:36:10 +00:00
LibWeb/WebGL2: Implement EXT_color_buffer_float extension
This makes the Point Of Sale model on https://www.shopify.com/ have colour instead of being completely black.
This commit is contained in:
parent
31853c13d3
commit
9ca25eed7f
Notes:
github-actions[bot]
2025-03-06 12:00:25 +00:00
Author: https://github.com/Lubrsi Commit: https://github.com/LadybirdBrowser/ladybird/commit/9ca25eed7f1 Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/3820
8 changed files with 99 additions and 0 deletions
|
@ -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
|
||||
|
|
|
@ -912,6 +912,7 @@ class WebGLVertexArrayObject;
|
|||
|
||||
namespace Web::WebGL::Extensions {
|
||||
class ANGLEInstancedArrays;
|
||||
class EXTColorBufferFloat;
|
||||
class OESVertexArrayObject;
|
||||
class WebGLCompressedTextureS3tc;
|
||||
class WebGLDrawBuffers;
|
||||
|
|
42
Libraries/LibWeb/WebGL/Extensions/EXTColorBufferFloat.cpp
Normal file
42
Libraries/LibWeb/WebGL/Extensions/EXTColorBufferFloat.cpp
Normal file
|
@ -0,0 +1,42 @@
|
|||
/*
|
||||
* Copyright (c) 2025, Luke Wilde <luke@ladybird.org>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#include <LibJS/Runtime/Realm.h>
|
||||
#include <LibWeb/Bindings/EXTColorBufferFloatPrototype.h>
|
||||
#include <LibWeb/Bindings/Intrinsics.h>
|
||||
#include <LibWeb/WebGL/Extensions/EXTColorBufferFloat.h>
|
||||
#include <LibWeb/WebGL/OpenGLContext.h>
|
||||
#include <LibWeb/WebGL/WebGL2RenderingContext.h>
|
||||
|
||||
namespace Web::WebGL::Extensions {
|
||||
|
||||
GC_DEFINE_ALLOCATOR(EXTColorBufferFloat);
|
||||
|
||||
JS::ThrowCompletionOr<GC::Ptr<EXTColorBufferFloat>> EXTColorBufferFloat::create(JS::Realm& realm, GC::Ref<WebGL2RenderingContext> context)
|
||||
{
|
||||
return realm.create<EXTColorBufferFloat>(realm, context);
|
||||
}
|
||||
|
||||
EXTColorBufferFloat::EXTColorBufferFloat(JS::Realm& realm, GC::Ref<WebGL2RenderingContext> 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);
|
||||
}
|
||||
|
||||
}
|
31
Libraries/LibWeb/WebGL/Extensions/EXTColorBufferFloat.h
Normal file
31
Libraries/LibWeb/WebGL/Extensions/EXTColorBufferFloat.h
Normal file
|
@ -0,0 +1,31 @@
|
|||
/*
|
||||
* Copyright (c) 2025, Luke Wilde <luke@ladybird.org>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <LibWeb/Bindings/PlatformObject.h>
|
||||
#include <LibWeb/Forward.h>
|
||||
|
||||
namespace Web::WebGL::Extensions {
|
||||
|
||||
class EXTColorBufferFloat : public Bindings::PlatformObject {
|
||||
WEB_PLATFORM_OBJECT(EXTColorBufferFloat, Bindings::PlatformObject);
|
||||
GC_DECLARE_ALLOCATOR(EXTColorBufferFloat);
|
||||
|
||||
public:
|
||||
static JS::ThrowCompletionOr<GC::Ptr<EXTColorBufferFloat>> create(JS::Realm&, GC::Ref<WebGL2RenderingContext>);
|
||||
|
||||
protected:
|
||||
void initialize(JS::Realm&) override;
|
||||
void visit_edges(Visitor&) override;
|
||||
|
||||
private:
|
||||
EXTColorBufferFloat(JS::Realm&, GC::Ref<WebGL2RenderingContext>);
|
||||
|
||||
GC::Ref<WebGL2RenderingContext> m_context;
|
||||
};
|
||||
|
||||
}
|
11
Libraries/LibWeb/WebGL/Extensions/EXTColorBufferFloat.idl
Normal file
11
Libraries/LibWeb/WebGL/Extensions/EXTColorBufferFloat.idl
Normal file
|
@ -0,0 +1,11 @@
|
|||
#import <WebGL/Types.idl>
|
||||
|
||||
// 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 {
|
||||
};
|
|
@ -15,6 +15,7 @@
|
|||
#include <LibWeb/Infra/Strings.h>
|
||||
#include <LibWeb/Painting/Paintable.h>
|
||||
#include <LibWeb/WebGL/EventNames.h>
|
||||
#include <LibWeb/WebGL/Extensions/EXTColorBufferFloat.h>
|
||||
#include <LibWeb/WebGL/Extensions/WebGLCompressedTextureS3tc.h>
|
||||
#include <LibWeb/WebGL/OpenGLContext.h>
|
||||
#include <LibWeb/WebGL/WebGL2RenderingContext.h>
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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<Extensions::EXTColorBufferFloat> m_ext_color_buffer_float_extension;
|
||||
GC::Ptr<Extensions::WebGLCompressedTextureS3tc> m_webgl_compressed_texture_s3tc_extension;
|
||||
|
||||
virtual void set_error(GLenum error) override;
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Add table
Reference in a new issue