[android] synchronize and coalesce requests targeting the same TileID in the CustomGeometrySource
This commit is contained in:
committed by
Łukasz Paczos
parent
51f3842a28
commit
f9fd9c0f00
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user