mirror of
https://github.com/zebrajr/ladybird.git
synced 2025-12-06 00:19:53 +01:00
LibWeb/WebGL: Implement texImage2D()
This commit is contained in:
parent
3c2ac309ca
commit
64fec8b2de
|
|
@ -15,7 +15,7 @@ interface mixin WebGLRenderingContextOverloads {
|
|||
|
||||
[FIXME] undefined readPixels(GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, [AllowShared] ArrayBufferView? pixels);
|
||||
|
||||
[FIXME] undefined texImage2D(GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, [AllowShared] ArrayBufferView? pixels);
|
||||
undefined texImage2D(GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, [AllowShared] ArrayBufferView? pixels);
|
||||
[FIXME] undefined texImage2D(GLenum target, GLint level, GLint internalformat, GLenum format, GLenum type, TexImageSource source); // May throw DOMException
|
||||
|
||||
[FIXME] undefined texSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, [AllowShared] ArrayBufferView? pixels);
|
||||
|
|
|
|||
|
|
@ -747,11 +747,26 @@ static void generate_to_cpp(SourceGenerator& generator, ParameterType& parameter
|
|||
|
||||
} else if (parameter.type->name() == "ArrayBufferView") {
|
||||
scoped_generator.append(R"~~~(
|
||||
if (!@js_name@@js_suffix@.is_object() || !(is<JS::TypedArrayBase>(@js_name@@js_suffix@.as_object()) || is<JS::DataView>(@js_name@@js_suffix@.as_object())))
|
||||
return vm.throw_completion<JS::TypeError>(JS::ErrorType::NotAnObjectOfType, "@parameter.type.name@");
|
||||
|
||||
auto @cpp_name@ = GC::make_root(realm.create<WebIDL::ArrayBufferView>(@js_name@@js_suffix@.as_object()));
|
||||
GC::Root<WebIDL::ArrayBufferView> @cpp_name@;
|
||||
)~~~");
|
||||
if (parameter.type->is_nullable()) {
|
||||
scoped_generator.append(R"~~~(
|
||||
if (!@js_name@@js_suffix@.is_null() && !@js_name@@js_suffix@.is_undefined()) {
|
||||
)~~~");
|
||||
}
|
||||
|
||||
scoped_generator.append(R"~~~(
|
||||
if (!@js_name@@js_suffix@.is_object() || !(is<JS::TypedArrayBase>(@js_name@@js_suffix@.as_object()) || is<JS::DataView>(@js_name@@js_suffix@.as_object())))
|
||||
return vm.throw_completion<JS::TypeError>(JS::ErrorType::NotAnObjectOfType, "@parameter.type.name@");
|
||||
|
||||
@cpp_name@ = GC::make_root(realm.create<WebIDL::ArrayBufferView>(@js_name@@js_suffix@.as_object()));
|
||||
)~~~");
|
||||
|
||||
if (parameter.type->is_nullable()) {
|
||||
scoped_generator.append(R"~~~(
|
||||
}
|
||||
)~~~");
|
||||
}
|
||||
if (optional) {
|
||||
scoped_generator.append(R"~~~(
|
||||
}
|
||||
|
|
|
|||
|
|
@ -263,6 +263,19 @@ public:
|
|||
continue;
|
||||
}
|
||||
|
||||
if (function.name == "texImage2D"sv && function.overload_index == 0) {
|
||||
function_impl_generator.append(R"~~~(
|
||||
void const* pixels_ptr = nullptr;
|
||||
if (pixels) {
|
||||
auto const& viewed_array_buffer = pixels->viewed_array_buffer();
|
||||
auto const& byte_buffer = viewed_array_buffer->buffer();
|
||||
pixels_ptr = byte_buffer.data();
|
||||
}
|
||||
glTexImage2D(target, level, internalformat, width, height, border, format, type, pixels_ptr);
|
||||
)~~~");
|
||||
continue;
|
||||
}
|
||||
|
||||
if (function.name == "getShaderParameter"sv) {
|
||||
function_impl_generator.append(R"~~~(
|
||||
GLint result = 0;
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user