mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-12-07 21:59:54 +00:00
LibWeb/WebGL2: Implement the EXT_texture_norm16 extension
This commit is contained in:
parent
93d3ebfd59
commit
ddf60ebe9e
Notes:
github-actions[bot]
2025-10-20 13:34:51 +00:00
Author: https://github.com/Lubrsi
Commit: ddf60ebe9e
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/6521
Reviewed-by: https://github.com/gmta ✅
8 changed files with 107 additions and 0 deletions
|
|
@ -1024,6 +1024,7 @@ set(SOURCES
|
|||
WebGL/Extensions/EXTBlendMinMax.cpp
|
||||
WebGL/Extensions/EXTColorBufferFloat.cpp
|
||||
WebGL/Extensions/EXTRenderSnorm.cpp
|
||||
WebGL/Extensions/EXTTextureNorm16.cpp
|
||||
WebGL/Extensions/OESVertexArrayObject.cpp
|
||||
WebGL/Extensions/WebGLCompressedTextureS3tc.cpp
|
||||
WebGL/Extensions/WebGLDrawBuffers.cpp
|
||||
|
|
|
|||
|
|
@ -1225,6 +1225,7 @@ class ANGLEInstancedArrays;
|
|||
class EXTBlendMinMax;
|
||||
class EXTColorBufferFloat;
|
||||
class EXTRenderSnorm;
|
||||
class EXTTextureNorm16;
|
||||
class OESVertexArrayObject;
|
||||
class WebGLCompressedTextureS3tc;
|
||||
class WebGLDrawBuffers;
|
||||
|
|
|
|||
42
Libraries/LibWeb/WebGL/Extensions/EXTTextureNorm16.cpp
Normal file
42
Libraries/LibWeb/WebGL/Extensions/EXTTextureNorm16.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/EXTTextureNorm16Prototype.h>
|
||||
#include <LibWeb/Bindings/Intrinsics.h>
|
||||
#include <LibWeb/WebGL/Extensions/EXTTextureNorm16.h>
|
||||
#include <LibWeb/WebGL/OpenGLContext.h>
|
||||
#include <LibWeb/WebGL/WebGL2RenderingContext.h>
|
||||
|
||||
namespace Web::WebGL::Extensions {
|
||||
|
||||
GC_DEFINE_ALLOCATOR(EXTTextureNorm16);
|
||||
|
||||
JS::ThrowCompletionOr<GC::Ptr<EXTTextureNorm16>> EXTTextureNorm16::create(JS::Realm& realm, GC::Ref<WebGL2RenderingContext> context)
|
||||
{
|
||||
return realm.create<EXTTextureNorm16>(realm, context);
|
||||
}
|
||||
|
||||
EXTTextureNorm16::EXTTextureNorm16(JS::Realm& realm, GC::Ref<WebGL2RenderingContext> context)
|
||||
: PlatformObject(realm)
|
||||
, m_context(context)
|
||||
{
|
||||
m_context->context().request_extension("GL_EXT_texture_norm16");
|
||||
}
|
||||
|
||||
void EXTTextureNorm16::initialize(JS::Realm& realm)
|
||||
{
|
||||
WEB_SET_PROTOTYPE_FOR_INTERFACE(EXTTextureNorm16);
|
||||
Base::initialize(realm);
|
||||
}
|
||||
|
||||
void EXTTextureNorm16::visit_edges(Visitor& visitor)
|
||||
{
|
||||
Base::visit_edges(visitor);
|
||||
visitor.visit(m_context);
|
||||
}
|
||||
|
||||
}
|
||||
31
Libraries/LibWeb/WebGL/Extensions/EXTTextureNorm16.h
Normal file
31
Libraries/LibWeb/WebGL/Extensions/EXTTextureNorm16.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 EXTTextureNorm16 : public Bindings::PlatformObject {
|
||||
WEB_PLATFORM_OBJECT(EXTTextureNorm16, Bindings::PlatformObject);
|
||||
GC_DECLARE_ALLOCATOR(EXTTextureNorm16);
|
||||
|
||||
public:
|
||||
static JS::ThrowCompletionOr<GC::Ptr<EXTTextureNorm16>> create(JS::Realm&, GC::Ref<WebGL2RenderingContext>);
|
||||
|
||||
protected:
|
||||
void initialize(JS::Realm&) override;
|
||||
void visit_edges(Visitor&) override;
|
||||
|
||||
private:
|
||||
EXTTextureNorm16(JS::Realm&, GC::Ref<WebGL2RenderingContext>);
|
||||
|
||||
GC::Ref<WebGL2RenderingContext> m_context;
|
||||
};
|
||||
|
||||
}
|
||||
19
Libraries/LibWeb/WebGL/Extensions/EXTTextureNorm16.idl
Normal file
19
Libraries/LibWeb/WebGL/Extensions/EXTTextureNorm16.idl
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
#import <WebGL/Types.idl>
|
||||
|
||||
// https://registry.khronos.org/webgl/extensions/EXT_texture_norm16/
|
||||
// NOTE: Original EXT_texture_norm16 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 EXTTextureNorm16 {
|
||||
const GLenum R16_EXT = 0x822A;
|
||||
const GLenum RG16_EXT = 0x822C;
|
||||
const GLenum RGB16_EXT = 0x8054;
|
||||
const GLenum RGBA16_EXT = 0x805B;
|
||||
const GLenum R16_SNORM_EXT = 0x8F98;
|
||||
const GLenum RG16_SNORM_EXT = 0x8F99;
|
||||
const GLenum RGB16_SNORM_EXT = 0x8F9A;
|
||||
const GLenum RGBA16_SNORM_EXT = 0x8F9B;
|
||||
};
|
||||
|
|
@ -17,6 +17,7 @@
|
|||
#include <LibWeb/WebGL/EventNames.h>
|
||||
#include <LibWeb/WebGL/Extensions/EXTColorBufferFloat.h>
|
||||
#include <LibWeb/WebGL/Extensions/EXTRenderSnorm.h>
|
||||
#include <LibWeb/WebGL/Extensions/EXTTextureNorm16.h>
|
||||
#include <LibWeb/WebGL/Extensions/WebGLCompressedTextureS3tc.h>
|
||||
#include <LibWeb/WebGL/OpenGLContext.h>
|
||||
#include <LibWeb/WebGL/WebGL2RenderingContext.h>
|
||||
|
|
@ -77,6 +78,7 @@ void WebGL2RenderingContext::visit_edges(Cell::Visitor& visitor)
|
|||
visitor.visit(m_canvas_element);
|
||||
visitor.visit(m_ext_color_buffer_float_extension);
|
||||
visitor.visit(m_ext_render_snorm);
|
||||
visitor.visit(m_ext_texture_norm16);
|
||||
visitor.visit(m_webgl_compressed_texture_s3tc_extension);
|
||||
}
|
||||
|
||||
|
|
@ -193,6 +195,15 @@ JS::Object* WebGL2RenderingContext::get_extension(String const& name)
|
|||
return m_ext_render_snorm;
|
||||
}
|
||||
|
||||
if (name.equals_ignoring_ascii_case("EXT_texture_norm16"sv)) {
|
||||
if (!m_ext_texture_norm16) {
|
||||
m_ext_texture_norm16 = MUST(Extensions::EXTTextureNorm16::create(realm(), *this));
|
||||
}
|
||||
|
||||
VERIFY(m_ext_texture_norm16);
|
||||
return m_ext_texture_norm16;
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -84,6 +84,7 @@ private:
|
|||
// "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::EXTRenderSnorm> m_ext_render_snorm;
|
||||
GC::Ptr<Extensions::EXTTextureNorm16> m_ext_texture_norm16;
|
||||
GC::Ptr<Extensions::WebGLCompressedTextureS3tc> m_webgl_compressed_texture_s3tc_extension;
|
||||
|
||||
virtual void set_error(GLenum error) override;
|
||||
|
|
|
|||
|
|
@ -472,6 +472,7 @@ libweb_js_bindings(WebGL/Extensions/ANGLEInstancedArrays)
|
|||
libweb_js_bindings(WebGL/Extensions/EXTBlendMinMax)
|
||||
libweb_js_bindings(WebGL/Extensions/EXTColorBufferFloat)
|
||||
libweb_js_bindings(WebGL/Extensions/EXTRenderSnorm)
|
||||
libweb_js_bindings(WebGL/Extensions/EXTTextureNorm16)
|
||||
libweb_js_bindings(WebGL/Extensions/OESVertexArrayObject)
|
||||
libweb_js_bindings(WebGL/Extensions/WebGLCompressedTextureS3tc)
|
||||
libweb_js_bindings(WebGL/Extensions/WebGLDrawBuffers)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue