mirror of
https://github.com/LadybirdBrowser/ladybird
synced 2026-04-26 01:35:08 +02:00
Meta: Support nullable BufferSource as Optional in IDL generator
This IDL change is needed for webaudio's WaveShaperNode, where a null BufferSource for a curve attribute results in a zero-length buffer. WebGL also has a nullable BufferSource arg in bufferData(...). But there, a null data/srcData value returns GL_INVALID_VALUE.
This commit is contained in:
committed by
Alexander Kalenik
parent
95955f40b1
commit
793a4eeb8e
Notes:
github-actions[bot]
2026-03-26 23:04:44 +00:00
Author: https://github.com/jonbgamble Commit: https://github.com/LadybirdBrowser/ladybird/commit/793a4eeb8e8 Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/7915 Reviewed-by: https://github.com/gmta Reviewed-by: https://github.com/kalenikaliaksandr ✅
@@ -34,12 +34,19 @@ void WebGLRenderingContextOverloads::buffer_data(WebIDL::UnsignedLong target, We
|
||||
glBufferData(target, size, 0, usage);
|
||||
}
|
||||
|
||||
void WebGLRenderingContextOverloads::buffer_data(WebIDL::UnsignedLong target, GC::Root<WebIDL::BufferSource> data, WebIDL::UnsignedLong usage)
|
||||
void WebGLRenderingContextOverloads::buffer_data(WebIDL::UnsignedLong target, Optional<GC::Root<WebIDL::BufferSource>> data, WebIDL::UnsignedLong usage)
|
||||
{
|
||||
m_context->make_current();
|
||||
|
||||
auto span = MUST(get_offset_span<u8 const>(*data, /* src_offset= */ 0));
|
||||
glBufferData(target, span.size(), span.data(), usage);
|
||||
// https://registry.khronos.org/webgl/specs/latest/1.0/#5.14.5
|
||||
// If the passed data is null then an INVALID_VALUE error is generated.
|
||||
if (!data.has_value()) {
|
||||
set_error(GL_INVALID_VALUE);
|
||||
return;
|
||||
}
|
||||
|
||||
auto span = MUST(get_offset_span<u8 const>(*data.value(), /* src_offset= */ 0));
|
||||
glBufferData(target, static_cast<GLsizeiptr>(span.size()), span.data(), usage);
|
||||
}
|
||||
|
||||
void WebGLRenderingContextOverloads::buffer_sub_data(WebIDL::UnsignedLong target, WebIDL::LongLong offset, GC::Root<WebIDL::BufferSource> data)
|
||||
|
||||
Reference in New Issue
Block a user