summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Morris <michael.patrick.morris@gmail.com>2014-10-07 16:26:21 -0400
committerMike Morris <michael.patrick.morris@gmail.com>2014-10-07 16:26:21 -0400
commit36b7bb0c0991b3c5c3a7d001139b120bee854484 (patch)
tree43e259265c7d3d6d1afcae177313adcbffd50295
parent5cc6b26229597ef78bd87d21367b75f2051b7314 (diff)
downloadqtlocation-mapboxgl-36b7bb0c0991b3c5c3a7d001139b120bee854484.tar.gz
clean up shared_ptr usage in HeadlessView
-rw-r--r--common/headless_view.cpp12
-rw-r--r--common/headless_view.hpp4
-rw-r--r--test/headless.cpp5
3 files changed, 12 insertions, 9 deletions
diff --git a/common/headless_view.cpp b/common/headless_view.cpp
index b8a2fa360b..d11f63dbd5 100644
--- a/common/headless_view.cpp
+++ b/common/headless_view.cpp
@@ -5,18 +5,18 @@
namespace mbgl {
-HeadlessView::HeadlessView() : display_ptr_(std::make_shared<HeadlessDisplay>()) {
+HeadlessView::HeadlessView() : display_(std::make_shared<HeadlessDisplay>()) {
createContext();
}
-HeadlessView::HeadlessView(std::shared_ptr<HeadlessDisplay> display_ptr)
- : display_ptr_(display_ptr) {
+HeadlessView::HeadlessView(std::shared_ptr<HeadlessDisplay> display)
+ : display_(display) {
createContext();
}
void HeadlessView::createContext() {
#if MBGL_USE_CGL
- CGLError error = CGLCreateContext(display_ptr_->pixelFormat, NULL, &gl_context);
+ CGLError error = CGLCreateContext(display_->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_ptr_->x_display;
- x_info = display_ptr_->x_info;
+ x_display = display_->x_display;
+ x_info = display_->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 3ad5a669a5..13a5b01099 100644
--- a/common/headless_view.hpp
+++ b/common/headless_view.hpp
@@ -20,7 +20,7 @@ class HeadlessDisplay;
class HeadlessView : public View {
public:
HeadlessView();
- HeadlessView(std::shared_ptr<HeadlessDisplay> display_ptr);
+ HeadlessView(std::shared_ptr<HeadlessDisplay> display);
~HeadlessView();
void createContext();
@@ -38,7 +38,7 @@ private:
private:
- std::shared_ptr<HeadlessDisplay> display_ptr_;
+ std::shared_ptr<HeadlessDisplay> display_;
#if MBGL_USE_CGL
CGLContextObj gl_context;
diff --git a/test/headless.cpp b/test/headless.cpp
index d4c4d6036e..981a9dcd59 100644
--- a/test/headless.cpp
+++ b/test/headless.cpp
@@ -10,6 +10,7 @@
#include <rapidjson/stringbuffer.h>
#include "../common/headless_view.hpp"
+#include "../common/headless_display.hpp"
#include "./fixtures/fixture_log.hpp"
@@ -22,6 +23,8 @@ const std::string base_directory = []{
return fn + "/node_modules/mapbox-gl-test-suite/";
}();
+auto display_ = std::make_shared<mbgl::HeadlessDisplay>();
+
class HeadlessTest : public ::testing::TestWithParam<std::string> {};
TEST_P(HeadlessTest, render) {
@@ -78,7 +81,7 @@ TEST_P(HeadlessTest, render) {
}
}
- HeadlessView view;
+ HeadlessView view(display_);
Map map(view);
map.setStyleJSON(style, base_directory);