diff options
-rw-r--r-- | common/headless_view.cpp | 12 | ||||
-rw-r--r-- | common/headless_view.hpp | 6 |
2 files changed, 10 insertions, 8 deletions
diff --git a/common/headless_view.cpp b/common/headless_view.cpp index cd8ee685d5..5e8770b7a7 100644 --- a/common/headless_view.cpp +++ b/common/headless_view.cpp @@ -5,18 +5,18 @@ namespace mbgl { -HeadlessView::HeadlessView() : display_(new HeadlessDisplay()) { +HeadlessView::HeadlessView() : display_ptr(std::make_shared<HeadlessDisplay>()) { createContext(); } -HeadlessView::HeadlessView(HeadlessDisplay *display) - : display_(display) { +HeadlessView::HeadlessView(HeadlessDisplay &display) + : display_ptr(std::make_shared<HeadlessDisplay>(display)) { createContext(); } void HeadlessView::createContext() { #if MBGL_USE_CGL - CGLError error = CGLCreateContext(display_->pixelFormat, NULL, &gl_context); + CGLError error = CGLCreateContext(display_ptr->pixelFormat, NULL, &gl_context); if (error) { fprintf(stderr, "Error creating GL context object\n"); return; @@ -30,8 +30,8 @@ void HeadlessView::createContext() { #endif #if MBGL_USE_GLX - x_display = display_->x_display; - x_info = display_->x_info; + x_display = display_ptr->x_display; + x_info = display_ptr->x_info; gl_context = glXCreateContext(x_display, x_info, 0, GL_TRUE); if (gl_context == nullptr) { diff --git a/common/headless_view.hpp b/common/headless_view.hpp index cef4213e90..5303f2c104 100644 --- a/common/headless_view.hpp +++ b/common/headless_view.hpp @@ -11,6 +11,8 @@ #include <mbgl/map/view.hpp> #include <mbgl/platform/gl.hpp> +#include <memory> + namespace mbgl { class HeadlessDisplay; @@ -18,7 +20,7 @@ class HeadlessDisplay; class HeadlessView : public View { public: HeadlessView(); - HeadlessView(HeadlessDisplay *display); + HeadlessView(HeadlessDisplay &display); ~HeadlessView(); void createContext(); @@ -36,7 +38,7 @@ private: private: - HeadlessDisplay *display_; + std::shared_ptr<HeadlessDisplay> display_ptr; #if MBGL_USE_CGL CGLContextObj gl_context; |