/* * Copyright (c) 2024-2025, Aliaksandr Kalenik * * SPDX-License-Identifier: BSD-2-Clause */ #pragma once #include #include #include namespace Web::WebGL { // NOTE: This is the Variant created by the IDL wrapper generator, and needs to be updated accordingly. using TexImageSource = Variant, GC::Root, GC::Root, GC::Root, GC::Root, GC::Root>; // FIXME: This object should inherit from Bindings::PlatformObject and implement the WebGLRenderingContextBase IDL interface. // We should make WebGL code generator to produce implementation for this interface. class WebGLRenderingContextBase { public: using Float32List = Variant, Vector>; using Int32List = Variant, Vector>; using Uint32List = Variant, Vector>; virtual GC::Cell const* gc_cell() const = 0; virtual void visit_edges(JS::Cell::Visitor&) = 0; virtual OpenGLContext& context() = 0; static Span span_from_float32_list(Float32List& float32_list) { if (float32_list.has>()) return float32_list.get>(); return float32_list.get>()->data(); } static Span span_from_int32_list(Int32List& int32_list) { if (int32_list.has>()) return int32_list.get>(); return int32_list.get>()->data(); } static Span span_from_uint32_list(Uint32List& int32_list) { if (int32_list.has>()) return int32_list.get>(); return int32_list.get>()->data(); } struct ConvertedTexture { ByteBuffer buffer; int width { 0 }; int height { 0 }; }; static Optional read_and_pixel_convert_texture_image_source(TexImageSource const& source, WebIDL::UnsignedLong format, WebIDL::UnsignedLong type, Optional destination_width = OptionalNone {}, Optional destination_height = OptionalNone {}); }; }