#pragma once #include #if MBGL_USE_QT class QGLWidget; #elif MBGL_USE_CGL #include #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 #endif #include #include #include #include namespace mbgl { class HeadlessDisplay; class HeadlessBackend : public Backend { public: HeadlessBackend(); HeadlessBackend(std::shared_ptr); ~HeadlessBackend() override; void invalidate() override; void activate() override; void deactivate() override; void notifyMapChange(MapChange) override; void setMapChangeCallback(std::function&& cb) { mapChangeCallback = std::move(cb); } private: void activateContext(); void deactivateContext(); private: // Implementation specific functions static gl::glProc initializeExtension(const char*); void createContext(); void destroyContext(); std::shared_ptr 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 mapChangeCallback; }; } // namespace mbgl