diff options
Diffstat (limited to 'include/mbgl/platform')
-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 |