mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-04-23 04:55:15 +00:00
LibWeb: Save OpenGL handle in WebGLObject
This commit is contained in:
parent
46cbbda944
commit
cfb394cad3
Notes:
github-actions[bot]
2024-12-03 22:37:03 +00:00
Author: https://github.com/kalenikaliaksandr Commit: https://github.com/LadybirdBrowser/ladybird/commit/cfb394cad39 Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/2688 Reviewed-by: https://github.com/ADKaster ✅
15 changed files with 83 additions and 20 deletions
|
@ -1,9 +1,11 @@
|
|||
/*
|
||||
* Copyright (c) 2024, Jelle Raaijmakers <jelle@ladybird.org>
|
||||
* Copyright (c) 2024, Aliaksandr Kalenik <kalenik.aliaksandr@gmail.com>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#include <LibJS/Runtime/Realm.h>
|
||||
#include <LibWeb/Bindings/WebGLBufferPrototype.h>
|
||||
#include <LibWeb/WebGL/WebGLBuffer.h>
|
||||
|
||||
|
@ -11,8 +13,13 @@ namespace Web::WebGL {
|
|||
|
||||
GC_DEFINE_ALLOCATOR(WebGLBuffer);
|
||||
|
||||
WebGLBuffer::WebGLBuffer(JS::Realm& realm)
|
||||
: WebGLObject(realm)
|
||||
GC::Ptr<WebGLBuffer> WebGLBuffer::create(JS::Realm& realm, GLuint handle)
|
||||
{
|
||||
return realm.heap().allocate<WebGLBuffer>(realm, handle);
|
||||
}
|
||||
|
||||
WebGLBuffer::WebGLBuffer(JS::Realm& realm, GLuint handle)
|
||||
: WebGLObject(realm, handle)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
@ -1,11 +1,13 @@
|
|||
/*
|
||||
* Copyright (c) 2024, Jelle Raaijmakers <jelle@ladybird.org>
|
||||
* Copyright (c) 2024, Aliaksandr Kalenik <kalenik.aliaksandr@gmail.com>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <LibWeb/WebGL/Types.h>
|
||||
#include <LibWeb/WebGL/WebGLObject.h>
|
||||
|
||||
namespace Web::WebGL {
|
||||
|
@ -15,10 +17,12 @@ class WebGLBuffer final : public WebGLObject {
|
|||
GC_DECLARE_ALLOCATOR(WebGLBuffer);
|
||||
|
||||
public:
|
||||
static GC::Ptr<WebGLBuffer> create(JS::Realm& realm, GLuint handle);
|
||||
|
||||
virtual ~WebGLBuffer();
|
||||
|
||||
protected:
|
||||
explicit WebGLBuffer(JS::Realm&);
|
||||
explicit WebGLBuffer(JS::Realm&, GLuint handle);
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -12,7 +12,7 @@ namespace Web::WebGL {
|
|||
GC_DEFINE_ALLOCATOR(WebGLFramebuffer);
|
||||
|
||||
WebGLFramebuffer::WebGLFramebuffer(JS::Realm& realm)
|
||||
: WebGLObject(realm)
|
||||
: WebGLObject(realm, 0)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
/*
|
||||
* Copyright (c) 2024, Jelle Raaijmakers <jelle@ladybird.org>
|
||||
* Copyright (c) 2024, Aliaksandr Kalenik <kalenik.aliaksandr@gmail.com>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
@ -8,8 +9,9 @@
|
|||
|
||||
namespace Web::WebGL {
|
||||
|
||||
WebGLObject::WebGLObject(JS::Realm& realm)
|
||||
WebGLObject::WebGLObject(JS::Realm& realm, GLuint handle)
|
||||
: Bindings::PlatformObject(realm)
|
||||
, m_handle(handle)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
/*
|
||||
* Copyright (c) 2024, Jelle Raaijmakers <jelle@ladybird.org>
|
||||
* Copyright (c) 2024, Aliaksandr Kalenik <kalenik.aliaksandr@gmail.com>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
@ -7,6 +8,9 @@
|
|||
#pragma once
|
||||
|
||||
#include <LibWeb/Bindings/PlatformObject.h>
|
||||
#include <LibWeb/WebGL/Types.h>
|
||||
|
||||
typedef unsigned int GLuint;
|
||||
|
||||
namespace Web::WebGL {
|
||||
|
||||
|
@ -19,14 +23,17 @@ public:
|
|||
String label() const { return m_label; }
|
||||
void set_label(String const& label) { m_label = label; }
|
||||
|
||||
GLuint handle() const { return m_handle; }
|
||||
|
||||
protected:
|
||||
explicit WebGLObject(JS::Realm&);
|
||||
explicit WebGLObject(JS::Realm&, GLuint handle);
|
||||
|
||||
bool invalidated() const { return m_invalidated; }
|
||||
|
||||
private:
|
||||
bool m_invalidated { false };
|
||||
String m_label;
|
||||
GLuint m_handle { 0 };
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -1,9 +1,11 @@
|
|||
/*
|
||||
* Copyright (c) 2024, Jelle Raaijmakers <jelle@ladybird.org>
|
||||
* Copyright (c) 2024, Aliaksandr Kalenik <kalenik.aliaksandr@gmail.com>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#include <LibJS/Runtime/Realm.h>
|
||||
#include <LibWeb/Bindings/WebGLProgramPrototype.h>
|
||||
#include <LibWeb/WebGL/WebGLProgram.h>
|
||||
|
||||
|
@ -11,8 +13,13 @@ namespace Web::WebGL {
|
|||
|
||||
GC_DEFINE_ALLOCATOR(WebGLProgram);
|
||||
|
||||
WebGLProgram::WebGLProgram(JS::Realm& realm)
|
||||
: WebGLObject(realm)
|
||||
GC::Ptr<WebGLProgram> WebGLProgram::create(JS::Realm& realm, GLuint handle)
|
||||
{
|
||||
return realm.heap().allocate<WebGLProgram>(realm, handle);
|
||||
}
|
||||
|
||||
WebGLProgram::WebGLProgram(JS::Realm& realm, GLuint handle)
|
||||
: WebGLObject(realm, handle)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
@ -1,11 +1,13 @@
|
|||
/*
|
||||
* Copyright (c) 2024, Jelle Raaijmakers <jelle@ladybird.org>
|
||||
* Copyright (c) 2024, Aliaksandr Kalenik <kalenik.aliaksandr@gmail.com>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <LibWeb/WebGL/Types.h>
|
||||
#include <LibWeb/WebGL/WebGLObject.h>
|
||||
|
||||
namespace Web::WebGL {
|
||||
|
@ -15,10 +17,12 @@ class WebGLProgram final : public WebGLObject {
|
|||
GC_DECLARE_ALLOCATOR(WebGLProgram);
|
||||
|
||||
public:
|
||||
static GC::Ptr<WebGLProgram> create(JS::Realm& realm, GLuint handle);
|
||||
|
||||
virtual ~WebGLProgram();
|
||||
|
||||
protected:
|
||||
explicit WebGLProgram(JS::Realm&);
|
||||
explicit WebGLProgram(JS::Realm&, GLuint handle);
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -12,7 +12,7 @@ namespace Web::WebGL {
|
|||
GC_DEFINE_ALLOCATOR(WebGLRenderbuffer);
|
||||
|
||||
WebGLRenderbuffer::WebGLRenderbuffer(JS::Realm& realm)
|
||||
: WebGLObject(realm)
|
||||
: WebGLObject(realm, 0)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
@ -1,9 +1,11 @@
|
|||
/*
|
||||
* Copyright (c) 2024, Jelle Raaijmakers <jelle@ladybird.org>
|
||||
* Copyright (c) 2024, Aliaksandr Kalenik <kalenik.aliaksandr@gmail.com>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#include <LibJS/Runtime/Realm.h>
|
||||
#include <LibWeb/Bindings/WebGLShaderPrototype.h>
|
||||
#include <LibWeb/WebGL/WebGLShader.h>
|
||||
|
||||
|
@ -11,8 +13,13 @@ namespace Web::WebGL {
|
|||
|
||||
GC_DEFINE_ALLOCATOR(WebGLShader);
|
||||
|
||||
WebGLShader::WebGLShader(JS::Realm& realm)
|
||||
: WebGLObject(realm)
|
||||
GC::Ptr<WebGLShader> WebGLShader::create(JS::Realm& realm, GLuint handle)
|
||||
{
|
||||
return realm.heap().allocate<WebGLShader>(realm, handle);
|
||||
}
|
||||
|
||||
WebGLShader::WebGLShader(JS::Realm& realm, GLuint handle)
|
||||
: WebGLObject(realm, handle)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
@ -1,11 +1,13 @@
|
|||
/*
|
||||
* Copyright (c) 2024, Jelle Raaijmakers <jelle@ladybird.org>
|
||||
* Copyright (c) 2024, Aliaksandr Kalenik <kalenik.aliaksandr@gmail.com>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <LibWeb/WebGL/Types.h>
|
||||
#include <LibWeb/WebGL/WebGLObject.h>
|
||||
|
||||
namespace Web::WebGL {
|
||||
|
@ -15,10 +17,12 @@ class WebGLShader final : public WebGLObject {
|
|||
GC_DECLARE_ALLOCATOR(WebGLShader);
|
||||
|
||||
public:
|
||||
static GC::Ptr<WebGLShader> create(JS::Realm& realm, GLuint handle);
|
||||
|
||||
virtual ~WebGLShader();
|
||||
|
||||
protected:
|
||||
explicit WebGLShader(JS::Realm&);
|
||||
explicit WebGLShader(JS::Realm&, GLuint handle);
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -12,7 +12,7 @@ namespace Web::WebGL {
|
|||
GC_DEFINE_ALLOCATOR(WebGLShaderPrecisionFormat);
|
||||
|
||||
WebGLShaderPrecisionFormat::WebGLShaderPrecisionFormat(JS::Realm& realm)
|
||||
: WebGLObject(realm)
|
||||
: WebGLObject(realm, 0)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
@ -1,9 +1,11 @@
|
|||
/*
|
||||
* Copyright (c) 2024, Jelle Raaijmakers <jelle@ladybird.org>
|
||||
* Copyright (c) 2024, Aliaksandr Kalenik <kalenik.aliaksandr@gmail.com>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#include <LibJS/Runtime/Realm.h>
|
||||
#include <LibWeb/Bindings/WebGLTexturePrototype.h>
|
||||
#include <LibWeb/WebGL/WebGLTexture.h>
|
||||
|
||||
|
@ -11,8 +13,13 @@ namespace Web::WebGL {
|
|||
|
||||
GC_DEFINE_ALLOCATOR(WebGLTexture);
|
||||
|
||||
WebGLTexture::WebGLTexture(JS::Realm& realm)
|
||||
: WebGLObject(realm)
|
||||
GC::Ptr<WebGLTexture> WebGLTexture::create(JS::Realm& realm, GLuint handle)
|
||||
{
|
||||
return realm.heap().allocate<WebGLTexture>(realm, handle);
|
||||
}
|
||||
|
||||
WebGLTexture::WebGLTexture(JS::Realm& realm, GLuint handle)
|
||||
: WebGLObject(realm, handle)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
@ -1,11 +1,13 @@
|
|||
/*
|
||||
* Copyright (c) 2024, Jelle Raaijmakers <jelle@ladybird.org>
|
||||
* Copyright (c) 2024, Aliaksandr Kalenik <kalenik.aliaksandr@gmail.com>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <LibWeb/WebGL/Types.h>
|
||||
#include <LibWeb/WebGL/WebGLObject.h>
|
||||
|
||||
namespace Web::WebGL {
|
||||
|
@ -15,10 +17,12 @@ class WebGLTexture final : public WebGLObject {
|
|||
GC_DECLARE_ALLOCATOR(WebGLTexture);
|
||||
|
||||
public:
|
||||
static GC::Ptr<WebGLTexture> create(JS::Realm& realm, GLuint handle);
|
||||
|
||||
virtual ~WebGLTexture();
|
||||
|
||||
protected:
|
||||
explicit WebGLTexture(JS::Realm&);
|
||||
explicit WebGLTexture(JS::Realm&, GLuint handle);
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -1,9 +1,11 @@
|
|||
/*
|
||||
* Copyright (c) 2024, Jelle Raaijmakers <jelle@ladybird.org>
|
||||
* Copyright (c) 2024, Aliaksandr Kalenik <kalenik.aliaksandr@gmail.com>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#include <LibJS/Runtime/Realm.h>
|
||||
#include <LibWeb/Bindings/WebGLUniformLocationPrototype.h>
|
||||
#include <LibWeb/WebGL/WebGLUniformLocation.h>
|
||||
|
||||
|
@ -11,8 +13,13 @@ namespace Web::WebGL {
|
|||
|
||||
GC_DEFINE_ALLOCATOR(WebGLUniformLocation);
|
||||
|
||||
WebGLUniformLocation::WebGLUniformLocation(JS::Realm& realm)
|
||||
: WebGLObject(realm)
|
||||
GC::Ptr<WebGLUniformLocation> WebGLUniformLocation::create(JS::Realm& realm, GLuint handle)
|
||||
{
|
||||
return realm.heap().allocate<WebGLUniformLocation>(realm, handle);
|
||||
}
|
||||
|
||||
WebGLUniformLocation::WebGLUniformLocation(JS::Realm& realm, GLuint handle)
|
||||
: WebGLObject(realm, handle)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
/*
|
||||
* Copyright (c) 2024, Jelle Raaijmakers <jelle@ladybird.org>
|
||||
* Copyright (c) 2024, Aliaksandr Kalenik <kalenik.aliaksandr@gmail.com>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
@ -15,10 +16,12 @@ class WebGLUniformLocation final : public WebGLObject {
|
|||
GC_DECLARE_ALLOCATOR(WebGLUniformLocation);
|
||||
|
||||
public:
|
||||
static GC::Ptr<WebGLUniformLocation> create(JS::Realm& realm, GLuint handle);
|
||||
|
||||
virtual ~WebGLUniformLocation();
|
||||
|
||||
protected:
|
||||
explicit WebGLUniformLocation(JS::Realm&);
|
||||
explicit WebGLUniformLocation(JS::Realm&, GLuint handle);
|
||||
};
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue