mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-12-08 06:09:58 +00:00
LibWeb: Implement WebGL getParameter(COMPRESSED_TEXTURE_FORMATS)
This commit is contained in:
parent
bc3761b40d
commit
932a3328a3
Notes:
github-actions[bot]
2025-11-01 23:55:34 +00:00
Author: https://github.com/cqundefine
Commit: 932a3328a3
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/6663
Reviewed-by: https://github.com/gmta ✅
7 changed files with 50 additions and 0 deletions
|
|
@ -175,6 +175,11 @@ JS::Object* WebGL2RenderingContext::get_extension(String const& name)
|
|||
if (name.equals_ignoring_ascii_case("WEBGL_compressed_texture_s3tc"sv)) {
|
||||
if (!m_webgl_compressed_texture_s3tc_extension) {
|
||||
m_webgl_compressed_texture_s3tc_extension = MUST(Extensions::WebGLCompressedTextureS3tc::create(realm(), this));
|
||||
|
||||
m_enabled_compressed_texture_formats.append(GL_COMPRESSED_RGB_S3TC_DXT1_EXT);
|
||||
m_enabled_compressed_texture_formats.append(GL_COMPRESSED_RGBA_S3TC_DXT1_EXT);
|
||||
m_enabled_compressed_texture_formats.append(GL_COMPRESSED_RGBA_S3TC_DXT3_EXT);
|
||||
m_enabled_compressed_texture_formats.append(GL_COMPRESSED_RGBA_S3TC_DXT5_EXT);
|
||||
}
|
||||
|
||||
VERIFY(m_webgl_compressed_texture_s3tc_extension);
|
||||
|
|
@ -184,6 +189,11 @@ JS::Object* WebGL2RenderingContext::get_extension(String const& name)
|
|||
if (name.equals_ignoring_ascii_case("WEBGL_compressed_texture_s3tc_srgb"sv)) {
|
||||
if (!m_webgl_compressed_texture_s3tc_srgb_extension) {
|
||||
m_webgl_compressed_texture_s3tc_srgb_extension = MUST(Extensions::WebGLCompressedTextureS3tcSrgb::create(realm(), this));
|
||||
|
||||
m_enabled_compressed_texture_formats.append(GL_COMPRESSED_SRGB_S3TC_DXT1_EXT);
|
||||
m_enabled_compressed_texture_formats.append(GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT);
|
||||
m_enabled_compressed_texture_formats.append(GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT);
|
||||
m_enabled_compressed_texture_formats.append(GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT);
|
||||
}
|
||||
|
||||
VERIFY(m_webgl_compressed_texture_s3tc_srgb_extension);
|
||||
|
|
@ -246,4 +256,9 @@ bool WebGL2RenderingContext::ext_texture_filter_anisotropic_extension_enabled()
|
|||
return !!m_ext_texture_filter_anisotropic;
|
||||
}
|
||||
|
||||
ReadonlySpan<WebIDL::UnsignedLong> WebGL2RenderingContext::enabled_compressed_texture_formats() const
|
||||
{
|
||||
return m_enabled_compressed_texture_formats;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -52,6 +52,7 @@ public:
|
|||
WebIDL::Long drawing_buffer_height() const;
|
||||
|
||||
virtual bool ext_texture_filter_anisotropic_extension_enabled() const override;
|
||||
virtual ReadonlySpan<WebIDL::UnsignedLong> enabled_compressed_texture_formats() const override;
|
||||
|
||||
private:
|
||||
virtual void initialize(JS::Realm&) override;
|
||||
|
|
@ -82,6 +83,8 @@ private:
|
|||
|
||||
GLenum m_error { 0 };
|
||||
|
||||
Vector<WebIDL::UnsignedLong> m_enabled_compressed_texture_formats;
|
||||
|
||||
// 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;
|
||||
|
|
|
|||
|
|
@ -2929,6 +2929,12 @@ JS::Value WebGL2RenderingContextImpl::get_parameter(WebIDL::UnsignedLong pname)
|
|||
glGetBooleanvRobustANGLE(GL_TRANSFORM_FEEDBACK_PAUSED, 1, nullptr, &result);
|
||||
return JS::Value(result == GL_TRUE);
|
||||
}
|
||||
case COMPRESSED_TEXTURE_FORMATS: {
|
||||
auto formats = enabled_compressed_texture_formats();
|
||||
auto byte_buffer = MUST(ByteBuffer::copy(formats.data(), formats.reinterpret<u8 const>().size()));
|
||||
auto array_buffer = JS::ArrayBuffer::create(m_realm, move(byte_buffer));
|
||||
return JS::Uint32Array::create(m_realm, formats.size(), array_buffer);
|
||||
}
|
||||
case UNPACK_FLIP_Y_WEBGL:
|
||||
return JS::Value(m_unpack_flip_y);
|
||||
case MAX_CLIENT_WAIT_TIMEOUT_WEBGL: {
|
||||
|
|
|
|||
|
|
@ -229,6 +229,11 @@ JS::Object* WebGLRenderingContext::get_extension(String const& name)
|
|||
if (name.equals_ignoring_ascii_case("WEBGL_compressed_texture_s3tc"sv)) {
|
||||
if (!m_webgl_compressed_texture_s3tc_extension) {
|
||||
m_webgl_compressed_texture_s3tc_extension = MUST(Extensions::WebGLCompressedTextureS3tc::create(realm(), this));
|
||||
|
||||
m_enabled_compressed_texture_formats.append(GL_COMPRESSED_RGB_S3TC_DXT1_EXT);
|
||||
m_enabled_compressed_texture_formats.append(GL_COMPRESSED_RGBA_S3TC_DXT1_EXT);
|
||||
m_enabled_compressed_texture_formats.append(GL_COMPRESSED_RGBA_S3TC_DXT3_EXT);
|
||||
m_enabled_compressed_texture_formats.append(GL_COMPRESSED_RGBA_S3TC_DXT5_EXT);
|
||||
}
|
||||
|
||||
VERIFY(m_webgl_compressed_texture_s3tc_extension);
|
||||
|
|
@ -238,6 +243,11 @@ JS::Object* WebGLRenderingContext::get_extension(String const& name)
|
|||
if (name.equals_ignoring_ascii_case("WEBGL_compressed_texture_s3tc_srgb"sv)) {
|
||||
if (!m_webgl_compressed_texture_s3tc_srgb_extension) {
|
||||
m_webgl_compressed_texture_s3tc_srgb_extension = MUST(Extensions::WebGLCompressedTextureS3tcSrgb::create(realm(), this));
|
||||
|
||||
m_enabled_compressed_texture_formats.append(GL_COMPRESSED_SRGB_S3TC_DXT1_EXT);
|
||||
m_enabled_compressed_texture_formats.append(GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT);
|
||||
m_enabled_compressed_texture_formats.append(GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT);
|
||||
m_enabled_compressed_texture_formats.append(GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT);
|
||||
}
|
||||
|
||||
VERIFY(m_webgl_compressed_texture_s3tc_srgb_extension);
|
||||
|
|
@ -273,4 +283,9 @@ bool WebGLRenderingContext::ext_texture_filter_anisotropic_extension_enabled() c
|
|||
return !!m_ext_texture_filter_anisotropic;
|
||||
}
|
||||
|
||||
ReadonlySpan<WebIDL::UnsignedLong> WebGLRenderingContext::enabled_compressed_texture_formats() const
|
||||
{
|
||||
return m_enabled_compressed_texture_formats;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -51,6 +51,7 @@ public:
|
|||
WebIDL::Long drawing_buffer_height() const;
|
||||
|
||||
virtual bool ext_texture_filter_anisotropic_extension_enabled() const override;
|
||||
virtual ReadonlySpan<WebIDL::UnsignedLong> enabled_compressed_texture_formats() const override;
|
||||
|
||||
private:
|
||||
virtual void initialize(JS::Realm&) override;
|
||||
|
|
@ -81,6 +82,8 @@ private:
|
|||
|
||||
GLenum m_error { 0 };
|
||||
|
||||
Vector<WebIDL::UnsignedLong> m_enabled_compressed_texture_formats;
|
||||
|
||||
// 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::ANGLEInstancedArrays> m_angle_instanced_arrays_extension;
|
||||
|
|
|
|||
|
|
@ -14,6 +14,7 @@
|
|||
|
||||
namespace Web::WebGL {
|
||||
|
||||
static constexpr int COMPRESSED_TEXTURE_FORMATS = 0x86A3;
|
||||
static constexpr int UNPACK_FLIP_Y_WEBGL = 0x9240;
|
||||
static constexpr int MAX_CLIENT_WAIT_TIMEOUT_WEBGL = 0x9247;
|
||||
|
||||
|
|
@ -32,6 +33,7 @@ public:
|
|||
virtual void visit_edges(JS::Cell::Visitor&) = 0;
|
||||
virtual OpenGLContext& context() = 0;
|
||||
virtual bool ext_texture_filter_anisotropic_extension_enabled() const = 0;
|
||||
virtual ReadonlySpan<WebIDL::UnsignedLong> enabled_compressed_texture_formats() const = 0;
|
||||
|
||||
template<typename T>
|
||||
static ErrorOr<Span<T>> get_offset_span(Span<T> src_span, WebIDL::UnsignedLongLong src_offset, WebIDL::UnsignedLong src_length_override = 0)
|
||||
|
|
|
|||
|
|
@ -1501,6 +1501,12 @@ JS::Value WebGLRenderingContextImpl::get_parameter(WebIDL::UnsignedLong pname)
|
|||
set_error(GL_INVALID_ENUM);
|
||||
return JS::js_null();
|
||||
}
|
||||
case COMPRESSED_TEXTURE_FORMATS: {
|
||||
auto formats = enabled_compressed_texture_formats();
|
||||
auto byte_buffer = MUST(ByteBuffer::copy(formats.data(), formats.reinterpret<u8 const>().size()));
|
||||
auto array_buffer = JS::ArrayBuffer::create(m_realm, move(byte_buffer));
|
||||
return JS::Uint32Array::create(m_realm, formats.size(), array_buffer);
|
||||
}
|
||||
case UNPACK_FLIP_Y_WEBGL:
|
||||
return JS::Value(m_unpack_flip_y);
|
||||
default:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue