diff options
author | Konstantin Käfer <mail@kkaefer.com> | 2017-11-27 16:34:52 +0100 |
---|---|---|
committer | Konstantin Käfer <mail@kkaefer.com> | 2017-11-29 15:48:51 +0100 |
commit | 335f04f7e13422ce53cbbf13cebb8283149faba8 (patch) | |
tree | 4542c71910cea2f626ac37325a32f9432f1d908b /platform/default/headless_backend_osmesa.cpp | |
parent | 772b9090626731101b82eccacbc3adaa71cc428c (diff) | |
download | qtlocation-mapboxgl-335f04f7e13422ce53cbbf13cebb8283149faba8.tar.gz |
[core] fold HeadlessDisplay into the headless RenderBackend implementation
Diffstat (limited to 'platform/default/headless_backend_osmesa.cpp')
-rw-r--r-- | platform/default/headless_backend_osmesa.cpp | 29 |
1 files changed, 12 insertions, 17 deletions
diff --git a/platform/default/headless_backend_osmesa.cpp b/platform/default/headless_backend_osmesa.cpp index 5042f5ed10..4cb0bfc5c4 100644 --- a/platform/default/headless_backend_osmesa.cpp +++ b/platform/default/headless_backend_osmesa.cpp @@ -8,10 +8,18 @@ namespace mbgl { struct OSMesaImpl : public HeadlessBackend::Impl { - OSMesaImpl(OSMesaContext glContext_) : glContext(glContext_) { + OSMesaImpl() { +#if OSMESA_MAJOR_VERSION * 100 + OSMESA_MINOR_VERSION >= 305 + glContext = OSMesaCreateContextExt(OSMESA_RGBA, 16, 0, 0, nullptr); +#else + glContext = OSMesaCreateContext(OSMESA_RGBA, nullptr); +#endif + if (glContext == nullptr) { + throw std::runtime_error("Error creating GL context object."); + } } - ~OSMesaImpl() { + ~OSMesaImpl() final { OSMesaDestroyContext(glContext); } @@ -21,6 +29,7 @@ struct OSMesaImpl : public HeadlessBackend::Impl { } } +private: OSMesaContext glContext = nullptr; GLubyte fakeBuffer = 0; }; @@ -29,23 +38,9 @@ gl::ProcAddress HeadlessBackend::initializeExtension(const char* name) { return OSMesaGetProcAddress(name); } -bool HeadlessBackend::hasDisplay() { - return true; -}; - void HeadlessBackend::createContext() { assert(!hasContext()); - -#if OSMESA_MAJOR_VERSION * 100 + OSMESA_MINOR_VERSION >= 305 - OSMesaContext glContext = OSMesaCreateContextExt(OSMESA_RGBA, 16, 0, 0, nullptr); -#else - OSMesaContext glContext = OSMesaCreateContext(OSMESA_RGBA, nullptr); -#endif - if (glContext == nullptr) { - throw std::runtime_error("Error creating GL context object."); - } - - impl.reset(new OSMesaImpl(glContext)); + impl = std::make_unique<OSMesaImpl>(); } } // namespace mbgl |