summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJohn Firebaugh <john.firebaugh@gmail.com>2015-11-19 16:08:18 -0800
committerJohn Firebaugh <john.firebaugh@gmail.com>2015-12-01 09:15:05 -0800
commit58886842bc381cd30bac7102d4f70497c0128aa7 (patch)
tree572ffb0f76aa4bcb6a86ef4ea506335adf636309 /src
parent40ebf5d0d08138c353d7c0e4bc61ee53dceae410 (diff)
downloadqtlocation-mapboxgl-58886842bc381cd30bac7102d4f70497c0128aa7.tar.gz
[core] Move MapData storage to MapContext
This allows MapData members to hold GL resources which must be released on the MapContext thread -- necessary for the following commit.
Diffstat (limited to 'src')
-rw-r--r--src/mbgl/map/map.cpp6
-rw-r--r--src/mbgl/map/map_context.cpp6
-rw-r--r--src/mbgl/map/map_context.hpp6
3 files changed, 13 insertions, 5 deletions
diff --git a/src/mbgl/map/map.cpp b/src/mbgl/map/map.cpp
index 57f8c3e7f3..08265ae1e8 100644
--- a/src/mbgl/map/map.cpp
+++ b/src/mbgl/map/map.cpp
@@ -17,8 +17,10 @@ namespace mbgl {
Map::Map(View& view_, FileSource& fileSource, MapMode mapMode, GLContextMode contextMode, ConstrainMode constrainMode)
: view(view_),
transform(std::make_unique<Transform>(view, constrainMode)),
- data(std::make_unique<MapData>(mapMode, contextMode, view.getPixelRatio())),
- context(std::make_unique<util::Thread<MapContext>>(util::ThreadContext{"Map", util::ThreadType::Map, util::ThreadPriority::Regular}, view, fileSource, *data))
+ context(std::make_unique<util::Thread<MapContext>>(
+ util::ThreadContext{"Map", util::ThreadType::Map, util::ThreadPriority::Regular},
+ view, fileSource, mapMode, contextMode, view.getPixelRatio())),
+ data(&context->invokeSync<MapData&>(&MapContext::getData))
{
view.initialize(this);
update(Update::Dimensions);
diff --git a/src/mbgl/map/map_context.cpp b/src/mbgl/map/map_context.cpp
index 400b2880da..32cf760afa 100644
--- a/src/mbgl/map/map_context.cpp
+++ b/src/mbgl/map/map_context.cpp
@@ -25,9 +25,10 @@
namespace mbgl {
-MapContext::MapContext(View& view_, FileSource& fileSource, MapData& data_)
+MapContext::MapContext(View& view_, FileSource& fileSource, MapMode mode_, GLContextMode contextMode_, const float pixelRatio_)
: view(view_),
- data(data_),
+ dataPtr(std::make_unique<MapData>(mode_, contextMode_, pixelRatio_)),
+ data(*dataPtr),
asyncUpdate([this] { update(); }),
asyncInvalidate([&view_] { view_.invalidate(); }),
texturePool(std::make_unique<TexturePool>()) {
@@ -57,6 +58,7 @@ void MapContext::cleanup() {
style.reset();
painter.reset();
texturePool.reset();
+ dataPtr.reset();
glObjectStore.performCleanup();
diff --git a/src/mbgl/map/map_context.hpp b/src/mbgl/map/map_context.hpp
index c0ee68a614..06be31ed85 100644
--- a/src/mbgl/map/map_context.hpp
+++ b/src/mbgl/map/map_context.hpp
@@ -5,6 +5,7 @@
#include <mbgl/map/update.hpp>
#include <mbgl/map/transform_state.hpp>
#include <mbgl/map/map.hpp>
+#include <mbgl/map/map_data.hpp>
#include <mbgl/style/style.hpp>
#include <mbgl/util/async_task.hpp>
#include <mbgl/util/gl_object_store.hpp>
@@ -27,9 +28,11 @@ struct FrameData {
class MapContext : public Style::Observer {
public:
- MapContext(View&, FileSource&, MapData&);
+ MapContext(View&, FileSource&, MapMode, GLContextMode, const float pixelRatio);
~MapContext();
+ MapData& getData() { return data; }
+
void pause();
void triggerUpdate(const TransformState&, Update = Update::Nothing);
@@ -69,6 +72,7 @@ private:
void loadStyleJSON(const std::string& json, const std::string& base);
View& view;
+ std::unique_ptr<MapData> dataPtr;
MapData& data;
util::GLObjectStore glObjectStore;