Canvas rendering is a major remaining path where WebContent directly owns GPU-facing drawing state. Back 2D and WebGL canvas contexts with remote Compositor transports, so WebContent talks to canvas surfaces through IPC while the Compositor owns the rasterization resources. This is a large step toward GPU sandboxing because canvas GPU work now lives behind the Compositor boundary. It also gives OffscreenCanvas the process-independent canvas plumbing that HTMLCanvasElement now uses, making worker-owned canvases possible without another WebContent-local rendering path.
62 lines
1.9 KiB
C++
62 lines
1.9 KiB
C++
/*
|
|
* Copyright (c) 2024, Aliaksandr Kalenik <kalenik.aliaksandr@gmail.com>
|
|
*
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
*/
|
|
|
|
#include <LibJS/Runtime/Realm.h>
|
|
#include <LibWeb/Bindings/ANGLEInstancedArrays.h>
|
|
#include <LibWeb/Bindings/Intrinsics.h>
|
|
#include <LibWeb/WebGL/Extensions/ANGLEInstancedArrays.h>
|
|
#include <LibWeb/WebGL/WebGLContextProxy.h>
|
|
#include <LibWeb/WebGL/WebGLRenderingContextBase.h>
|
|
|
|
#include <GLES2/gl2.h>
|
|
#include <GLES2/gl2ext.h>
|
|
|
|
namespace Web::WebGL {
|
|
|
|
GC_DEFINE_ALLOCATOR(ANGLEInstancedArrays);
|
|
|
|
JS::ThrowCompletionOr<GC::Ref<JS::Object>> ANGLEInstancedArrays::create(JS::Realm& realm, GC::Ref<WebGLRenderingContextBase> context)
|
|
{
|
|
return realm.create<ANGLEInstancedArrays>(realm, context);
|
|
}
|
|
|
|
ANGLEInstancedArrays::ANGLEInstancedArrays(JS::Realm& realm, GC::Ref<WebGLRenderingContextBase> context)
|
|
: PlatformObject(realm)
|
|
, m_context(context)
|
|
{
|
|
}
|
|
|
|
void ANGLEInstancedArrays::vertex_attrib_divisor_angle(GLuint index, GLuint divisor)
|
|
{
|
|
m_context->context().make_current();
|
|
m_context->context().vertex_attrib_divisor_angle(index, divisor);
|
|
}
|
|
|
|
void ANGLEInstancedArrays::draw_arrays_instanced_angle(GLenum mode, GLint first, GLsizei count, GLsizei primcount)
|
|
{
|
|
m_context->context().make_current();
|
|
m_context->context().draw_arrays_instanced_angle(mode, first, count, primcount);
|
|
}
|
|
|
|
void ANGLEInstancedArrays::draw_elements_instanced_angle(GLenum mode, GLsizei count, GLenum type, GLintptr offset, GLsizei primcount)
|
|
{
|
|
m_context->context().make_current();
|
|
m_context->context().draw_elements_instanced_angle(mode, count, type, reinterpret_cast<void*>(offset), primcount);
|
|
}
|
|
|
|
void ANGLEInstancedArrays::initialize(JS::Realm& realm)
|
|
{
|
|
WEB_SET_PROTOTYPE_FOR_INTERFACE(ANGLEInstancedArrays);
|
|
Base::initialize(realm);
|
|
}
|
|
|
|
void ANGLEInstancedArrays::visit_edges(Visitor& visitor)
|
|
{
|
|
Base::visit_edges(visitor);
|
|
visitor.visit(m_context);
|
|
}
|
|
|
|
}
|