mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-08-05 07:41:01 +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: cfb394cad3
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, Jelle Raaijmakers <jelle@ladybird.org>
|
||||||
|
* Copyright (c) 2024, Aliaksandr Kalenik <kalenik.aliaksandr@gmail.com>
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: BSD-2-Clause
|
* SPDX-License-Identifier: BSD-2-Clause
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include <LibJS/Runtime/Realm.h>
|
||||||
#include <LibWeb/Bindings/WebGLBufferPrototype.h>
|
#include <LibWeb/Bindings/WebGLBufferPrototype.h>
|
||||||
#include <LibWeb/WebGL/WebGLBuffer.h>
|
#include <LibWeb/WebGL/WebGLBuffer.h>
|
||||||
|
|
||||||
|
@ -11,8 +13,13 @@ namespace Web::WebGL {
|
||||||
|
|
||||||
GC_DEFINE_ALLOCATOR(WebGLBuffer);
|
GC_DEFINE_ALLOCATOR(WebGLBuffer);
|
||||||
|
|
||||||
WebGLBuffer::WebGLBuffer(JS::Realm& realm)
|
GC::Ptr<WebGLBuffer> WebGLBuffer::create(JS::Realm& realm, GLuint handle)
|
||||||
: WebGLObject(realm)
|
{
|
||||||
|
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, Jelle Raaijmakers <jelle@ladybird.org>
|
||||||
|
* Copyright (c) 2024, Aliaksandr Kalenik <kalenik.aliaksandr@gmail.com>
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: BSD-2-Clause
|
* SPDX-License-Identifier: BSD-2-Clause
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include <LibWeb/WebGL/Types.h>
|
||||||
#include <LibWeb/WebGL/WebGLObject.h>
|
#include <LibWeb/WebGL/WebGLObject.h>
|
||||||
|
|
||||||
namespace Web::WebGL {
|
namespace Web::WebGL {
|
||||||
|
@ -15,10 +17,12 @@ class WebGLBuffer final : public WebGLObject {
|
||||||
GC_DECLARE_ALLOCATOR(WebGLBuffer);
|
GC_DECLARE_ALLOCATOR(WebGLBuffer);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
static GC::Ptr<WebGLBuffer> create(JS::Realm& realm, GLuint handle);
|
||||||
|
|
||||||
virtual ~WebGLBuffer();
|
virtual ~WebGLBuffer();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
explicit WebGLBuffer(JS::Realm&);
|
explicit WebGLBuffer(JS::Realm&, GLuint handle);
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,7 +12,7 @@ namespace Web::WebGL {
|
||||||
GC_DEFINE_ALLOCATOR(WebGLFramebuffer);
|
GC_DEFINE_ALLOCATOR(WebGLFramebuffer);
|
||||||
|
|
||||||
WebGLFramebuffer::WebGLFramebuffer(JS::Realm& realm)
|
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, Jelle Raaijmakers <jelle@ladybird.org>
|
||||||
|
* Copyright (c) 2024, Aliaksandr Kalenik <kalenik.aliaksandr@gmail.com>
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: BSD-2-Clause
|
* SPDX-License-Identifier: BSD-2-Clause
|
||||||
*/
|
*/
|
||||||
|
@ -8,8 +9,9 @@
|
||||||
|
|
||||||
namespace Web::WebGL {
|
namespace Web::WebGL {
|
||||||
|
|
||||||
WebGLObject::WebGLObject(JS::Realm& realm)
|
WebGLObject::WebGLObject(JS::Realm& realm, GLuint handle)
|
||||||
: Bindings::PlatformObject(realm)
|
: Bindings::PlatformObject(realm)
|
||||||
|
, m_handle(handle)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2024, Jelle Raaijmakers <jelle@ladybird.org>
|
* Copyright (c) 2024, Jelle Raaijmakers <jelle@ladybird.org>
|
||||||
|
* Copyright (c) 2024, Aliaksandr Kalenik <kalenik.aliaksandr@gmail.com>
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: BSD-2-Clause
|
* SPDX-License-Identifier: BSD-2-Clause
|
||||||
*/
|
*/
|
||||||
|
@ -7,6 +8,9 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <LibWeb/Bindings/PlatformObject.h>
|
#include <LibWeb/Bindings/PlatformObject.h>
|
||||||
|
#include <LibWeb/WebGL/Types.h>
|
||||||
|
|
||||||
|
typedef unsigned int GLuint;
|
||||||
|
|
||||||
namespace Web::WebGL {
|
namespace Web::WebGL {
|
||||||
|
|
||||||
|
@ -19,14 +23,17 @@ public:
|
||||||
String label() const { return m_label; }
|
String label() const { return m_label; }
|
||||||
void set_label(String const& label) { m_label = label; }
|
void set_label(String const& label) { m_label = label; }
|
||||||
|
|
||||||
|
GLuint handle() const { return m_handle; }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
explicit WebGLObject(JS::Realm&);
|
explicit WebGLObject(JS::Realm&, GLuint handle);
|
||||||
|
|
||||||
bool invalidated() const { return m_invalidated; }
|
bool invalidated() const { return m_invalidated; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool m_invalidated { false };
|
bool m_invalidated { false };
|
||||||
String m_label;
|
String m_label;
|
||||||
|
GLuint m_handle { 0 };
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,9 +1,11 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2024, Jelle Raaijmakers <jelle@ladybird.org>
|
* Copyright (c) 2024, Jelle Raaijmakers <jelle@ladybird.org>
|
||||||
|
* Copyright (c) 2024, Aliaksandr Kalenik <kalenik.aliaksandr@gmail.com>
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: BSD-2-Clause
|
* SPDX-License-Identifier: BSD-2-Clause
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include <LibJS/Runtime/Realm.h>
|
||||||
#include <LibWeb/Bindings/WebGLProgramPrototype.h>
|
#include <LibWeb/Bindings/WebGLProgramPrototype.h>
|
||||||
#include <LibWeb/WebGL/WebGLProgram.h>
|
#include <LibWeb/WebGL/WebGLProgram.h>
|
||||||
|
|
||||||
|
@ -11,8 +13,13 @@ namespace Web::WebGL {
|
||||||
|
|
||||||
GC_DEFINE_ALLOCATOR(WebGLProgram);
|
GC_DEFINE_ALLOCATOR(WebGLProgram);
|
||||||
|
|
||||||
WebGLProgram::WebGLProgram(JS::Realm& realm)
|
GC::Ptr<WebGLProgram> WebGLProgram::create(JS::Realm& realm, GLuint handle)
|
||||||
: WebGLObject(realm)
|
{
|
||||||
|
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, Jelle Raaijmakers <jelle@ladybird.org>
|
||||||
|
* Copyright (c) 2024, Aliaksandr Kalenik <kalenik.aliaksandr@gmail.com>
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: BSD-2-Clause
|
* SPDX-License-Identifier: BSD-2-Clause
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include <LibWeb/WebGL/Types.h>
|
||||||
#include <LibWeb/WebGL/WebGLObject.h>
|
#include <LibWeb/WebGL/WebGLObject.h>
|
||||||
|
|
||||||
namespace Web::WebGL {
|
namespace Web::WebGL {
|
||||||
|
@ -15,10 +17,12 @@ class WebGLProgram final : public WebGLObject {
|
||||||
GC_DECLARE_ALLOCATOR(WebGLProgram);
|
GC_DECLARE_ALLOCATOR(WebGLProgram);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
static GC::Ptr<WebGLProgram> create(JS::Realm& realm, GLuint handle);
|
||||||
|
|
||||||
virtual ~WebGLProgram();
|
virtual ~WebGLProgram();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
explicit WebGLProgram(JS::Realm&);
|
explicit WebGLProgram(JS::Realm&, GLuint handle);
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,7 +12,7 @@ namespace Web::WebGL {
|
||||||
GC_DEFINE_ALLOCATOR(WebGLRenderbuffer);
|
GC_DEFINE_ALLOCATOR(WebGLRenderbuffer);
|
||||||
|
|
||||||
WebGLRenderbuffer::WebGLRenderbuffer(JS::Realm& realm)
|
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, Jelle Raaijmakers <jelle@ladybird.org>
|
||||||
|
* Copyright (c) 2024, Aliaksandr Kalenik <kalenik.aliaksandr@gmail.com>
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: BSD-2-Clause
|
* SPDX-License-Identifier: BSD-2-Clause
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include <LibJS/Runtime/Realm.h>
|
||||||
#include <LibWeb/Bindings/WebGLShaderPrototype.h>
|
#include <LibWeb/Bindings/WebGLShaderPrototype.h>
|
||||||
#include <LibWeb/WebGL/WebGLShader.h>
|
#include <LibWeb/WebGL/WebGLShader.h>
|
||||||
|
|
||||||
|
@ -11,8 +13,13 @@ namespace Web::WebGL {
|
||||||
|
|
||||||
GC_DEFINE_ALLOCATOR(WebGLShader);
|
GC_DEFINE_ALLOCATOR(WebGLShader);
|
||||||
|
|
||||||
WebGLShader::WebGLShader(JS::Realm& realm)
|
GC::Ptr<WebGLShader> WebGLShader::create(JS::Realm& realm, GLuint handle)
|
||||||
: WebGLObject(realm)
|
{
|
||||||
|
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, Jelle Raaijmakers <jelle@ladybird.org>
|
||||||
|
* Copyright (c) 2024, Aliaksandr Kalenik <kalenik.aliaksandr@gmail.com>
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: BSD-2-Clause
|
* SPDX-License-Identifier: BSD-2-Clause
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include <LibWeb/WebGL/Types.h>
|
||||||
#include <LibWeb/WebGL/WebGLObject.h>
|
#include <LibWeb/WebGL/WebGLObject.h>
|
||||||
|
|
||||||
namespace Web::WebGL {
|
namespace Web::WebGL {
|
||||||
|
@ -15,10 +17,12 @@ class WebGLShader final : public WebGLObject {
|
||||||
GC_DECLARE_ALLOCATOR(WebGLShader);
|
GC_DECLARE_ALLOCATOR(WebGLShader);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
static GC::Ptr<WebGLShader> create(JS::Realm& realm, GLuint handle);
|
||||||
|
|
||||||
virtual ~WebGLShader();
|
virtual ~WebGLShader();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
explicit WebGLShader(JS::Realm&);
|
explicit WebGLShader(JS::Realm&, GLuint handle);
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,7 +12,7 @@ namespace Web::WebGL {
|
||||||
GC_DEFINE_ALLOCATOR(WebGLShaderPrecisionFormat);
|
GC_DEFINE_ALLOCATOR(WebGLShaderPrecisionFormat);
|
||||||
|
|
||||||
WebGLShaderPrecisionFormat::WebGLShaderPrecisionFormat(JS::Realm& realm)
|
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, Jelle Raaijmakers <jelle@ladybird.org>
|
||||||
|
* Copyright (c) 2024, Aliaksandr Kalenik <kalenik.aliaksandr@gmail.com>
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: BSD-2-Clause
|
* SPDX-License-Identifier: BSD-2-Clause
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include <LibJS/Runtime/Realm.h>
|
||||||
#include <LibWeb/Bindings/WebGLTexturePrototype.h>
|
#include <LibWeb/Bindings/WebGLTexturePrototype.h>
|
||||||
#include <LibWeb/WebGL/WebGLTexture.h>
|
#include <LibWeb/WebGL/WebGLTexture.h>
|
||||||
|
|
||||||
|
@ -11,8 +13,13 @@ namespace Web::WebGL {
|
||||||
|
|
||||||
GC_DEFINE_ALLOCATOR(WebGLTexture);
|
GC_DEFINE_ALLOCATOR(WebGLTexture);
|
||||||
|
|
||||||
WebGLTexture::WebGLTexture(JS::Realm& realm)
|
GC::Ptr<WebGLTexture> WebGLTexture::create(JS::Realm& realm, GLuint handle)
|
||||||
: WebGLObject(realm)
|
{
|
||||||
|
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, Jelle Raaijmakers <jelle@ladybird.org>
|
||||||
|
* Copyright (c) 2024, Aliaksandr Kalenik <kalenik.aliaksandr@gmail.com>
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: BSD-2-Clause
|
* SPDX-License-Identifier: BSD-2-Clause
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include <LibWeb/WebGL/Types.h>
|
||||||
#include <LibWeb/WebGL/WebGLObject.h>
|
#include <LibWeb/WebGL/WebGLObject.h>
|
||||||
|
|
||||||
namespace Web::WebGL {
|
namespace Web::WebGL {
|
||||||
|
@ -15,10 +17,12 @@ class WebGLTexture final : public WebGLObject {
|
||||||
GC_DECLARE_ALLOCATOR(WebGLTexture);
|
GC_DECLARE_ALLOCATOR(WebGLTexture);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
static GC::Ptr<WebGLTexture> create(JS::Realm& realm, GLuint handle);
|
||||||
|
|
||||||
virtual ~WebGLTexture();
|
virtual ~WebGLTexture();
|
||||||
|
|
||||||
protected:
|
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, Jelle Raaijmakers <jelle@ladybird.org>
|
||||||
|
* Copyright (c) 2024, Aliaksandr Kalenik <kalenik.aliaksandr@gmail.com>
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: BSD-2-Clause
|
* SPDX-License-Identifier: BSD-2-Clause
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include <LibJS/Runtime/Realm.h>
|
||||||
#include <LibWeb/Bindings/WebGLUniformLocationPrototype.h>
|
#include <LibWeb/Bindings/WebGLUniformLocationPrototype.h>
|
||||||
#include <LibWeb/WebGL/WebGLUniformLocation.h>
|
#include <LibWeb/WebGL/WebGLUniformLocation.h>
|
||||||
|
|
||||||
|
@ -11,8 +13,13 @@ namespace Web::WebGL {
|
||||||
|
|
||||||
GC_DEFINE_ALLOCATOR(WebGLUniformLocation);
|
GC_DEFINE_ALLOCATOR(WebGLUniformLocation);
|
||||||
|
|
||||||
WebGLUniformLocation::WebGLUniformLocation(JS::Realm& realm)
|
GC::Ptr<WebGLUniformLocation> WebGLUniformLocation::create(JS::Realm& realm, GLuint handle)
|
||||||
: WebGLObject(realm)
|
{
|
||||||
|
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, Jelle Raaijmakers <jelle@ladybird.org>
|
||||||
|
* Copyright (c) 2024, Aliaksandr Kalenik <kalenik.aliaksandr@gmail.com>
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: BSD-2-Clause
|
* SPDX-License-Identifier: BSD-2-Clause
|
||||||
*/
|
*/
|
||||||
|
@ -15,10 +16,12 @@ class WebGLUniformLocation final : public WebGLObject {
|
||||||
GC_DECLARE_ALLOCATOR(WebGLUniformLocation);
|
GC_DECLARE_ALLOCATOR(WebGLUniformLocation);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
static GC::Ptr<WebGLUniformLocation> create(JS::Realm& realm, GLuint handle);
|
||||||
|
|
||||||
virtual ~WebGLUniformLocation();
|
virtual ~WebGLUniformLocation();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
explicit WebGLUniformLocation(JS::Realm&);
|
explicit WebGLUniformLocation(JS::Realm&, GLuint handle);
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue