summaryrefslogtreecommitdiff
path: root/platform/android/src
diff options
context:
space:
mode:
authorŁukasz Paczos <lukas.paczos@gmail.com>2018-07-30 15:09:35 +0200
committerŁukasz Paczos <lukasz.paczos@mapbox.com>2018-08-23 18:29:55 +0200
commitf9fd9c0f0086fa2883aa2125c9b95c599c83c4e5 (patch)
treee06293c4b89a942c99b31ea6ad10d9339598ba8b /platform/android/src
parent51f3842a28f579e6da0389f4634e89b8374a3f9e (diff)
downloadqtlocation-mapboxgl-f9fd9c0f0086fa2883aa2125c9b95c599c83c4e5.tar.gz
[android] synchronize and coalesce requests targeting the same TileID in the CustomGeometrySource
Diffstat (limited to 'platform/android/src')
-rw-r--r--platform/android/src/style/sources/custom_geometry_source.cpp19
-rw-r--r--platform/android/src/style/sources/custom_geometry_source.hpp1
2 files changed, 18 insertions, 2 deletions
diff --git a/platform/android/src/style/sources/custom_geometry_source.cpp b/platform/android/src/style/sources/custom_geometry_source.cpp
index 9c51f70ab5..e9a530f75b 100644
--- a/platform/android/src/style/sources/custom_geometry_source.cpp
+++ b/platform/android/src/style/sources/custom_geometry_source.cpp
@@ -102,6 +102,19 @@ namespace android {
peer.Call(*_env, releaseThreads);
};
+ bool CustomGeometrySource::isCancelled(jni::jint z,
+ jni::jint x,
+ jni::jint y) {
+ android::UniqueEnv _env = android::AttachEnv();
+
+ static auto isCancelled = javaClass.GetMethod<jboolean (jni::jint, jni::jint, jni::jint)>(*_env, "isCancelled");
+
+ assert(javaPeer);
+
+ auto peer = jni::Cast(*_env, *javaPeer, javaClass);
+ return peer.Call(*_env, isCancelled, z, x, y);
+ };
+
void CustomGeometrySource::setTileData(jni::JNIEnv& env,
jni::jint z,
jni::jint x,
@@ -112,8 +125,10 @@ namespace android {
// Convert the jni object
auto geometry = geojson::FeatureCollection::convert(env, jFeatures);
- // Update the core source
- source.as<mbgl::style::CustomGeometrySource>()->CustomGeometrySource::setTileData(CanonicalTileID(z, x, y), GeoJSON(geometry));
+ // Update the core source if not cancelled
+ if (!isCancelled(z, x ,y)) {
+ source.as<mbgl::style::CustomGeometrySource>()->CustomGeometrySource::setTileData(CanonicalTileID(z, x, y), GeoJSON(geometry));
+ }
}
void CustomGeometrySource::invalidateTile(jni::JNIEnv&, jni::jint z, jni::jint x, jni::jint y) {
diff --git a/platform/android/src/style/sources/custom_geometry_source.hpp b/platform/android/src/style/sources/custom_geometry_source.hpp
index c38926a5b9..801f81b089 100644
--- a/platform/android/src/style/sources/custom_geometry_source.hpp
+++ b/platform/android/src/style/sources/custom_geometry_source.hpp
@@ -33,6 +33,7 @@ public:
void fetchTile(const mbgl::CanonicalTileID& tileID);
void cancelTile(const mbgl::CanonicalTileID& tileID);
+ bool isCancelled(jni::jint z, jni::jint x, jni::jint y);
void startThreads();
void releaseThreads();
void setTileData(jni::JNIEnv& env, jni::jint z, jni::jint x, jni::jint y, jni::Object<geojson::FeatureCollection> jf);