summaryrefslogtreecommitdiff
path: root/platform/linux/src/headless_backend_egl.cpp
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/src/headless_backend_egl.cpp
parent335f04f7e13422ce53cbbf13cebb8283149faba8 (diff)
downloadqtlocation-mapboxgl-2eec5a19803a01e21d5793706ae69ac0d886cee5.tar.gz
[core] move HeadlessBackend extension initialization code into Impl
Diffstat (limited to 'platform/linux/src/headless_backend_egl.cpp')
-rw-r--r--platform/linux/src/headless_backend_egl.cpp21
1 files changed, 11 insertions, 10 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