From e6ee7f3e642acd548b3ae96c47f7174ceb98f730 Mon Sep 17 00:00:00 2001 From: Jelle Raaijmakers Date: Wed, 13 Nov 2024 09:31:46 +0100 Subject: [PATCH] LibWeb: Add WebGLObject interface --- Libraries/LibWeb/CMakeLists.txt | 1 + Libraries/LibWeb/WebGL/WebGLObject.cpp | 18 +++++++++++ Libraries/LibWeb/WebGL/WebGLObject.h | 32 +++++++++++++++++++ Libraries/LibWeb/WebGL/WebGLObject.idl | 5 +++ Libraries/LibWeb/idl_files.cmake | 1 + .../Userland/Libraries/LibWeb/idl_files.gni | 1 + .../Text/expected/all-window-properties.txt | 1 + 7 files changed, 59 insertions(+) create mode 100644 Libraries/LibWeb/WebGL/WebGLObject.cpp create mode 100644 Libraries/LibWeb/WebGL/WebGLObject.h create mode 100644 Libraries/LibWeb/WebGL/WebGLObject.idl diff --git a/Libraries/LibWeb/CMakeLists.txt b/Libraries/LibWeb/CMakeLists.txt index dca642f4ef2..559328eb0aa 100644 --- a/Libraries/LibWeb/CMakeLists.txt +++ b/Libraries/LibWeb/CMakeLists.txt @@ -779,6 +779,7 @@ set(SOURCES WebGL/OpenGLContext.cpp WebGL/WebGLContextAttributes.cpp WebGL/WebGLContextEvent.cpp + WebGL/WebGLObject.cpp WebGL/WebGLRenderingContext.cpp WebGL/WebGLRenderingContextBase.cpp WebIDL/AbstractOperations.cpp diff --git a/Libraries/LibWeb/WebGL/WebGLObject.cpp b/Libraries/LibWeb/WebGL/WebGLObject.cpp new file mode 100644 index 00000000000..dff390dfe92 --- /dev/null +++ b/Libraries/LibWeb/WebGL/WebGLObject.cpp @@ -0,0 +1,18 @@ +/* + * Copyright (c) 2024, Jelle Raaijmakers + * + * SPDX-License-Identifier: BSD-2-Clause + */ + +#include + +namespace Web::WebGL { + +WebGLObject::WebGLObject(JS::Realm& realm) + : Bindings::PlatformObject(realm) +{ +} + +WebGLObject::~WebGLObject() = default; + +} diff --git a/Libraries/LibWeb/WebGL/WebGLObject.h b/Libraries/LibWeb/WebGL/WebGLObject.h new file mode 100644 index 00000000000..068b698f0da --- /dev/null +++ b/Libraries/LibWeb/WebGL/WebGLObject.h @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2024, Jelle Raaijmakers + * + * SPDX-License-Identifier: BSD-2-Clause + */ + +#pragma once + +#include + +namespace Web::WebGL { + +class WebGLObject : public Bindings::PlatformObject { + WEB_PLATFORM_OBJECT(WebGLRenderingContextBase, Bindings::PlatformObject); + +public: + virtual ~WebGLObject(); + + String label() const { return m_label; } + void set_label(String const& label) { m_label = label; } + +protected: + explicit WebGLObject(JS::Realm&); + + bool invalidated() const { return m_invalidated; } + +private: + bool m_invalidated { false }; + String m_label; +}; + +} diff --git a/Libraries/LibWeb/WebGL/WebGLObject.idl b/Libraries/LibWeb/WebGL/WebGLObject.idl new file mode 100644 index 00000000000..6b3139c9d8d --- /dev/null +++ b/Libraries/LibWeb/WebGL/WebGLObject.idl @@ -0,0 +1,5 @@ +// https://registry.khronos.org/webgl/specs/latest/1.0/#5.3 +[Exposed=(Window,Worker)] +interface WebGLObject { + attribute USVString label; +}; diff --git a/Libraries/LibWeb/idl_files.cmake b/Libraries/LibWeb/idl_files.cmake index 7f84bccbdf5..00a8f601c13 100644 --- a/Libraries/LibWeb/idl_files.cmake +++ b/Libraries/LibWeb/idl_files.cmake @@ -360,6 +360,7 @@ libweb_js_bindings(WebAudio/OfflineAudioContext) libweb_js_bindings(WebAudio/OscillatorNode) libweb_js_bindings(WebAudio/PeriodicWave) libweb_js_bindings(WebGL/WebGLContextEvent) +libweb_js_bindings(WebGL/WebGLObject) libweb_js_bindings(WebGL/WebGLRenderingContext) libweb_js_bindings(WebIDL/DOMException) libweb_js_bindings(WebSockets/WebSocket) diff --git a/Meta/gn/secondary/Userland/Libraries/LibWeb/idl_files.gni b/Meta/gn/secondary/Userland/Libraries/LibWeb/idl_files.gni index afd0cc05892..2f50882f3f4 100644 --- a/Meta/gn/secondary/Userland/Libraries/LibWeb/idl_files.gni +++ b/Meta/gn/secondary/Userland/Libraries/LibWeb/idl_files.gni @@ -372,6 +372,7 @@ standard_idl_files = [ "//Userland/Libraries/LibWeb/WebAudio/OscillatorNode.idl", "//Userland/Libraries/LibWeb/WebAudio/PeriodicWave.idl", "//Userland/Libraries/LibWeb/WebGL/WebGLContextEvent.idl", + "//Userland/Libraries/LibWeb/WebGL/WebGLObject.idl", "//Userland/Libraries/LibWeb/WebGL/WebGLRenderingContext.idl", "//Userland/Libraries/LibWeb/WebIDL/DOMException.idl", "//Userland/Libraries/LibWeb/WebSockets/WebSocket.idl", diff --git a/Tests/LibWeb/Text/expected/all-window-properties.txt b/Tests/LibWeb/Text/expected/all-window-properties.txt index 5613d0a6c24..33e96d926b6 100644 --- a/Tests/LibWeb/Text/expected/all-window-properties.txt +++ b/Tests/LibWeb/Text/expected/all-window-properties.txt @@ -391,6 +391,7 @@ WeakMap WeakRef WeakSet WebGLContextEvent +WebGLObject WebGLRenderingContext WebKitCSSMatrix WebSocket