mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-07-31 21:29:06 +00:00
LibWeb/WebGL: Implement WEBGL_compressed_texture_s3tc extension
This commit is contained in:
parent
484008d440
commit
958938655d
Notes:
github-actions[bot]
2025-02-09 00:01:44 +00:00
Author: https://github.com/Lubrsi
Commit: 958938655d
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/3385
11 changed files with 137 additions and 2 deletions
|
@ -0,0 +1,43 @@
|
|||
/*
|
||||
* Copyright (c) 2025, Luke Wilde <luke@ladybird.org>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#include <LibJS/Runtime/Realm.h>
|
||||
#include <LibWeb/Bindings/Intrinsics.h>
|
||||
#include <LibWeb/Bindings/WebGLCompressedTextureS3tcPrototype.h>
|
||||
#include <LibWeb/WebGL/Extensions/WebGLCompressedTextureS3tc.h>
|
||||
#include <LibWeb/WebGL/OpenGLContext.h>
|
||||
|
||||
namespace Web::WebGL::Extensions {
|
||||
|
||||
GC_DEFINE_ALLOCATOR(WebGLCompressedTextureS3tc);
|
||||
|
||||
JS::ThrowCompletionOr<GC::Ptr<WebGLCompressedTextureS3tc>> WebGLCompressedTextureS3tc::create(JS::Realm& realm, WebGLRenderingContextBase* context)
|
||||
{
|
||||
return realm.create<WebGLCompressedTextureS3tc>(realm, context);
|
||||
}
|
||||
|
||||
WebGLCompressedTextureS3tc::WebGLCompressedTextureS3tc(JS::Realm& realm, WebGLRenderingContextBase* context)
|
||||
: PlatformObject(realm)
|
||||
, m_context(context)
|
||||
{
|
||||
m_context->context().request_extension("GL_EXT_texture_compression_dxt1");
|
||||
m_context->context().request_extension("GL_ANGLE_texture_compression_dxt3");
|
||||
m_context->context().request_extension("GL_ANGLE_texture_compression_dxt5");
|
||||
}
|
||||
|
||||
void WebGLCompressedTextureS3tc::initialize(JS::Realm& realm)
|
||||
{
|
||||
Base::initialize(realm);
|
||||
WEB_SET_PROTOTYPE_FOR_INTERFACE(WebGLCompressedTextureS3tc);
|
||||
}
|
||||
|
||||
void WebGLCompressedTextureS3tc::visit_edges(Visitor& visitor)
|
||||
{
|
||||
Base::visit_edges(visitor);
|
||||
visitor.visit(m_context->gc_cell());
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,33 @@
|
|||
/*
|
||||
* 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>
|
||||
#include <LibWeb/WebGL/WebGLRenderingContextBase.h>
|
||||
|
||||
namespace Web::WebGL::Extensions {
|
||||
|
||||
class WebGLCompressedTextureS3tc : public Bindings::PlatformObject {
|
||||
WEB_PLATFORM_OBJECT(WebGLCompressedTextureS3tc, Bindings::PlatformObject);
|
||||
GC_DECLARE_ALLOCATOR(WebGLCompressedTextureS3tc);
|
||||
|
||||
public:
|
||||
static JS::ThrowCompletionOr<GC::Ptr<WebGLCompressedTextureS3tc>> create(JS::Realm&, WebGLRenderingContextBase*);
|
||||
|
||||
protected:
|
||||
void initialize(JS::Realm&) override;
|
||||
void visit_edges(Visitor&) override;
|
||||
|
||||
private:
|
||||
WebGLCompressedTextureS3tc(JS::Realm&, WebGLRenderingContextBase*);
|
||||
|
||||
// FIXME: It should be GC::Ptr instead of raw pointer, but we need to make WebGLRenderingContextBase inherit from PlatformObject first.
|
||||
WebGLRenderingContextBase* m_context;
|
||||
};
|
||||
|
||||
}
|
|
@ -0,0 +1,16 @@
|
|||
#import <WebGL/Types.idl>
|
||||
|
||||
// https://registry.khronos.org/webgl/extensions/WEBGL_compressed_texture_s3tc/
|
||||
// NOTE: Original WEBGL_compressed_texture_s3tc 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 WebGLCompressedTextureS3tc {
|
||||
// Compressed Texture Formats
|
||||
const GLenum COMPRESSED_RGB_S3TC_DXT1_EXT = 0x83F0;
|
||||
const GLenum COMPRESSED_RGBA_S3TC_DXT1_EXT = 0x83F1;
|
||||
const GLenum COMPRESSED_RGBA_S3TC_DXT3_EXT = 0x83F2;
|
||||
const GLenum COMPRESSED_RGBA_S3TC_DXT5_EXT = 0x83F3;
|
||||
};
|
Loading…
Add table
Add a link
Reference in a new issue