Add Chromium-only Blender WebEngine parity work

This commit is contained in:
mes123456
2026-08-12 04:47:48 -04:00
commit 9fd26010f6
18225 changed files with 11622124 additions and 0 deletions

View File

@@ -0,0 +1,89 @@
/* SPDX-FileCopyrightText: 2022 Blender Authors
*
* SPDX-License-Identifier: GPL-2.0-or-later */
/** \file
* \ingroup intern_wayland_dynload
*
* Wrapper functions for `<wayland-client.h>`.
*/
#include <stdlib.h> /* `atexit`. */
#include <string.h>
#include "wayland_dynload_API.h"
#include "wayland_dynload_utils.h"
#include "wayland_dynload_client.h" /* Own include. */
/* Public handle. */
struct WaylandDynload_Client wayland_dynload_client = {NULL};
static DynamicLibrary lib = NULL;
#define WAYLAND_DYNLOAD_IFACE(symbol) \
extern struct wl_interface symbol; \
struct wl_interface symbol;
#include "wayland_dynload_client.h"
#undef WAYLAND_DYNLOAD_IFACE
bool wayland_dynload_client_init(const bool verbose)
{
/* NOTE: returning false must call exit to prevent leaking `lib`
* once it has been opened. */
/* Library paths. */
const char *paths[] = {
"libwayland-client.so.0",
"libwayland-client.so",
};
const int paths_num = sizeof(paths) / sizeof(*paths);
int path_found;
if (!(lib = dynamic_library_open_array_with_error(paths, paths_num, verbose, &path_found))) {
return false;
}
if (atexit(wayland_dynload_client_exit)) {
wayland_dynload_client_exit();
return false;
}
#define WAYLAND_DYNLOAD_IFACE(symbol) \
{ \
const void *symbol_val; \
if (!(symbol_val = dynamic_library_find_with_error( \
lib, #symbol, paths[path_found], verbose))) { \
wayland_dynload_client_exit(); \
return false; \
} \
memcpy(&symbol, symbol_val, sizeof(symbol)); \
}
#include "wayland_dynload_client.h"
#undef WAYLAND_DYNLOAD_IFACE
#define WAYLAND_DYNLOAD_FN(symbol) \
if (!(wayland_dynload_client.symbol = dynamic_library_find_with_error( \
lib, #symbol, paths[path_found], verbose))) \
{ \
wayland_dynload_client_exit(); \
return false; \
}
#include "wayland_dynload_client.h"
#undef WAYLAND_DYNLOAD_FN
return true;
}
void wayland_dynload_client_exit(void)
{
if (lib != NULL) {
dynamic_library_close(lib); /* Ignore errors. */
lib = NULL;
}
}
/* Validate local signatures against the original header. */
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wredundant-decls"
#define WAYLAND_DYNLOAD_VALIDATE
#include "wayland_dynload_client.h"
#pragma GCC diagnostic pop

View File

@@ -0,0 +1,69 @@
/* SPDX-FileCopyrightText: 2022 Blender Authors
*
* SPDX-License-Identifier: GPL-2.0-or-later */
/** \file
* \ingroup intern_wayland_dynload
*
* Wrapper functions for `<wayland-cursor.h>`.
*/
#include <stdlib.h> /* `atexit`. */
#include <string.h>
#include "wayland_dynload_API.h"
#include "wayland_dynload_utils.h"
#include "wayland_dynload_cursor.h" /* Own include. */
struct WaylandDynload_Cursor wayland_dynload_cursor = {NULL};
static DynamicLibrary lib = NULL;
bool wayland_dynload_cursor_init(const bool verbose)
{
/* NOTE: returning false must call exit to prevent leaking `lib`
* once it has been opened. */
/* Library paths. */
const char *paths[] = {
"libwayland-cursor.so.0",
"libwayland-cursor.so",
};
const int paths_num = sizeof(paths) / sizeof(*paths);
int path_index;
if (!(lib = dynamic_library_open_array_with_error(paths, paths_num, verbose, &path_index))) {
return false;
}
if (atexit(wayland_dynload_cursor_exit)) {
wayland_dynload_cursor_exit();
return false;
}
#define WAYLAND_DYNLOAD_FN(symbol) \
if (!(wayland_dynload_cursor.symbol = dynamic_library_find_with_error( \
lib, #symbol, paths[path_index], verbose))) \
{ \
wayland_dynload_cursor_exit(); \
return false; \
}
#include "wayland_dynload_cursor.h"
#undef WAYLAND_DYNLOAD_FN
return true;
}
void wayland_dynload_cursor_exit(void)
{
if (lib != NULL) {
dynamic_library_close(lib); /* Ignore errors. */
lib = NULL;
}
}
/* Validate local signatures against the original header. */
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wredundant-decls"
#define WAYLAND_DYNLOAD_VALIDATE
#include "wayland_dynload_cursor.h"
#pragma GCC diagnostic pop

View File

@@ -0,0 +1,69 @@
/* SPDX-FileCopyrightText: 2022 Blender Authors
*
* SPDX-License-Identifier: GPL-2.0-or-later */
/** \file
* \ingroup intern_wayland_dynload
*
* Wrapper functions for `<wayland-egl.h>`.
*/
#include <stdlib.h> /* `atexit`. */
#include "wayland_dynload_API.h"
#include "wayland_dynload_utils.h"
#include "wayland_dynload_egl.h" /* Own include. */
/* Public handle. */
struct WaylandDynload_EGL wayland_dynload_egl = {NULL};
static DynamicLibrary lib = NULL;
bool wayland_dynload_egl_init(const bool verbose)
{
/* NOTE: returning false must call exit to prevent leaking `lib`
* once it has been opened. */
/* Library paths. */
const char *paths[] = {
"libwayland-egl.so.1",
"libwayland-egl.so",
};
const int paths_num = sizeof(paths) / sizeof(*paths);
int path_found = 0;
if (!(lib = dynamic_library_open_array_with_error(paths, paths_num, verbose, &path_found))) {
return false;
}
if (atexit(wayland_dynload_egl_exit)) {
wayland_dynload_egl_exit();
return false;
}
#define WAYLAND_DYNLOAD_FN(symbol) \
if (!(wayland_dynload_egl.symbol = dynamic_library_find_with_error( \
lib, #symbol, paths[path_found], verbose))) \
{ \
wayland_dynload_egl_exit(); \
return false; \
}
#include "wayland_dynload_egl.h"
#undef WAYLAND_DYNLOAD_FN
return true;
}
void wayland_dynload_egl_exit(void)
{
if (lib != NULL) {
dynamic_library_close(lib); /* Ignore errors. */
lib = NULL;
}
}
/* Validate local signatures against the original header. */
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wredundant-decls"
#define WAYLAND_DYNLOAD_VALIDATE
#include "wayland_dynload_egl.h"
#pragma GCC diagnostic pop

View File

@@ -0,0 +1,47 @@
/* SPDX-FileCopyrightText: 2022 Blender Authors
*
* SPDX-License-Identifier: GPL-2.0-or-later */
/** \file
* \ingroup intern_wayland_dynload
*/
#include <stdio.h>
#include "wayland_dynload_utils.h"
DynamicLibrary dynamic_library_open_array_with_error(const char **paths,
const int paths_num,
const bool verbose,
int *r_path_index)
{
DynamicLibrary lib = NULL;
for (int a = 0; a < paths_num; a++) {
lib = dynamic_library_open(paths[a]);
if (lib) {
*r_path_index = a;
break;
}
}
if (lib == NULL) {
/* Use the last path as it's likely to be least specific. */
if (verbose) {
fprintf(stderr, "Unable to find '%s'\n", paths[paths_num - 1]);
}
}
return lib;
}
void *dynamic_library_find_with_error(DynamicLibrary lib,
const char *symbol,
const char *path_lib,
const bool verbose)
{
void *symbol_var = dynamic_library_find(lib, symbol);
if (symbol_var == NULL) {
if (verbose) {
fprintf(stderr, "Unable to find '%s' in '%s'.\n", symbol, path_lib);
}
}
return symbol_var;
}

View File

@@ -0,0 +1,32 @@
/* SPDX-FileCopyrightText: 2022 Blender Authors
*
* SPDX-License-Identifier: GPL-2.0-or-later */
/** \file
* \ingroup intern_wayland_dynload
*
* Utility defines.
*/
#pragma once
#include <dlfcn.h> /* Dynamic loading. */
#include <stdbool.h>
typedef void *DynamicLibrary;
#define dynamic_library_open(path) dlopen(path, RTLD_NOW)
#define dynamic_library_close(lib) dlclose(lib)
#define dynamic_library_find(lib, symbol) dlsym(lib, symbol)
/** Loads a library from an array, printing an error when the symbol isn't found. */
DynamicLibrary dynamic_library_open_array_with_error(const char **paths,
int paths_num,
bool verbose,
int *r_path_index);
/** Find a symbol, printing an error when the symbol isn't found. */
void *dynamic_library_find_with_error(DynamicLibrary lib,
const char *symbol,
const char *path_lib,
bool verbose);