summaryrefslogtreecommitdiff
path: root/platform/default/headless_backend_osmesa.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/default/headless_backend_osmesa.cpp
parent335f04f7e13422ce53cbbf13cebb8283149faba8 (diff)
downloadqtlocation-mapboxgl-2eec5a19803a01e21d5793706ae69ac0d886cee5.tar.gz
[core] move HeadlessBackend extension initialization code into Impl
Diffstat (limited to 'platform/default/headless_backend_osmesa.cpp')
-rw-r--r--platform/default/headless_backend_osmesa.cpp21
1 files changed, 11 insertions, 10 deletions
diff --git a/platform/default/headless_backend_osmesa.cpp b/platform/default/headless_backend_osmesa.cpp
index 4cb0bfc5c4..0da1caf9af 100644
--- a/platform/default/headless_backend_osmesa.cpp
+++ b/platform/default/headless_backend_osmesa.cpp
@@ -7,8 +7,9 @@
namespace mbgl {
-struct OSMesaImpl : public HeadlessBackend::Impl {
- OSMesaImpl() {
+class OSMesaBackendImpl : public HeadlessBackend::Impl {
+public:
+ OSMesaBackendImpl() {
#if OSMESA_MAJOR_VERSION * 100 + OSMESA_MINOR_VERSION >= 305
glContext = OSMesaCreateContextExt(OSMESA_RGBA, 16, 0, 0, nullptr);
#else
@@ -19,10 +20,14 @@ struct OSMesaImpl : public HeadlessBackend::Impl {
}
}
- ~OSMesaImpl() final {
+ ~OSMesaBackendImpl() final {
OSMesaDestroyContext(glContext);
}
+ gl::ProcAddress getExtensionFunctionPointer(const char* name) final {
+ return OSMesaGetProcAddress(name);
+ }
+
void activateContext() final {
if (!OSMesaMakeCurrent(glContext, &fakeBuffer, GL_UNSIGNED_BYTE, 1, 1)) {
throw std::runtime_error("Switching OpenGL context failed.\n");
@@ -34,13 +39,9 @@ private:
GLubyte fakeBuffer = 0;
};
-gl::ProcAddress HeadlessBackend::initializeExtension(const char* name) {
- return OSMesaGetProcAddress(name);
-}
-
-void HeadlessBackend::createContext() {
- assert(!hasContext());
- impl = std::make_unique<OSMesaImpl>();
+void HeadlessBackend::createImpl() {
+ assert(!impl);
+ impl = std::make_unique<OSMesaBackendImpl>();
}
} // namespace mbgl