summaryrefslogtreecommitdiff
path: root/src/mbgl/geometry
diff options
context:
space:
mode:
authorKonstantin Käfer <mail@kkaefer.com>2015-08-14 18:12:04 +0300
committerKonstantin Käfer <mail@kkaefer.com>2015-08-19 14:42:09 -0400
commit90bae75838f223a88a08a43380b405ec5e373591 (patch)
tree97329f687758cfebb972c0c51628fe766f8d4c37 /src/mbgl/geometry
parent31555bccca9a9565c24e2af94629031bcc2d65f8 (diff)
downloadqtlocation-mapboxgl-90bae75838f223a88a08a43380b405ec5e373591.tar.gz
remove mutex from LineAtlas
we're only ever accessing it from the Map thread, so there's no need for a mutex, even less for a recursive one
Diffstat (limited to 'src/mbgl/geometry')
-rw-r--r--src/mbgl/geometry/line_atlas.cpp8
-rw-r--r--src/mbgl/geometry/line_atlas.hpp5
2 files changed, 5 insertions, 8 deletions
diff --git a/src/mbgl/geometry/line_atlas.cpp b/src/mbgl/geometry/line_atlas.cpp
index 0c16294d53..aeac3067e9 100644
--- a/src/mbgl/geometry/line_atlas.cpp
+++ b/src/mbgl/geometry/line_atlas.cpp
@@ -20,7 +20,7 @@ LineAtlas::LineAtlas(uint16_t w, uint16_t h)
}
LineAtlas::~LineAtlas() {
- std::lock_guard<std::recursive_mutex> lock(mtx);
+ assert(util::ThreadContext::currentlyOn(util::ThreadType::Map));
if (texture) {
mbgl::util::ThreadContext::getGLObjectStore()->abandonTexture(texture);
@@ -29,14 +29,14 @@ LineAtlas::~LineAtlas() {
}
LinePatternPos LineAtlas::getDashPosition(const std::vector<float> &dasharray, bool round) {
+ assert(util::ThreadContext::currentlyOn(util::ThreadType::Map));
+
size_t key = round ? std::numeric_limits<size_t>::min() : std::numeric_limits<size_t>::max();
for (const float part : dasharray) {
boost::hash_combine<float>(key, part);
}
// Note: We're not handling hash collisions here.
-
- std::lock_guard<std::recursive_mutex> lock(mtx);
const auto it = positions.find(key);
if (it == positions.end()) {
auto inserted = positions.emplace(key, addDash(dasharray, round));
@@ -137,7 +137,7 @@ void LineAtlas::upload() {
}
void LineAtlas::bind() {
- std::lock_guard<std::recursive_mutex> lock(mtx);
+ assert(util::ThreadContext::currentlyOn(util::ThreadType::Map));
bool first = false;
if (!texture) {
diff --git a/src/mbgl/geometry/line_atlas.hpp b/src/mbgl/geometry/line_atlas.hpp
index 7075a932b5..3c3b90f752 100644
--- a/src/mbgl/geometry/line_atlas.hpp
+++ b/src/mbgl/geometry/line_atlas.hpp
@@ -4,8 +4,6 @@
#include <vector>
#include <map>
#include <memory>
-#include <mutex>
-#include <atomic>
namespace mbgl {
@@ -34,9 +32,8 @@ public:
const int height;
private:
- std::recursive_mutex mtx;
const std::unique_ptr<uint8_t[]> data;
- std::atomic<bool> dirty;
+ bool dirty;
uint32_t texture = 0;
int nextRow = 0;
std::map<size_t, LinePatternPos> positions;