diff options
author | Bruno de Oliveira Abinader <bruno@mapbox.com> | 2016-11-06 20:39:13 +0200 |
---|---|---|
committer | Bruno de Oliveira Abinader <bruno@mapbox.com> | 2016-11-08 18:02:38 +0200 |
commit | d0ac12309b470eb59690ece3f15773df73a127e1 (patch) | |
tree | cfb7939f6d3ac7f1656966142b8b6f548ab6389f /include | |
parent | 297c303e88416274d3d2c14b5f6abf1c850c3cf8 (diff) | |
download | qtlocation-mapboxgl-d0ac12309b470eb59690ece3f15773df73a127e1.tar.gz |
[core] Refactor HeadlessBackend
Diffstat (limited to 'include')
-rw-r--r-- | include/mbgl/platform/default/headless_backend.hpp | 59 |
1 files changed, 16 insertions, 43 deletions
diff --git a/include/mbgl/platform/default/headless_backend.hpp b/include/mbgl/platform/default/headless_backend.hpp index b6c654943f..2fef321d85 100644 --- a/include/mbgl/platform/default/headless_backend.hpp +++ b/include/mbgl/platform/default/headless_backend.hpp @@ -1,23 +1,9 @@ #pragma once #include <mbgl/gl/implementation.hpp> - -#if MBGL_USE_QT -class QGLWidget; -#elif MBGL_USE_CGL -#include <OpenGL/OpenGL.h> -#elif MBGL_USE_GLX -typedef struct _XDisplay Display; -typedef struct __GLXcontextRec* GLXContext; -typedef struct __GLXFBConfigRec* GLXFBConfig; -typedef long unsigned int XID; -typedef XID GLXPbuffer; -#elif MBGL_USE_OSMESA -#include <GL/osmesa.h> -#endif +#include <mbgl/gl/extension.hpp> #include <mbgl/map/backend.hpp> -#include <mbgl/gl/extension.hpp> #include <memory> #include <functional> @@ -39,47 +25,34 @@ public: void setMapChangeCallback(std::function<void(MapChange)>&& cb) { mapChangeCallback = std::move(cb); } -private: - void activateContext(); - void deactivateContext(); + struct Impl { + virtual ~Impl() {} + virtual void activateContext() = 0; + virtual void deactivateContext() {} + }; private: // Implementation specific functions static gl::glProc initializeExtension(const char*); + + bool hasContext() const { return bool(impl); } + bool hasDisplay(); + void createContext(); + +private: void destroyContext(); + void activateContext(); + void deactivateContext(); + + std::unique_ptr<Impl> impl; std::shared_ptr<HeadlessDisplay> display; bool extensionsLoaded = false; bool active = false; -#if MBGL_USE_QT - QGLWidget* glContext = nullptr; -#endif - -#if MBGL_USE_CGL - CGLContextObj glContext = nullptr; -#endif - -#if MBGL_USE_EAGL - void *glContext = nullptr; -#endif - -#if MBGL_USE_GLX - Display *xDisplay = nullptr; - GLXFBConfig *fbConfigs = nullptr; - GLXContext glContext = nullptr; - GLXPbuffer glxPbuffer = 0; -#endif - -#if MBGL_USE_OSMESA - OSMesaContext glContext = nullptr; - GLubyte fakeBuffer = 0; -#endif - std::function<void(MapChange)> mapChangeCallback; - }; } // namespace mbgl |