mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-10-24 00:49:46 +00:00
LibWeb/WebGL: Define Uint32List exactly like in the spec
Same fix as d54cab60 but applied for Uint32List.
This commit is contained in:
parent
c75a8fab3b
commit
ffc05a9ca9
Notes:
github-actions[bot]
2025-09-30 16:36:42 +00:00
Author: https://github.com/kalenikaliaksandr
Commit: ffc05a9ca9
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/6354
Reviewed-by: https://github.com/gmta ✅
5 changed files with 17 additions and 23 deletions
|
|
@ -14,8 +14,7 @@
|
||||||
#import <WebGL/WebGLUniformLocation.idl>
|
#import <WebGL/WebGLUniformLocation.idl>
|
||||||
#import <WebGL/WebGLVertexArrayObject.idl>
|
#import <WebGL/WebGLVertexArrayObject.idl>
|
||||||
|
|
||||||
// FIXME: BufferSource should be a Uint32Array
|
typedef (Uint32Array or sequence<GLuint>) Uint32List;
|
||||||
typedef (BufferSource or sequence<GLuint>) Uint32List;
|
|
||||||
|
|
||||||
// https://registry.khronos.org/webgl/specs/latest/2.0/#3.7
|
// https://registry.khronos.org/webgl/specs/latest/2.0/#3.7
|
||||||
interface mixin WebGL2RenderingContextBase {
|
interface mixin WebGL2RenderingContextBase {
|
||||||
|
|
|
||||||
|
|
@ -484,36 +484,22 @@ void WebGL2RenderingContextImpl::clear_bufferiv(WebIDL::UnsignedLong buffer, Web
|
||||||
needs_to_present();
|
needs_to_present();
|
||||||
}
|
}
|
||||||
|
|
||||||
void WebGL2RenderingContextImpl::clear_bufferuiv(WebIDL::UnsignedLong buffer, WebIDL::Long drawbuffer, Variant<GC::Root<WebIDL::BufferSource>, Vector<WebIDL::UnsignedLong>> values, WebIDL::UnsignedLongLong src_offset)
|
void WebGL2RenderingContextImpl::clear_bufferuiv(WebIDL::UnsignedLong buffer, WebIDL::Long drawbuffer, Uint32List values, WebIDL::UnsignedLongLong src_offset)
|
||||||
{
|
{
|
||||||
m_context->make_current();
|
m_context->make_current();
|
||||||
m_context->notify_content_will_change();
|
m_context->notify_content_will_change();
|
||||||
|
|
||||||
u32 const* data = nullptr;
|
auto span = span_from_uint32_list(values);
|
||||||
size_t count = 0;
|
|
||||||
if (values.has<Vector<u32>>()) {
|
|
||||||
auto& vector = values.get<Vector<u32>>();
|
|
||||||
data = vector.data();
|
|
||||||
count = vector.size();
|
|
||||||
} else if (values.has<GC::Root<WebIDL::BufferSource>>()) {
|
|
||||||
auto& typed_array_base = static_cast<JS::TypedArrayBase&>(*values.get<GC::Root<WebIDL::BufferSource>>()->raw_object());
|
|
||||||
auto& typed_array = as<JS::Uint32Array>(typed_array_base);
|
|
||||||
data = typed_array.data().data();
|
|
||||||
count = typed_array.array_length().length();
|
|
||||||
} else {
|
|
||||||
VERIFY_NOT_REACHED();
|
|
||||||
}
|
|
||||||
|
|
||||||
switch (buffer) {
|
switch (buffer) {
|
||||||
case GL_COLOR:
|
case GL_COLOR:
|
||||||
if (src_offset + 4 > count) {
|
if (src_offset + 4 > span.size()) {
|
||||||
set_error(GL_INVALID_VALUE);
|
set_error(GL_INVALID_VALUE);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case GL_DEPTH:
|
case GL_DEPTH:
|
||||||
case GL_STENCIL:
|
case GL_STENCIL:
|
||||||
if (src_offset + 1 > count) {
|
if (src_offset + 1 > span.size()) {
|
||||||
set_error(GL_INVALID_VALUE);
|
set_error(GL_INVALID_VALUE);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
@ -524,8 +510,8 @@ void WebGL2RenderingContextImpl::clear_bufferuiv(WebIDL::UnsignedLong buffer, We
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
data += src_offset;
|
span = span.slice(src_offset);
|
||||||
glClearBufferuiv(buffer, drawbuffer, data);
|
glClearBufferuiv(buffer, drawbuffer, span.data());
|
||||||
needs_to_present();
|
needs_to_present();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -50,7 +50,7 @@ public:
|
||||||
void draw_buffers(Vector<WebIDL::UnsignedLong> buffers);
|
void draw_buffers(Vector<WebIDL::UnsignedLong> buffers);
|
||||||
void clear_bufferfv(WebIDL::UnsignedLong buffer, WebIDL::Long drawbuffer, Float32List values, WebIDL::UnsignedLongLong src_offset);
|
void clear_bufferfv(WebIDL::UnsignedLong buffer, WebIDL::Long drawbuffer, Float32List values, WebIDL::UnsignedLongLong src_offset);
|
||||||
void clear_bufferiv(WebIDL::UnsignedLong buffer, WebIDL::Long drawbuffer, Int32List values, WebIDL::UnsignedLongLong src_offset);
|
void clear_bufferiv(WebIDL::UnsignedLong buffer, WebIDL::Long drawbuffer, Int32List values, WebIDL::UnsignedLongLong src_offset);
|
||||||
void clear_bufferuiv(WebIDL::UnsignedLong buffer, WebIDL::Long drawbuffer, Variant<GC::Root<WebIDL::BufferSource>, Vector<WebIDL::UnsignedLong>> values, WebIDL::UnsignedLongLong src_offset);
|
void clear_bufferuiv(WebIDL::UnsignedLong buffer, WebIDL::Long drawbuffer, Uint32List values, WebIDL::UnsignedLongLong src_offset);
|
||||||
void clear_bufferfi(WebIDL::UnsignedLong buffer, WebIDL::Long drawbuffer, float depth, WebIDL::Long stencil);
|
void clear_bufferfi(WebIDL::UnsignedLong buffer, WebIDL::Long drawbuffer, float depth, WebIDL::Long stencil);
|
||||||
GC::Root<WebGLSampler> create_sampler();
|
GC::Root<WebGLSampler> create_sampler();
|
||||||
void delete_sampler(GC::Root<WebGLSampler> sampler);
|
void delete_sampler(GC::Root<WebGLSampler> sampler);
|
||||||
|
|
|
||||||
|
|
@ -21,6 +21,7 @@ class WebGLRenderingContextBase {
|
||||||
public:
|
public:
|
||||||
using Float32List = Variant<GC::Root<JS::Float32Array>, Vector<float>>;
|
using Float32List = Variant<GC::Root<JS::Float32Array>, Vector<float>>;
|
||||||
using Int32List = Variant<GC::Root<JS::Int32Array>, Vector<WebIDL::Long>>;
|
using Int32List = Variant<GC::Root<JS::Int32Array>, Vector<WebIDL::Long>>;
|
||||||
|
using Uint32List = Variant<GC::Root<JS::Uint32Array>, Vector<WebIDL::UnsignedLong>>;
|
||||||
|
|
||||||
virtual GC::Cell const* gc_cell() const = 0;
|
virtual GC::Cell const* gc_cell() const = 0;
|
||||||
virtual void visit_edges(JS::Cell::Visitor&) = 0;
|
virtual void visit_edges(JS::Cell::Visitor&) = 0;
|
||||||
|
|
@ -39,6 +40,13 @@ public:
|
||||||
return int32_list.get<Vector<int>>();
|
return int32_list.get<Vector<int>>();
|
||||||
return int32_list.get<GC::Root<JS::Int32Array>>()->data();
|
return int32_list.get<GC::Root<JS::Int32Array>>()->data();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static Span<u32> span_from_uint32_list(Uint32List& int32_list)
|
||||||
|
{
|
||||||
|
if (int32_list.has<Vector<u32>>())
|
||||||
|
return int32_list.get<Vector<u32>>();
|
||||||
|
return int32_list.get<GC::Root<JS::Uint32Array>>()->data();
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -183,6 +183,7 @@ static bool is_javascript_builtin(Type const& type)
|
||||||
"Float64Array"sv,
|
"Float64Array"sv,
|
||||||
"Int32Array"sv,
|
"Int32Array"sv,
|
||||||
"Uint8Array"sv,
|
"Uint8Array"sv,
|
||||||
|
"Uint32Array"sv,
|
||||||
"Uint8ClampedArray"sv,
|
"Uint8ClampedArray"sv,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue