summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn Firebaugh <john.firebaugh@gmail.com>2016-06-06 17:06:51 -0700
committerKonstantin Käfer <mail@kkaefer.com>2016-06-10 12:42:14 +0200
commitdbf16440a6ae8dedc408d8345e1527a516a42a1d (patch)
treedf641cd7cb77194771439bf85d0eb7534df79d15
parentc3a8534a4308474a4b6cad09785d53ab43cb6f6a (diff)
downloadqtlocation-mapboxgl-dbf16440a6ae8dedc408d8345e1527a516a42a1d.tar.gz
[core] Eliminate Source dependency on TileSource
-rw-r--r--src/mbgl/style/source.cpp7
-rw-r--r--src/mbgl/tile/tile_data.cpp4
-rw-r--r--src/mbgl/tile/tile_data.hpp10
3 files changed, 15 insertions, 6 deletions
diff --git a/src/mbgl/style/source.cpp b/src/mbgl/style/source.cpp
index 7e012727dd..d7752ed371 100644
--- a/src/mbgl/style/source.cpp
+++ b/src/mbgl/style/source.cpp
@@ -2,7 +2,6 @@
#include <mbgl/style/source_observer.hpp>
#include <mbgl/map/transform.hpp>
#include <mbgl/tile/tile.hpp>
-#include <mbgl/tile/tile_source.hpp>
#include <mbgl/renderer/painter.hpp>
#include <mbgl/util/exception.hpp>
#include <mbgl/util/constants.hpp>
@@ -244,8 +243,8 @@ bool Source::update(const UpdateParameters& parameters) {
auto retainTileDataFn = [&retain](TileData& tileData, bool required) -> void {
retain.emplace(tileData.id);
- tileData.getTileSource()->setNecessity(required ? TileSource::Necessity::Required
- : TileSource::Necessity::Optional);
+ tileData.setNecessity(required ? TileData::Necessity::Required
+ : TileData::Necessity::Optional);
};
auto getTileDataFn = [this](const OverscaledTileID& dataTileID) -> TileData* {
return getTileData(dataTileID);
@@ -288,7 +287,7 @@ bool Source::update(const UpdateParameters& parameters) {
auto retainIt = retain.begin();
while (dataIt != tileDataMap.end()) {
if (retainIt == retain.end() || dataIt->first < *retainIt) {
- dataIt->second->getTileSource()->setNecessity(TileSource::Necessity::Optional);
+ dataIt->second->setNecessity(TileData::Necessity::Optional);
cache.add(dataIt->first, std::move(dataIt->second));
tileDataMap.erase(dataIt++);
} else {
diff --git a/src/mbgl/tile/tile_data.cpp b/src/mbgl/tile/tile_data.cpp
index a64de4d1eb..19ff48a897 100644
--- a/src/mbgl/tile/tile_data.cpp
+++ b/src/mbgl/tile/tile_data.cpp
@@ -24,6 +24,10 @@ void TileData::setTileSource(std::unique_ptr<TileSource> tileSource_) {
tileSource = std::move(tileSource_);
}
+void TileData::setNecessity(Necessity necessity) {
+ tileSource->setNecessity(static_cast<TileSource::Necessity>(necessity));
+}
+
void TileData::setTriedOptional() {
triedOptional = true;
observer->onNeedsRepaint();
diff --git a/src/mbgl/tile/tile_data.hpp b/src/mbgl/tile/tile_data.hpp
index d22e871185..9dd44b0379 100644
--- a/src/mbgl/tile/tile_data.hpp
+++ b/src/mbgl/tile/tile_data.hpp
@@ -32,8 +32,13 @@ public:
virtual ~TileData();
void setObserver(TileDataObserver* observer);
- void setTileSource(std::unique_ptr<TileSource>);
- TileSource* getTileSource() { return tileSource.get(); }
+
+ enum class Necessity : bool {
+ Optional = false,
+ Required = true,
+ };
+
+ void setNecessity(Necessity);
// Mark this tile as no longer needed and cancel any pending work.
virtual void cancel() = 0;
@@ -99,6 +104,7 @@ protected:
DataAvailability availableData = DataAvailability::None;
+ void setTileSource(std::unique_ptr<TileSource>);
std::unique_ptr<TileSource> tileSource;
TileDataObserver* observer = nullptr;