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:
Luke Wilde 2025-03-05 17:13:52 +00:00 committed by Andreas Kling
commit 9ca25eed7f
Notes: github-actions[bot] 2025-03-06 12:00:25 +00:00
8 changed files with 99 additions and 0 deletions

View 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);
}
}

View 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;
};
}

View 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 {
};