From 042f21da5cc1598e19bd28d729a2deaa0bae253f Mon Sep 17 00:00:00 2001 From: Akash Mohan Chaudhary <30294175+hadt0786@users.noreply.github.com> Date: Mon, 7 Sep 2026 02:32:21 +0530 Subject: [PATCH] Rename OpenGL event to GraphicsBackend (#4515) --- include/mln/util/event.hpp | 2 +- platform/darwin/src/headless_backend_cgl.mm | 2 +- platform/glfw/glfw_view.cpp | 9 ++-- platform/linux/src/headless_backend_egl.cpp | 8 ++-- platform/linux/src/headless_backend_glx.cpp | 2 +- platform/windows/src/headless_backend_egl.cpp | 8 ++-- platform/windows/src/headless_backend_wgl.cpp | 42 +++++++++---------- src/mln/gl/debugging_extension.cpp | 2 +- src/mln/platform/gl_functions.cpp | 2 +- src/mln/renderer/render_layer.cpp | 4 +- src/mln/shaders/gl/legacy/program_base.hpp | 2 +- src/mln/util/event.cpp | 2 +- 12 files changed, 43 insertions(+), 42 deletions(-) diff --git a/include/mln/util/event.hpp b/include/mln/util/event.hpp index 1c2c1e180..2f35102a1 100644 --- a/include/mln/util/event.hpp +++ b/include/mln/util/event.hpp @@ -24,7 +24,7 @@ enum class Event : uint8_t { HttpRequest, Sprite, Image, - OpenGL, + GraphicsBackend, JNI, Android, Crash, diff --git a/platform/darwin/src/headless_backend_cgl.mm b/platform/darwin/src/headless_backend_cgl.mm index 197c597e2..4d0171ade 100644 --- a/platform/darwin/src/headless_backend_cgl.mm +++ b/platform/darwin/src/headless_backend_cgl.mm @@ -51,7 +51,7 @@ public: ~CGLDisplayConfig() { const CGLError error = CGLDestroyPixelFormat(pixelFormat); if (error != kCGLNoError) { - Log::Error(Event::OpenGL, + Log::Error(Event::GraphicsBackend, std::string("Error destroying pixel format:") + CGLErrorString(error)); } } diff --git a/platform/glfw/glfw_view.cpp b/platform/glfw/glfw_view.cpp index 5df17a795..ec5b55b2a 100644 --- a/platform/glfw/glfw_view.cpp +++ b/platform/glfw/glfw_view.cpp @@ -175,7 +175,7 @@ void tileLodZoomShift(mln::Map &map, bool positive) { auto shift = positive ? tileLodZoomShiftStep : -tileLodZoomShiftStep; shift = map.getTileLodZoomShift() + shift; shift = mln::util::clamp(shift, -2.5, 2.5); - mln::Log::Info(mln::Event::OpenGL, "Zoom shift: " + std::to_string(shift)); + mln::Log::Info(mln::Event::GraphicsBackend, "Zoom shift: " + std::to_string(shift)); map.setTileLodZoomShift(shift); map.triggerRepaint(); } @@ -216,7 +216,8 @@ void addFillExtrusionLayer(mln::style::Style &style, bool visible) { } // namespace void glfwError(int error, const char *description) { - mln::Log::Error(mln::Event::OpenGL, std::string("GLFW error (") + std::to_string(error) + "): " + description); + mln::Log::Error(mln::Event::GraphicsBackend, + std::string("GLFW error (") + std::to_string(error) + "): " + description); } GLFWView::GLFWView(bool fullscreen_, @@ -242,7 +243,7 @@ GLFWView::GLFWView(bool fullscreen_, #endif if (!glfwInit()) { - mln::Log::Error(mln::Event::OpenGL, "failed to initialize glfw"); + mln::Log::Error(mln::Event::GraphicsBackend, "failed to initialize glfw"); exit(1); } @@ -288,7 +289,7 @@ GLFWView::GLFWView(bool fullscreen_, window = glfwCreateWindow(width, height, "MapLibre Native", monitor, nullptr); if (!window) { glfwTerminate(); - mln::Log::Error(mln::Event::OpenGL, "failed to initialize window"); + mln::Log::Error(mln::Event::GraphicsBackend, "failed to initialize window"); exit(1); } diff --git a/platform/linux/src/headless_backend_egl.cpp b/platform/linux/src/headless_backend_egl.cpp index 11d00516a..4f5ec7c62 100644 --- a/platform/linux/src/headless_backend_egl.cpp +++ b/platform/linux/src/headless_backend_egl.cpp @@ -34,7 +34,7 @@ public: } if (!eglBindAPI(EGL_OPENGL_ES_API)) { - mln::Log::Error(mln::Event::OpenGL, + mln::Log::Error(mln::Event::GraphicsBackend, "eglBindAPI(EGL_OPENGL_ES_API) returned error " + std::to_string(eglGetError())); throw std::runtime_error("eglBindAPI() failed"); } @@ -75,7 +75,7 @@ public: if (eglContext == EGL_NO_CONTEXT) { std::ostringstream logMsg; logMsg << "eglCreateContext() returned error 0x" << std::hex << eglGetError(); - mln::Log::Error(mln::Event::OpenGL, logMsg.str()); + mln::Log::Error(mln::Event::GraphicsBackend, logMsg.str()); throw std::runtime_error("Error creating the EGL context object.\n"); } @@ -95,12 +95,12 @@ public: ~EGLBackendImpl() final { if (eglSurface != EGL_NO_SURFACE) { if (!eglDestroySurface(eglDisplay->display, eglSurface)) { - Log::Error(Event::OpenGL, "Failed to destroy EGL surface."); + Log::Error(Event::GraphicsBackend, "Failed to destroy EGL surface."); } eglSurface = EGL_NO_SURFACE; } if (!eglDestroyContext(eglDisplay->display, eglContext)) { - Log::Error(Event::OpenGL, "Failed to destroy EGL context."); + Log::Error(Event::GraphicsBackend, "Failed to destroy EGL context."); } } diff --git a/platform/linux/src/headless_backend_glx.cpp b/platform/linux/src/headless_backend_glx.cpp index 2e0cfd29c..59104e49d 100644 --- a/platform/linux/src/headless_backend_glx.cpp +++ b/platform/linux/src/headless_backend_glx.cpp @@ -97,7 +97,7 @@ public: // Try to create a legacy context. glContext = glXCreateNewContext(glxDisplay->xDisplay, glxDisplay->fbConfigs[0], GLX_RGBA_TYPE, None, True); if (glContext && !glXIsDirect(glxDisplay->xDisplay, glContext)) { - Log::Error(Event::OpenGL, "failed to create direct OpenGL Legacy context"); + Log::Error(Event::GraphicsBackend, "failed to create direct OpenGL Legacy context"); glXDestroyContext(glxDisplay->xDisplay, glContext); glContext = nullptr; } diff --git a/platform/windows/src/headless_backend_egl.cpp b/platform/windows/src/headless_backend_egl.cpp index d6ecfa6c6..a57ccb756 100644 --- a/platform/windows/src/headless_backend_egl.cpp +++ b/platform/windows/src/headless_backend_egl.cpp @@ -37,7 +37,7 @@ public: if (!eglBindAPI(EGL_OPENGL_ES_API)) { std::ostringstream logMsg; logMsg << "eglBindAPI(EGL_OPENGL_ES_API) returned error " << eglGetError(); - mln::Log::Error(mln::Event::OpenGL, logMsg.str()); + mln::Log::Error(mln::Event::GraphicsBackend, logMsg.str()); throw std::runtime_error("eglBindAPI() failed"); } @@ -78,7 +78,7 @@ public: std::ostringstream logMsg; logMsg << "eglCreateContext() returned error 0x" << std::setw(4) << std::setfill('0') << std::hex << eglGetError(); - mln::Log::Error(mln::Event::OpenGL, logMsg.str()); + mln::Log::Error(mln::Event::GraphicsBackend, logMsg.str()); throw std::runtime_error("Error creating the EGL context object.\n"); } @@ -97,12 +97,12 @@ public: ~EGLBackendImpl() final { if (eglSurface != EGL_NO_SURFACE) { if (!eglDestroySurface(eglDisplay->display, eglSurface)) { - Log::Error(Event::OpenGL, "Failed to destroy EGL surface."); + Log::Error(Event::GraphicsBackend, "Failed to destroy EGL surface."); } eglSurface = EGL_NO_SURFACE; } if (!eglDestroyContext(eglDisplay->display, eglContext)) { - Log::Error(Event::OpenGL, "Failed to destroy EGL context."); + Log::Error(Event::GraphicsBackend, "Failed to destroy EGL context."); } } diff --git a/platform/windows/src/headless_backend_wgl.cpp b/platform/windows/src/headless_backend_wgl.cpp index efe9310d6..1722fb13b 100644 --- a/platform/windows/src/headless_backend_wgl.cpp +++ b/platform/windows/src/headless_backend_wgl.cpp @@ -40,7 +40,7 @@ private: GetModuleHandleExA(0, NULL, &helperWindowClass.hInstance); if (!RegisterClassExA(&helperWindowClass)) { - Log::Error(Event::OpenGL, "Failed to register helper window class"); + Log::Error(Event::GraphicsBackend, "Failed to register helper window class"); throw std::runtime_error("Failed to register helper window class"); } @@ -58,7 +58,7 @@ private: NULL); if (!helperWindowHandle) { - Log::Error(Event::OpenGL, "Failed to create helper window"); + Log::Error(Event::GraphicsBackend, "Failed to create helper window"); throw std::runtime_error("Failed to create helper window"); } @@ -141,14 +141,14 @@ public: // the default surface anyway; all rendering will be directed to // framebuffers which have their own configuration. if (!SetPixelFormat(dummyDC, ChoosePixelFormat(dummyDC, &pfd), &pfd)) { - Log::Error(Event::OpenGL, "Failed to set pixel format for dummy context"); + Log::Error(Event::GraphicsBackend, "Failed to set pixel format for dummy context"); throw std::runtime_error("Failed to set pixel format for dummy context"); } dummyRC = wglCreateContext(dummyDC); if (!dummyRC) { - Log::Error(Event::OpenGL, "Failed to create dummy context"); + Log::Error(Event::GraphicsBackend, "Failed to create dummy context"); throw std::runtime_error("Failed to create dummy context"); } @@ -161,7 +161,7 @@ public: DestroyHelperWindow(); - Log::Error(Event::OpenGL, "Failed to make dummy context current"); + Log::Error(Event::GraphicsBackend, "Failed to make dummy context current"); throw std::runtime_error("Failed to make dummy context current"); } @@ -173,7 +173,7 @@ public: ARB_ES3_compatibility = extensionSupportedWGL("GL_ARB_ES3_compatibility"); if (!ARB_create_context || !ARB_create_context_profile || !ARB_ES3_compatibility) { - Log::Error(Event::OpenGL, "OpenGL ES 3.0 is unavailable"); + Log::Error(Event::GraphicsBackend, "OpenGL ES 3.0 is unavailable"); throw std::runtime_error("OpenGL ES 3.0 is unavailable"); } @@ -187,7 +187,7 @@ public: GetModuleHandleExA(0, NULL, &renderingWindowClass.hInstance); if (!RegisterClassExA(&renderingWindowClass)) { - Log::Error(Event::OpenGL, "Failed to register rendering window class"); + Log::Error(Event::GraphicsBackend, "Failed to register rendering window class"); throw std::runtime_error("Failed to register rendering window class"); } } @@ -236,7 +236,7 @@ private: NULL); if (!renderingWindowHandle) { - Log::Error(Event::OpenGL, "Failed to create helper window"); + Log::Error(Event::GraphicsBackend, "Failed to create helper window"); throw std::runtime_error("Failed to create helper window"); } @@ -262,7 +262,7 @@ private: HGLRC GetContext() { if (!(renderingWindowRenderingContext || CreateRenderingContext())) { - Log::Error(Event::OpenGL, "Failed to create rendering context"); + Log::Error(Event::GraphicsBackend, "Failed to create rendering context"); throw std::runtime_error("Failed to create rendering context"); } @@ -305,7 +305,7 @@ private: 1, &pixelFormat, &numFormats)) { - Log::Error(Event::OpenGL, "Failed to choose pixel format for context"); + Log::Error(Event::GraphicsBackend, "Failed to choose pixel format for context"); throw std::runtime_error("Failed to choose pixel format for context"); } @@ -314,12 +314,12 @@ private: pfd.nSize = sizeof(pfd); if (!DescribePixelFormat(renderingWindowDeviceContext, pixelFormat, sizeof(pfd), &pfd)) { - Log::Error(Event::OpenGL, "Failed to retrieve pixel format for context"); + Log::Error(Event::GraphicsBackend, "Failed to retrieve pixel format for context"); throw std::runtime_error("Failed to retrieve pixel format for context"); } if (!SetPixelFormat(renderingWindowDeviceContext, pixelFormat, &pfd)) { - Log::Error(Event::OpenGL, "Failed to set pixel format for context"); + Log::Error(Event::GraphicsBackend, "Failed to set pixel format for context"); throw std::runtime_error("Failed to set pixel format for context"); } @@ -340,20 +340,20 @@ private: const DWORD error = GetLastError(); if (error == (0xc0070000 | ERROR_INVALID_VERSION_ARB)) { - Log::Error(Event::OpenGL, "Driver does not support OpenGL ES version 2.0"); + Log::Error(Event::GraphicsBackend, "Driver does not support OpenGL ES version 2.0"); throw std::runtime_error("Driver does not support OpenGL ES version 2.0"); } else if (error == (0xc0070000 | ERROR_INVALID_PROFILE_ARB)) { - Log::Error(Event::OpenGL, "Driver does not support the requested OpenGL profile"); + Log::Error(Event::GraphicsBackend, "Driver does not support the requested OpenGL profile"); throw std::runtime_error("Driver does not support the requested OpenGL profile"); } else if (error == (0xc0070000 | ERROR_INCOMPATIBLE_DEVICE_CONTEXTS_ARB)) { - Log::Error(Event::OpenGL, + Log::Error(Event::GraphicsBackend, "The share context is not compatible with the " "requested context"); throw std::runtime_error( "The share context is not compatible with the " "requested context"); } else { - Log::Error(Event::OpenGL, "Failed to create OpenGL ES context"); + Log::Error(Event::GraphicsBackend, "Failed to create OpenGL ES context"); throw std::runtime_error("Failed to create OpenGL ES context"); } @@ -363,7 +363,7 @@ private: renderingWindowRenderingContext = wglCreateContext(renderingWindowDeviceContext); if (!renderingWindowRenderingContext) { - Log::Error(Event::OpenGL, "Failed to create OpenGL context"); + Log::Error(Event::GraphicsBackend, "Failed to create OpenGL context"); throw std::runtime_error("Failed to create OpenGL context"); } } @@ -380,13 +380,13 @@ private: bool DestroyRenderingContext() { if (renderingWindowRenderingContext && !wglMakeCurrent(renderingWindowDeviceContext, NULL)) { - Log::Error(Event::OpenGL, "Failed to make context current"); + Log::Error(Event::GraphicsBackend, "Failed to make context current"); // throw std::runtime_error("Failed to make context current"); return false; } if (renderingWindowRenderingContext && !wglDeleteContext(renderingWindowRenderingContext)) { - Log::Error(Event::OpenGL, "Failed to delete current context"); + Log::Error(Event::GraphicsBackend, "Failed to delete current context"); // throw std::runtime_error("Failed to delete current context"); return false; } @@ -414,14 +414,14 @@ public: void activateContext() final { if (renderingWindowRenderingContext && !wglMakeCurrent(renderingWindowDeviceContext, renderingWindowRenderingContext)) { - Log::Error(Event::OpenGL, "Switching OpenGL context failed"); + Log::Error(Event::GraphicsBackend, "Switching OpenGL context failed"); // throw std::runtime_error("Switching OpenGL context failed"); } } void deactivateContext() final { if (renderingWindowRenderingContext && !wglMakeCurrent(NULL, NULL)) { - Log::Error(Event::OpenGL, "Removing OpenGL context failed"); + Log::Error(Event::GraphicsBackend, "Removing OpenGL context failed"); // throw std::runtime_error("Removing OpenGL context failed"); } } diff --git a/src/mln/gl/debugging_extension.cpp b/src/mln/gl/debugging_extension.cpp index 44adb82ca..633957525 100644 --- a/src/mln/gl/debugging_extension.cpp +++ b/src/mln/gl/debugging_extension.cpp @@ -98,7 +98,7 @@ void Debugging::DebugCallback(GLenum source, } const std::string logMsg = "GL_" + strSource + " GL_" + strType + " " + std::to_string(id) + " GL_" + strSeverity + " - " + message; - mln::Log::Record(evtSeverity, mln::Event::OpenGL, logMsg); + mln::Log::Record(evtSeverity, mln::Event::GraphicsBackend, logMsg); } } // namespace extension diff --git a/src/mln/platform/gl_functions.cpp b/src/mln/platform/gl_functions.cpp index 79b0af3cf..9e8e072d3 100644 --- a/src/mln/platform/gl_functions.cpp +++ b/src/mln/platform/gl_functions.cpp @@ -9,7 +9,7 @@ namespace platform { #ifndef NDEBUG void glCheckError(const char* cmd, const char* file, int line) { if (GLenum err = glGetError()) { - Log::Warning(Event::OpenGL, + Log::Warning(Event::GraphicsBackend, "Error" + std::to_string(err) + ": " + cmd + " - " + file + ":" + std::to_string(line)); } } diff --git a/src/mln/renderer/render_layer.cpp b/src/mln/renderer/render_layer.cpp index 9b661068c..48a3fa1d0 100644 --- a/src/mln/renderer/render_layer.cpp +++ b/src/mln/renderer/render_layer.cpp @@ -95,7 +95,7 @@ void RenderLayer::checkRenderability(const PaintParameters& parameters, const ui } if (activeBindingCount > parameters.context.maximumVertexBindingCount) { - Log::Error(Event::OpenGL, + Log::Error(Event::GraphicsBackend, "The layer '" + getID() + "' uses more data-driven properties than the current device " "supports, and will have rendering errors. To ensure " @@ -105,7 +105,7 @@ void RenderLayer::checkRenderability(const PaintParameters& parameters, const ui " fewer data driven properties in this layer."); hasRenderFailures = true; } else if (activeBindingCount > gfx::Context::minimumRequiredVertexBindingCount) { - Log::Warning(Event::OpenGL, + Log::Warning(Event::GraphicsBackend, "The layer '" + getID() + "' uses more data-driven properties than some devices may " "support. " diff --git a/src/mln/shaders/gl/legacy/program_base.hpp b/src/mln/shaders/gl/legacy/program_base.hpp index 9fe4b36b3..c1c9150c6 100644 --- a/src/mln/shaders/gl/legacy/program_base.hpp +++ b/src/mln/shaders/gl/legacy/program_base.hpp @@ -121,7 +121,7 @@ public: gl::AttributeKey::defines(attributeBindings))) .first; } catch (const std::runtime_error& e) { - Log::Error(Event::OpenGL, e.what()); + Log::Error(Event::GraphicsBackend, e.what()); failedInstances.insert(key); return false; } diff --git a/src/mln/util/event.cpp b/src/mln/util/event.cpp index 370ca889c..4a8c0bb5f 100644 --- a/src/mln/util/event.cpp +++ b/src/mln/util/event.cpp @@ -25,7 +25,7 @@ MBGL_DEFINE_ENUM(Event, {Event::HttpRequest, "HttpRequest"}, {Event::Sprite, "Sprite"}, {Event::Image, "Image"}, - {Event::OpenGL, "OpenGL"}, + {Event::GraphicsBackend, "GraphicsBackend"}, {Event::JNI, "JNI"}, {Event::Android, "Android"}, {Event::Crash, "Crash"},