summaryrefslogtreecommitdiff
path: root/platform/linux
diff options
context:
space:
mode:
authorKonstantin Käfer <mail@kkaefer.com>2017-11-27 17:25:20 +0100
committerKonstantin Käfer <mail@kkaefer.com>2017-11-29 15:48:51 +0100
commit2eec5a19803a01e21d5793706ae69ac0d886cee5 (patch)
treefb0f1464f1e73eca49dd062dfd70770e84ec6b8b /platform/linux
parent335f04f7e13422ce53cbbf13cebb8283149faba8 (diff)
downloadqtlocation-mapboxgl-2eec5a19803a01e21d5793706ae69ac0d886cee5.tar.gz
[core] move HeadlessBackend extension initialization code into Impl
Diffstat (limited to 'platform/linux')
-rw-r--r--platform/linux/src/headless_backend_egl.cpp21
-rw-r--r--platform/linux/src/headless_backend_glx.cpp21
2 files changed, 22 insertions, 20 deletions
diff --git a/platform/linux/src/headless_backend_egl.cpp b/platform/linux/src/headless_backend_egl.cpp
index 7d3a3d1ec1..089e344987 100644
--- a/platform/linux/src/headless_backend_egl.cpp
+++ b/platform/linux/src/headless_backend_egl.cpp
@@ -66,8 +66,9 @@ public:
EGLConfig config = 0;
};
-struct EGLImpl : public HeadlessBackend::Impl {
- EGLImpl() {
+class EGLBackendImpl : public HeadlessBackend::Impl {
+public:
+ EGLBackendImpl() {
// EGL initializes the context client version to 1 by default. We want to
// use OpenGL ES 2.0 which has the ability to create shader and program
// objects and also to write vertex and fragment shaders in the OpenGL ES
@@ -101,7 +102,7 @@ struct EGLImpl : public HeadlessBackend::Impl {
}
}
- ~EGLImpl() final {
+ ~EGLBackendImpl() final {
if (eglSurface != EGL_NO_SURFACE) {
if (!eglDestroySurface(eglDisplay->display, eglSurface)) {
Log::Error(Event::OpenGL, "Failed to destroy EGL surface.");
@@ -113,6 +114,10 @@ struct EGLImpl : public HeadlessBackend::Impl {
}
}
+ gl::ProcAddress getExtensionFunctionPointer(const char* name) final {
+ return eglGetProcAddress(name);
+ }
+
void activateContext() final {
if (!eglMakeCurrent(eglDisplay->display, eglSurface, eglSurface, eglContext)) {
throw std::runtime_error("Switching OpenGL context failed.\n");
@@ -131,13 +136,9 @@ private:
EGLSurface eglSurface = EGL_NO_SURFACE;
};
-gl::ProcAddress HeadlessBackend::initializeExtension(const char* name) {
- return eglGetProcAddress(name);
-}
-
-void HeadlessBackend::createContext() {
- assert(!hasContext());
- impl = std::make_unique<EGLImpl>();
+void HeadlessBackend::createImpl() {
+ assert(!impl);
+ impl = std::make_unique<EGLBackendImpl>();
}
} // namespace mbgl
diff --git a/platform/linux/src/headless_backend_glx.cpp b/platform/linux/src/headless_backend_glx.cpp
index 6d2939da0f..27af98e70a 100644
--- a/platform/linux/src/headless_backend_glx.cpp
+++ b/platform/linux/src/headless_backend_glx.cpp
@@ -70,8 +70,9 @@ public:
GLXFBConfig* fbConfigs = nullptr;
};
-struct GLXImpl : public HeadlessBackend::Impl {
- GLXImpl() {
+class GLXBackendImpl : public HeadlessBackend::Impl {
+public:
+ GLXBackendImpl() {
// Try to create a legacy context.
glContext = glXCreateNewContext(glxDisplay->xDisplay, glxDisplay->fbConfigs[0],
GLX_RGBA_TYPE, None, True);
@@ -91,13 +92,17 @@ struct GLXImpl : public HeadlessBackend::Impl {
glXCreatePbuffer(glxDisplay->xDisplay, glxDisplay->fbConfigs[0], pbufferAttributes);
}
- ~GLXImpl() final {
+ ~GLXBackendImpl() final {
if (glxPbuffer) {
glXDestroyPbuffer(glxDisplay->xDisplay, glxPbuffer);
}
glXDestroyContext(glxDisplay->xDisplay, glContext);
}
+ gl::ProcAddress getExtensionFunctionPointer(const char* name) final {
+ return glXGetProcAddress(reinterpret_cast<const GLubyte*>(name));
+ }
+
void activateContext() final {
if (!glXMakeContextCurrent(glxDisplay->xDisplay, glxPbuffer, glxPbuffer, glContext)) {
throw std::runtime_error("Switching OpenGL context failed.\n");
@@ -117,13 +122,9 @@ private:
GLXPbuffer glxPbuffer = 0;
};
-gl::ProcAddress HeadlessBackend::initializeExtension(const char* name) {
- return glXGetProcAddress(reinterpret_cast<const GLubyte*>(name));
-}
-
-void HeadlessBackend::createContext() {
- assert(!hasContext());
- impl = std::make_unique<GLXImpl>();
+void HeadlessBackend::createImpl() {
+ assert(!impl);
+ impl = std::make_unique<GLXBackendImpl>();
}
} // namespace mbgl