From 2b5e54e995c623ac29b86e2fc94206557c6f1bf6 Mon Sep 17 00:00:00 2001 From: Andrew Kaster Date: Thu, 5 Dec 2024 19:12:40 -0700 Subject: [PATCH] LibWeb/WebGL: Add stub class for WebGLSampler This is a WebGL 2.0 class --- Libraries/LibWeb/CMakeLists.txt | 1 + Libraries/LibWeb/WebGL/WebGLSampler.cpp | 34 +++++++++++++++++++ Libraries/LibWeb/WebGL/WebGLSampler.h | 29 ++++++++++++++++ Libraries/LibWeb/WebGL/WebGLSampler.idl | 6 ++++ Libraries/LibWeb/idl_files.cmake | 1 + .../Text/expected/all-window-properties.txt | 1 + 6 files changed, 72 insertions(+) create mode 100644 Libraries/LibWeb/WebGL/WebGLSampler.cpp create mode 100644 Libraries/LibWeb/WebGL/WebGLSampler.h create mode 100644 Libraries/LibWeb/WebGL/WebGLSampler.idl diff --git a/Libraries/LibWeb/CMakeLists.txt b/Libraries/LibWeb/CMakeLists.txt index a737bdb3c7c..659a7186fd6 100644 --- a/Libraries/LibWeb/CMakeLists.txt +++ b/Libraries/LibWeb/CMakeLists.txt @@ -814,6 +814,7 @@ set(SOURCES WebGL/WebGLQuery.cpp WebGL/WebGLRenderbuffer.cpp WebGL/WebGLRenderingContext.cpp + WebGL/WebGLSampler.cpp WebGL/WebGLShader.cpp WebGL/WebGLShaderPrecisionFormat.cpp WebGL/WebGLTexture.cpp diff --git a/Libraries/LibWeb/WebGL/WebGLSampler.cpp b/Libraries/LibWeb/WebGL/WebGLSampler.cpp new file mode 100644 index 00000000000..cf4ac154b72 --- /dev/null +++ b/Libraries/LibWeb/WebGL/WebGLSampler.cpp @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2024, Andrew Kaster + * + * SPDX-License-Identifier: BSD-2-Clause + */ + +#include +#include +#include +#include + +namespace Web::WebGL { + +GC_DEFINE_ALLOCATOR(WebGLSampler); + +GC::Ref WebGLSampler::create(JS::Realm& realm, GLuint handle) +{ + return realm.create(realm, handle); +} + +WebGLSampler::WebGLSampler(JS::Realm& realm, GLuint handle) + : WebGLObject(realm, handle) +{ +} + +WebGLSampler::~WebGLSampler() = default; + +void WebGLSampler::initialize(JS::Realm& realm) +{ + Base::initialize(realm); + WEB_SET_PROTOTYPE_FOR_INTERFACE(WebGLSampler); +} + +} diff --git a/Libraries/LibWeb/WebGL/WebGLSampler.h b/Libraries/LibWeb/WebGL/WebGLSampler.h new file mode 100644 index 00000000000..4d47534ec61 --- /dev/null +++ b/Libraries/LibWeb/WebGL/WebGLSampler.h @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2024, Andrew Kaster + * + * SPDX-License-Identifier: BSD-2-Clause + */ + +#pragma once + +#include +#include + +namespace Web::WebGL { + +class WebGLSampler : public WebGLObject { + WEB_PLATFORM_OBJECT(WebGLSampler, WebGLObject); + GC_DECLARE_ALLOCATOR(WebGLSampler); + +public: + static GC::Ref create(JS::Realm& realm, GLuint handle); + + virtual ~WebGLSampler() override; + +protected: + explicit WebGLSampler(JS::Realm&, GLuint handle); + + virtual void initialize(JS::Realm&) override; +}; + +} diff --git a/Libraries/LibWeb/WebGL/WebGLSampler.idl b/Libraries/LibWeb/WebGL/WebGLSampler.idl new file mode 100644 index 00000000000..7fb4e421c72 --- /dev/null +++ b/Libraries/LibWeb/WebGL/WebGLSampler.idl @@ -0,0 +1,6 @@ +#import + +// https://registry.khronos.org/webgl/specs/latest/2.0/#3.3 +[Exposed=(Window,Worker)] +interface WebGLSampler : WebGLObject { +}; diff --git a/Libraries/LibWeb/idl_files.cmake b/Libraries/LibWeb/idl_files.cmake index ca17331ebfe..bf44c9e8ade 100644 --- a/Libraries/LibWeb/idl_files.cmake +++ b/Libraries/LibWeb/idl_files.cmake @@ -378,6 +378,7 @@ libweb_js_bindings(WebGL/WebGLProgram) libweb_js_bindings(WebGL/WebGLQuery) libweb_js_bindings(WebGL/WebGLRenderbuffer) libweb_js_bindings(WebGL/WebGLRenderingContext) +libweb_js_bindings(WebGL/WebGLSampler) libweb_js_bindings(WebGL/WebGLShader) libweb_js_bindings(WebGL/WebGLShaderPrecisionFormat) libweb_js_bindings(WebGL/WebGLTexture) diff --git a/Tests/LibWeb/Text/expected/all-window-properties.txt b/Tests/LibWeb/Text/expected/all-window-properties.txt index d6eaa98f3a9..2b13aa60fbe 100644 --- a/Tests/LibWeb/Text/expected/all-window-properties.txt +++ b/Tests/LibWeb/Text/expected/all-window-properties.txt @@ -407,6 +407,7 @@ WebGLProgram WebGLQuery WebGLRenderbuffer WebGLRenderingContext +WebGLSampler WebGLShader WebGLShaderPrecisionFormat WebGLTexture