Merge branch 'release-android-v4.1.0'
# Conflicts: # platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/annotations/BaseMarkerViewOptions.java # platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/annotations/MarkerView.java # platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/annotations/MarkerViewManager.java # platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapView.java # platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapboxMap.java # platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/NativeMapView.java # platform/android/src/jni.cpp # src/mbgl/geometry/buffer.hpp # src/mbgl/geometry/glyph_atlas.cpp # src/mbgl/geometry/glyph_atlas.hpp # src/mbgl/geometry/line_atlas.cpp # src/mbgl/geometry/vao.cpp # src/mbgl/gl/gl_object_store.cpp # src/mbgl/gl/gl_object_store.hpp # src/mbgl/renderer/frame_history.cpp # src/mbgl/shader/shader.cpp # src/mbgl/sprite/sprite_atlas.cpp # src/mbgl/sprite/sprite_atlas.hpp # src/mbgl/text/glyph_pbf.hpp
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
|
||||
#include <mbgl/geometry/binpack.hpp>
|
||||
#include <mbgl/text/glyph_store.hpp>
|
||||
#include <mbgl/util/atomic.hpp>
|
||||
#include <mbgl/util/noncopyable.hpp>
|
||||
#include <mbgl/util/optional.hpp>
|
||||
#include <mbgl/gl/gl.hpp>
|
||||
@@ -11,7 +12,6 @@
|
||||
#include <set>
|
||||
#include <unordered_map>
|
||||
#include <mutex>
|
||||
#include <atomic>
|
||||
|
||||
namespace mbgl {
|
||||
|
||||
|
||||
@@ -25,7 +25,7 @@ public:
|
||||
if (bound_shader == 0) {
|
||||
vertexBuffer.bind(store);
|
||||
shader.bind(offset);
|
||||
if (vao) {
|
||||
if (vao.created()) {
|
||||
storeBinding(shader, vertexBuffer.getID(), 0, offset);
|
||||
}
|
||||
} else {
|
||||
@@ -40,7 +40,7 @@ public:
|
||||
vertexBuffer.bind(store);
|
||||
elementsBuffer.bind(store);
|
||||
shader.bind(offset);
|
||||
if (vao) {
|
||||
if (vao.created()) {
|
||||
storeBinding(shader, vertexBuffer.getID(), elementsBuffer.getID(), offset);
|
||||
}
|
||||
} else {
|
||||
|
||||
@@ -510,7 +510,7 @@ CameraOptions Map::cameraForLatLngs(const std::vector<LatLng>& latLngs, optional
|
||||
scaleY -= (padding->top + padding->bottom) / height;
|
||||
}
|
||||
double minScale = ::fmin(scaleX, scaleY);
|
||||
double zoom = ::log2(getScale() * minScale);
|
||||
double zoom = util::log2(getScale() * minScale);
|
||||
zoom = util::clamp(zoom, getMinZoom(), getMaxZoom());
|
||||
|
||||
// Calculate the center point of a virtual bounds that is extended in all directions by padding.
|
||||
|
||||
@@ -222,7 +222,7 @@ double TransformState::zoomScale(double zoom) const {
|
||||
}
|
||||
|
||||
double TransformState::scaleZoom(double s) const {
|
||||
return ::log2(s);
|
||||
return util::log2(s);
|
||||
}
|
||||
|
||||
double TransformState::worldSize() const {
|
||||
|
||||
@@ -2,11 +2,10 @@
|
||||
|
||||
#include <mbgl/gl/gl.hpp>
|
||||
#include <mbgl/renderer/render_pass.hpp>
|
||||
#include <mbgl/util/atomic.hpp>
|
||||
#include <mbgl/util/noncopyable.hpp>
|
||||
#include <mbgl/util/mat4.hpp>
|
||||
|
||||
#include <atomic>
|
||||
|
||||
#define BUFFER_OFFSET_0 ((GLbyte*)nullptr)
|
||||
#define BUFFER_OFFSET(i) ((BUFFER_OFFSET_0) + (i))
|
||||
|
||||
@@ -50,7 +49,7 @@ public:
|
||||
virtual void swapRenderData() {}
|
||||
|
||||
protected:
|
||||
std::atomic<bool> uploaded;
|
||||
util::Atomic<bool> uploaded;
|
||||
|
||||
};
|
||||
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
#include <mbgl/geometry/binpack.hpp>
|
||||
#include <mbgl/gl/gl.hpp>
|
||||
#include <mbgl/gl/object_store.hpp>
|
||||
#include <mbgl/util/atomic.hpp>
|
||||
#include <mbgl/util/noncopyable.hpp>
|
||||
#include <mbgl/util/ptr.hpp>
|
||||
#include <mbgl/util/optional.hpp>
|
||||
@@ -10,7 +11,6 @@
|
||||
#include <string>
|
||||
#include <map>
|
||||
#include <mutex>
|
||||
#include <atomic>
|
||||
#include <set>
|
||||
#include <array>
|
||||
|
||||
@@ -92,7 +92,7 @@ private:
|
||||
std::map<Key, Holder> images;
|
||||
std::set<std::string> uninitialized;
|
||||
std::unique_ptr<uint32_t[]> data;
|
||||
std::atomic<bool> dirty;
|
||||
util::Atomic<bool> dirty;
|
||||
bool fullUploadRequired = true;
|
||||
mbgl::optional<gl::UniqueTexture> texture;
|
||||
uint32_t filter = 0;
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
|
||||
namespace mbgl {
|
||||
|
||||
std::atomic<bool> NetworkStatus::online(true);
|
||||
util::Atomic<bool> NetworkStatus::online(true);
|
||||
std::mutex NetworkStatus::mtx;
|
||||
std::set<util::AsyncTask *> NetworkStatus::observers;
|
||||
|
||||
|
||||
@@ -3,9 +3,9 @@
|
||||
#include <mbgl/map/mode.hpp>
|
||||
#include <mbgl/tile/tile_id.hpp>
|
||||
#include <mbgl/style/filter.hpp>
|
||||
#include <mbgl/util/atomic.hpp>
|
||||
|
||||
#include <functional>
|
||||
#include <atomic>
|
||||
|
||||
namespace mbgl {
|
||||
|
||||
@@ -24,7 +24,7 @@ class BucketParameters {
|
||||
public:
|
||||
BucketParameters(const OverscaledTileID& tileID_,
|
||||
const GeometryTileLayer& layer_,
|
||||
const std::atomic<bool>& obsolete_,
|
||||
const util::Atomic<bool>& obsolete_,
|
||||
uintptr_t tileUID_,
|
||||
bool& partialParse_,
|
||||
SpriteStore& spriteStore_,
|
||||
@@ -51,7 +51,7 @@ public:
|
||||
|
||||
const OverscaledTileID& tileID;
|
||||
const GeometryTileLayer& layer;
|
||||
const std::atomic<bool>& obsolete;
|
||||
const util::Atomic<bool>& obsolete;
|
||||
uintptr_t tileUID;
|
||||
bool& partialParse;
|
||||
SpriteStore& spriteStore;
|
||||
|
||||
@@ -2,10 +2,10 @@
|
||||
|
||||
#include <mbgl/text/glyph.hpp>
|
||||
#include <mbgl/text/glyph_store.hpp>
|
||||
#include <mbgl/util/atomic.hpp>
|
||||
#include <mbgl/util/font_stack.hpp>
|
||||
#include <mbgl/util/noncopyable.hpp>
|
||||
|
||||
#include <atomic>
|
||||
#include <functional>
|
||||
#include <string>
|
||||
#include <memory>
|
||||
@@ -29,7 +29,7 @@ public:
|
||||
}
|
||||
|
||||
private:
|
||||
std::atomic<bool> parsed;
|
||||
util::Atomic<bool> parsed;
|
||||
std::unique_ptr<AsyncRequest> req;
|
||||
GlyphStoreObserver* observer = nullptr;
|
||||
};
|
||||
|
||||
@@ -24,7 +24,7 @@ TileWorker::TileWorker(const OverscaledTileID& id_,
|
||||
SpriteStore& spriteStore_,
|
||||
GlyphAtlas& glyphAtlas_,
|
||||
GlyphStore& glyphStore_,
|
||||
const std::atomic<bool>& obsolete_,
|
||||
const util::Atomic<bool>& obsolete_,
|
||||
const MapMode mode_)
|
||||
: id(id_),
|
||||
sourceID(std::move(sourceID_)),
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
#include <mbgl/map/mode.hpp>
|
||||
#include <mbgl/tile/tile_id.hpp>
|
||||
#include <mbgl/util/atomic.hpp>
|
||||
#include <mbgl/util/noncopyable.hpp>
|
||||
#include <mbgl/util/variant.hpp>
|
||||
#include <mbgl/util/ptr.hpp>
|
||||
@@ -12,7 +13,6 @@
|
||||
#include <memory>
|
||||
#include <mutex>
|
||||
#include <list>
|
||||
#include <atomic>
|
||||
#include <unordered_map>
|
||||
|
||||
namespace mbgl {
|
||||
@@ -50,7 +50,7 @@ public:
|
||||
SpriteStore&,
|
||||
GlyphAtlas&,
|
||||
GlyphStore&,
|
||||
const std::atomic<bool>&,
|
||||
const util::Atomic<bool>&,
|
||||
const MapMode);
|
||||
~TileWorker();
|
||||
|
||||
@@ -75,7 +75,7 @@ private:
|
||||
SpriteStore& spriteStore;
|
||||
GlyphAtlas& glyphAtlas;
|
||||
GlyphStore& glyphStore;
|
||||
const std::atomic<bool>& obsolete;
|
||||
const util::Atomic<bool>& obsolete;
|
||||
const MapMode mode;
|
||||
|
||||
bool partialParse = false;
|
||||
|
||||
@@ -3,9 +3,9 @@
|
||||
#include <mbgl/tile/tile_data.hpp>
|
||||
#include <mbgl/tile/tile_worker.hpp>
|
||||
#include <mbgl/text/placement_config.hpp>
|
||||
#include <mbgl/util/atomic.hpp>
|
||||
#include <mbgl/util/feature.hpp>
|
||||
|
||||
#include <atomic>
|
||||
#include <memory>
|
||||
#include <unordered_map>
|
||||
|
||||
@@ -69,7 +69,7 @@ private:
|
||||
PlacementConfig targetConfig;
|
||||
|
||||
// Used to signal the worker that it should abandon parsing this tile as soon as possible.
|
||||
std::atomic<bool> obsolete { false };
|
||||
util::Atomic<bool> obsolete { false };
|
||||
};
|
||||
|
||||
} // namespace mbgl
|
||||
|
||||
45
src/mbgl/util/atomic.hpp
Normal file
45
src/mbgl/util/atomic.hpp
Normal file
@@ -0,0 +1,45 @@
|
||||
#pragma once
|
||||
|
||||
#include <atomic>
|
||||
#include <mutex>
|
||||
|
||||
namespace mbgl {
|
||||
namespace util {
|
||||
|
||||
// std::atomic<bool> is implemented lock free which
|
||||
// is not supported by ARMv5 but the code generated
|
||||
// seems to be using that and not working at all,
|
||||
// thus, this naive implementation using mutexes.
|
||||
#if defined(__ANDROID__) && defined(__ARM_ARCH_5TE__)
|
||||
|
||||
template <typename T>
|
||||
class Atomic {
|
||||
public:
|
||||
Atomic() = default;
|
||||
explicit Atomic(const T& data_) : data(data_) {}
|
||||
|
||||
void operator=(const T& other) {
|
||||
std::lock_guard<std::mutex> lock(mtx);
|
||||
data = other;
|
||||
}
|
||||
|
||||
operator bool() const {
|
||||
std::lock_guard<std::mutex> lock(mtx);
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
private:
|
||||
T data;
|
||||
mutable std::mutex mtx;
|
||||
};
|
||||
|
||||
#else
|
||||
|
||||
template <typename T>
|
||||
using Atomic = std::atomic<T>;
|
||||
|
||||
#endif
|
||||
|
||||
} // namespace util
|
||||
} // namespace mbgl
|
||||
@@ -21,5 +21,15 @@ uint32_t ceil_log2(uint64_t x) {
|
||||
return y;
|
||||
}
|
||||
|
||||
double log2(double x) {
|
||||
// log2() is producing wrong results on ARMv5 binaries
|
||||
// running on ARMv7+ CPUs.
|
||||
#if defined(__ANDROID__) && defined(__ARM_ARCH_5TE__)
|
||||
return std::log(x) / 0.6931471805599453; // log(x) / log(2)
|
||||
#else
|
||||
return ::log2(x);
|
||||
#endif
|
||||
}
|
||||
|
||||
} // namespace util
|
||||
} // namespace mbgl
|
||||
} // namespace mbgl
|
||||
|
||||
@@ -110,5 +110,7 @@ T smoothstep(T edge0, T edge1, T x) {
|
||||
// (== number of bits required to store x)
|
||||
uint32_t ceil_log2(uint64_t x);
|
||||
|
||||
double log2(double x);
|
||||
|
||||
} // namespace util
|
||||
} // namespace mbgl
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
#include <utility>
|
||||
#include <functional>
|
||||
|
||||
#include <mbgl/util/atomic.hpp>
|
||||
#include <mbgl/util/run_loop.hpp>
|
||||
#include <mbgl/util/thread_context.hpp>
|
||||
#include <mbgl/platform/platform.hpp>
|
||||
|
||||
Reference in New Issue
Block a user