mirror of
https://github.com/LadybirdBrowser/ladybird
synced 2026-04-28 10:37:17 +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 ✅
@@ -37,12 +37,19 @@ void WebGL2RenderingContextOverloads::buffer_data(WebIDL::UnsignedLong target, W
|
||||
glBufferData(target, size, 0, usage);
|
||||
}
|
||||
|
||||
void WebGL2RenderingContextOverloads::buffer_data(WebIDL::UnsignedLong target, GC::Root<WebIDL::BufferSource> src_data, WebIDL::UnsignedLong usage)
|
||||
void WebGL2RenderingContextOverloads::buffer_data(WebIDL::UnsignedLong target, Optional<GC::Root<WebIDL::BufferSource>> src_data, WebIDL::UnsignedLong usage)
|
||||
{
|
||||
m_context->make_current();
|
||||
|
||||
auto data = MUST(get_offset_span<u8 const>(*src_data, /* src_offset= */ 0));
|
||||
glBufferData(target, data.size(), data.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 (!src_data.has_value()) {
|
||||
set_error(GL_INVALID_VALUE);
|
||||
return;
|
||||
}
|
||||
|
||||
auto data = MUST(get_offset_span<u8 const>(*src_data.value(), /* src_offset= */ 0));
|
||||
glBufferData(target, static_cast<GLsizeiptr>(data.size()), data.data(), usage);
|
||||
}
|
||||
|
||||
void WebGL2RenderingContextOverloads::buffer_sub_data(WebIDL::UnsignedLong target, WebIDL::LongLong dst_byte_offset, GC::Root<WebIDL::BufferSource> src_data)
|
||||
|
||||
Reference in New Issue
Block a user