Skip to content

Commit 12f0d04

Browse files
committed
[Chore] (All): Format code & add source file head.
1 parent 311f1cd commit 12f0d04

70 files changed

Lines changed: 12968 additions & 12112 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

src/main/cpp/config/cJSON.c

Lines changed: 795 additions & 1271 deletions
Large diffs are not rendered by default.

src/main/cpp/config/cJSON.h

Lines changed: 218 additions & 200 deletions
Large diffs are not rendered by default.

src/main/cpp/config/config.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
// MobileGlues - config/config.cpp
2+
// Copyright (c) 2025-2026 MobileGL-Dev
3+
// Licensed under the GNU Lesser General Public License v2.1:
4+
// https://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt
5+
// SPDX-License-Identifier: LGPL-2.1-only
6+
// End of Source File Header
17
#include "config.h"
28

39
#include "../gl/log.h"

src/main/cpp/config/config.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
// MobileGlues - config/config.h
2+
// Copyright (c) 2025-2026 MobileGL-Dev
3+
// Licensed under the GNU Lesser General Public License v2.1:
4+
// https://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt
5+
// SPDX-License-Identifier: LGPL-2.1-only
6+
// End of Source File Header
17
#ifndef _MOBILEGLUES_CONFIG_H_
28
#define _MOBILEGLUES_CONFIG_H_
39

src/main/cpp/config/gpu_utils.cpp

Lines changed: 53 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
1-
//
2-
// Created by hanji on 2025/2/9.
3-
//
1+
// MobileGlues - config/gpu_utils.cpp
2+
// Copyright (c) 2025-2026 MobileGL-Dev
3+
// Licensed under the GNU Lesser General Public License v2.1:
4+
// https://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt
5+
// SPDX-License-Identifier: LGPL-2.1-only
6+
// End of Source File Header
47

58
#include "gpu_utils.h"
69
#include "../gles/loader.h"
@@ -12,29 +15,19 @@
1215
#include <cstring>
1316
#include <optional>
1417
typedef const char* cstr;
15-
static const cstr gles3_lib[] = {
16-
"libGLESv3_CM",
17-
"libGLESv3",
18-
nullptr
19-
};
20-
static const cstr egl_libs[] = {
21-
"libEGL",
22-
nullptr
23-
};
24-
static const cstr vk_lib[] = {
25-
"libvulkan",
26-
nullptr
27-
};
18+
static const cstr gles3_lib[] = {"libGLESv3_CM", "libGLESv3", nullptr};
19+
static const cstr egl_libs[] = {"libEGL", nullptr};
20+
static const cstr vk_lib[] = {"libvulkan", nullptr};
2821

2922
namespace egl_func {
30-
PFNEGLGETDISPLAYPROC eglGetDisplay = nullptr;
31-
PFNEGLINITIALIZEPROC eglInitialize = nullptr;
32-
PFNEGLCHOOSECONFIGPROC eglChooseConfig = nullptr;
33-
PFNEGLCREATECONTEXTPROC eglCreateContext = nullptr;
34-
PFNEGLMAKECURRENTPROC eglMakeCurrent = nullptr;
35-
PFNEGLDESTROYCONTEXTPROC eglDestroyContext = nullptr;
36-
PFNEGLTERMINATEPROC eglTerminate = nullptr;
37-
}
23+
PFNEGLGETDISPLAYPROC eglGetDisplay = nullptr;
24+
PFNEGLINITIALIZEPROC eglInitialize = nullptr;
25+
PFNEGLCHOOSECONFIGPROC eglChooseConfig = nullptr;
26+
PFNEGLCREATECONTEXTPROC eglCreateContext = nullptr;
27+
PFNEGLMAKECURRENTPROC eglMakeCurrent = nullptr;
28+
PFNEGLDESTROYCONTEXTPROC eglDestroyContext = nullptr;
29+
PFNEGLTERMINATEPROC eglTerminate = nullptr;
30+
} // namespace egl_func
3831

3932
template <typename T>
4033
static void* open_lib(const T names[], const char* override) {
@@ -62,8 +55,8 @@ static bool loadEGLFunctions(void* lib) {
6255
egl_func::eglTerminate = (PFNEGLTERMINATEPROC)dlsym(lib, "eglTerminate");
6356

6457
return egl_func::eglGetDisplay && egl_func::eglInitialize && egl_func::eglChooseConfig &&
65-
egl_func::eglCreateContext && egl_func::eglMakeCurrent &&
66-
egl_func::eglDestroyContext && egl_func::eglTerminate;
58+
egl_func::eglCreateContext && egl_func::eglMakeCurrent && egl_func::eglDestroyContext &&
59+
egl_func::eglTerminate;
6760
}
6861

6962
std::string getGPUInfo() {
@@ -85,16 +78,21 @@ std::string getGPUInfo() {
8578
return std::string();
8679
}
8780

88-
const EGLint attribs[] = {
89-
EGL_BLUE_SIZE, 8,
90-
EGL_GREEN_SIZE, 8,
91-
EGL_RED_SIZE, 8,
92-
EGL_ALPHA_SIZE, 8,
93-
EGL_DEPTH_SIZE, 24,
94-
EGL_SURFACE_TYPE, EGL_PBUFFER_BIT,
95-
EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT,
96-
EGL_NONE
97-
};
81+
const EGLint attribs[] = {EGL_BLUE_SIZE,
82+
8,
83+
EGL_GREEN_SIZE,
84+
8,
85+
EGL_RED_SIZE,
86+
8,
87+
EGL_ALPHA_SIZE,
88+
8,
89+
EGL_DEPTH_SIZE,
90+
24,
91+
EGL_SURFACE_TYPE,
92+
EGL_PBUFFER_BIT,
93+
EGL_RENDERABLE_TYPE,
94+
EGL_OPENGL_ES2_BIT,
95+
EGL_NONE};
9896
EGLint numConfigs = 0;
9997
if (egl_func::eglChooseConfig(display, attribs, nullptr, 0, &numConfigs) != EGL_TRUE || numConfigs == 0) {
10098
egl_func::eglTerminate(display);
@@ -104,7 +102,7 @@ std::string getGPUInfo() {
104102
EGLConfig config;
105103
egl_func::eglChooseConfig(display, attribs, &config, 1, &numConfigs);
106104

107-
const EGLint ctxAttribs[] = { EGL_CONTEXT_CLIENT_VERSION, 3, EGL_NONE };
105+
const EGLint ctxAttribs[] = {EGL_CONTEXT_CLIENT_VERSION, 3, EGL_NONE};
108106
EGLContext ctx = egl_func::eglCreateContext(display, config, EGL_NO_CONTEXT, ctxAttribs);
109107
if (ctx == EGL_NO_CONTEXT) {
110108
egl_func::eglTerminate(display);
@@ -122,7 +120,7 @@ std::string getGPUInfo() {
122120
void* glesLib = open_lib(gles3_lib, nullptr);
123121
std::string renderer;
124122
if (glesLib) {
125-
auto glGetString = (const GLubyte * (*)(GLenum))dlsym(glesLib, "glGetString");
123+
auto glGetString = (const GLubyte* (*)(GLenum))dlsym(glesLib, "glGetString");
126124
if (glGetString) {
127125
renderer = reinterpret_cast<const char*>(glGetString(GL_RENDERER));
128126
}
@@ -138,23 +136,20 @@ std::string getGPUInfo() {
138136
}
139137

140138
int isAdreno(const char* gpu) {
141-
// const char* gpu = getGPUInfo();
142-
if (!gpu)
143-
return 0;
139+
// const char* gpu = getGPUInfo();
140+
if (!gpu) return 0;
144141
return strstr(gpu, "Adreno") != nullptr;
145142
}
146143

147144
int isAdreno740(const char* gpu) {
148145
// const char* gpu = getGPUInfo();
149-
if (!gpu)
150-
return 0;
146+
if (!gpu) return 0;
151147
return isAdreno(gpu) && (strstr(gpu, "740") != nullptr);
152148
}
153149

154150
int isAdreno730(const char* gpu) {
155151
// const char* gpu = getGPUInfo();
156-
if (!gpu)
157-
return 0;
152+
if (!gpu) return 0;
158153
return isAdreno(gpu) && (strstr(gpu, "730") != nullptr);
159154
}
160155

@@ -163,41 +158,35 @@ bool checkIfANGLESupported(const char* gpu) {
163158
}
164159

165160
int isAdreno830(const char* gpu) {
166-
// const char* gpu = getGPUInfo();
167-
if (!gpu)
168-
return 0;
161+
// const char* gpu = getGPUInfo();
162+
if (!gpu) return 0;
169163
return isAdreno(gpu) && (strstr(gpu, "830") != nullptr);
170164
}
171165

172166
static std::optional<int> hasVk12;
173167
int hasVulkan12() {
174-
if (hasVk12.has_value())
175-
return hasVk12.value();
168+
if (hasVk12.has_value()) return hasVk12.value();
176169
void* vulkan_lib = open_lib(vk_lib, nullptr);
177-
if (!vulkan_lib)
178-
return 0;
170+
if (!vulkan_lib) return 0;
179171

180172
#ifndef __APPLE__
181-
173+
182174
typedef VkResult (*PFN_vkEnumerateInstanceExtensionProperties)(const char*, uint32_t*, VkExtensionProperties*);
183175
typedef VkResult (*PFN_vkCreateInstance)(const VkInstanceCreateInfo*, const VkAllocationCallbacks*, VkInstance*);
184176
typedef void (*PFN_vkDestroyInstance)(VkInstance, const VkAllocationCallbacks*);
185177
typedef VkResult (*PFN_vkEnumeratePhysicalDevices)(VkInstance, uint32_t*, VkPhysicalDevice*);
186178
typedef void (*PFN_vkGetPhysicalDeviceProperties)(VkPhysicalDevice, VkPhysicalDeviceProperties*);
187179

188180
auto vkEnumerateInstanceExtensionProperties =
189-
(PFN_vkEnumerateInstanceExtensionProperties)dlsym(vulkan_lib, "vkEnumerateInstanceExtensionProperties");
190-
auto vkCreateInstance =
191-
(PFN_vkCreateInstance)dlsym(vulkan_lib, "vkCreateInstance");
192-
auto vkDestroyInstance =
193-
(PFN_vkDestroyInstance)dlsym(vulkan_lib, "vkDestroyInstance");
194-
auto vkEnumeratePhysicalDevices =
195-
(PFN_vkEnumeratePhysicalDevices)dlsym(vulkan_lib, "vkEnumeratePhysicalDevices");
181+
(PFN_vkEnumerateInstanceExtensionProperties)dlsym(vulkan_lib, "vkEnumerateInstanceExtensionProperties");
182+
auto vkCreateInstance = (PFN_vkCreateInstance)dlsym(vulkan_lib, "vkCreateInstance");
183+
auto vkDestroyInstance = (PFN_vkDestroyInstance)dlsym(vulkan_lib, "vkDestroyInstance");
184+
auto vkEnumeratePhysicalDevices = (PFN_vkEnumeratePhysicalDevices)dlsym(vulkan_lib, "vkEnumeratePhysicalDevices");
196185
auto vkGetPhysicalDeviceProperties =
197-
(PFN_vkGetPhysicalDeviceProperties)dlsym(vulkan_lib, "vkGetPhysicalDeviceProperties");
186+
(PFN_vkGetPhysicalDeviceProperties)dlsym(vulkan_lib, "vkGetPhysicalDeviceProperties");
198187

199-
if (!vkEnumerateInstanceExtensionProperties || !vkCreateInstance ||
200-
!vkDestroyInstance || !vkEnumeratePhysicalDevices || !vkGetPhysicalDeviceProperties) {
188+
if (!vkEnumerateInstanceExtensionProperties || !vkCreateInstance || !vkDestroyInstance ||
189+
!vkEnumeratePhysicalDevices || !vkGetPhysicalDeviceProperties) {
201190
dlclose(vulkan_lib);
202191
return 0;
203192
}
@@ -265,6 +254,6 @@ int hasVulkan12() {
265254
dlclose(vulkan_lib);
266255
hasVk12 = false;
267256
return 0;
268-
257+
269258
#endif
270259
}

src/main/cpp/config/gpu_utils.h

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
1-
//
2-
// Created by hanji on 2025/2/9.
3-
//
1+
// MobileGlues - config/gpu_utils.h
2+
// Copyright (c) 2025-2026 MobileGL-Dev
3+
// Licensed under the GNU Lesser General Public License v2.1:
4+
// https://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt
5+
// SPDX-License-Identifier: LGPL-2.1-only
6+
// End of Source File Header
47

58
#ifndef MOBILEGLUES_PLUGIN_GPU_UTILS_H
69
#define MOBILEGLUES_PLUGIN_GPU_UTILS_H
@@ -11,23 +14,24 @@
1114
std::string getGPUInfo();
1215

1316
#ifdef __cplusplus
14-
extern "C" {
17+
extern "C"
18+
{
1519
#endif
1620

17-
int isAdreno(const char *gpu);
21+
int isAdreno(const char* gpu);
1822

19-
int isAdreno730(const char *gpu);
23+
int isAdreno730(const char* gpu);
2024

21-
int isAdreno740(const char *gpu);
25+
int isAdreno740(const char* gpu);
2226

23-
int isAdreno830(const char *gpu);
27+
int isAdreno830(const char* gpu);
2428

25-
int hasVulkan12();
29+
int hasVulkan12();
2630

27-
bool checkIfANGLESupported(const char* gpu);
31+
bool checkIfANGLESupported(const char* gpu);
2832

2933
#ifdef __cplusplus
3034
}
3135
#endif
3236

33-
#endif //MOBILEGLUES_PLUGIN_GPU_UTILS_H
37+
#endif // MOBILEGLUES_PLUGIN_GPU_UTILS_H

src/main/cpp/config/settings.cpp

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
1-
//
2-
// Created by hanji on 2025/2/9.
3-
//
1+
// MobileGlues - config/settings.cpp
2+
// Copyright (c) 2025-2026 MobileGL-Dev
3+
// Licensed under the GNU Lesser General Public License v2.1:
4+
// https://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt
5+
// SPDX-License-Identifier: LGPL-2.1-only
6+
// End of Source File Header
47

58
#include "settings.h"
69
#include "config.h"

src/main/cpp/config/settings.h

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
1-
//
2-
// Created by hanji on 2025/2/9.
3-
//
1+
// MobileGlues - config/settings.h
2+
// Copyright (c) 2025-2026 MobileGL-Dev
3+
// Licensed under the GNU Lesser General Public License v2.1:
4+
// https://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt
5+
// SPDX-License-Identifier: LGPL-2.1-only
6+
// End of Source File Header
47

58
#ifndef MOBILEGLUES_PLUGIN_SETTINGS_H
69
#define MOBILEGLUES_PLUGIN_SETTINGS_H

0 commit comments

Comments
 (0)