feat: add continuous retained render ranges
Some checks failed
validate-scripts / validate-scripts (push) Has been cancelled

This commit is contained in:
tei
2026-09-24 11:46:19 +09:00
parent b29e564944
commit a9eaec6b65
25 changed files with 857 additions and 120 deletions

View File

@@ -720,15 +720,36 @@ void NativeMapView::setRetainedUnderlayEnabled(JNIEnv&, jni::jboolean enabled) {
map->setRetainedUnderlayEnabled(enabled);
}
jni::jboolean NativeMapView::setContinuousLayerRange(JNIEnv& env,
const jni::String& startLayerId,
const jni::String& endLayerId) {
return map->setContinuousLayerRange(jni::Make<std::string>(env, startLayerId),
jni::Make<std::string>(env, endLayerId));
}
jni::Local<jni::Array<jni::String>> NativeMapView::getRetainedUnderlayDiagnostics(JNIEnv& env) {
const auto snapshot = map->getRetainedUnderlayDiagnostics();
const std::array<std::string, 6> values = {
const std::array<std::string, 20> values = {
snapshot.enabled ? "true" : "false",
std::to_string(snapshot.build),
std::to_string(snapshot.reuse),
std::to_string(snapshot.fallback),
std::to_string(snapshot.invalidation),
snapshot.lastReason,
snapshot.rangeConfigured ? "true" : "false",
snapshot.rangeValid ? "true" : "false",
snapshot.startLayerId,
snapshot.endLayerId,
std::to_string(snapshot.startIndex),
std::to_string(snapshot.endIndex),
snapshot.bottomPresent ? "true" : "false",
std::to_string(snapshot.bottomBuild),
std::to_string(snapshot.bottomReuse),
std::to_string(snapshot.bottomInvalidation),
snapshot.topPresent ? "true" : "false",
std::to_string(snapshot.topBuild),
std::to_string(snapshot.topReuse),
std::to_string(snapshot.topInvalidation),
};
auto result = jni::Array<jni::String>::New(env, values.size());
for (std::size_t index = 0; index < values.size(); ++index) {
@@ -1817,6 +1838,7 @@ void NativeMapView::registerNative(jni::JNIEnv& env) {
METHOD(&NativeMapView::setDebug, "nativeSetDebug"),
METHOD(&NativeMapView::getDebug, "nativeGetDebug"),
METHOD(&NativeMapView::setRetainedUnderlayEnabled, "nativeSetRetainedUnderlayEnabled"),
METHOD(&NativeMapView::setContinuousLayerRange, "nativeSetContinuousLayerRange"),
METHOD(&NativeMapView::getRetainedUnderlayDiagnostics, "nativeGetRetainedUnderlayDiagnostics"),
METHOD(&NativeMapView::getActionJournalLogFiles, "nativeGetActionJournalLogFiles"),
METHOD(&NativeMapView::getActionJournalLog, "nativeGetActionJournalLog"),

View File

@@ -203,6 +203,8 @@ public:
void setRetainedUnderlayEnabled(JNIEnv&, jni::jboolean);
jni::jboolean setContinuousLayerRange(JNIEnv&, const jni::String&, const jni::String&);
jni::Local<jni::Array<jni::String>> getRetainedUnderlayDiagnostics(JNIEnv&);
jni::Local<jni::Array<jni::String>> getActionJournalLogFiles(JNIEnv&);

View File

@@ -116,6 +116,11 @@ public final class MapLibreMap {
nativeMapView.setRetainedUnderlayEnabled(enabled);
}
/** Configures the inclusive Style-layer interval rendered continuously. */
public boolean setContinuousLayerRange(@NonNull String startLayerId, @NonNull String endLayerId) {
return nativeMapView.setContinuousLayerRange(startLayerId, endLayerId);
}
/** Returns whether the retained static underlay optimization is enabled for this map. */
public boolean isRetainedUnderlayEnabled() {
return nativeMapView.getRetainedUnderlayDiagnostics().enabled;

View File

@@ -288,6 +288,8 @@ interface NativeMap {
void setRetainedUnderlayEnabled(boolean enabled);
boolean setContinuousLayerRange(String startLayerId, String endLayerId);
RetainedUnderlayDiagnostics getRetainedUnderlayDiagnostics();
String[] getActionJournalLogFiles();

View File

@@ -661,10 +661,16 @@ final class NativeMapView implements NativeMap {
nativeSetRetainedUnderlayEnabled(enabled);
}
@Override
public boolean setContinuousLayerRange(@NonNull String startLayerId, @NonNull String endLayerId) {
if (checkState("setContinuousLayerRange")) return false;
return nativeSetContinuousLayerRange(startLayerId, endLayerId);
}
@Override
public RetainedUnderlayDiagnostics getRetainedUnderlayDiagnostics() {
if (checkState("getRetainedUnderlayDiagnostics")) {
return new RetainedUnderlayDiagnostics(new String[] {"true", "0", "0", "0", "0", "unavailable"});
return RetainedUnderlayDiagnostics.unavailable();
}
return new RetainedUnderlayDiagnostics(nativeGetRetainedUnderlayDiagnostics());
}
@@ -1721,6 +1727,9 @@ final class NativeMapView implements NativeMap {
@Keep
private native void nativeSetRetainedUnderlayEnabled(boolean enabled);
@Keep
private native boolean nativeSetContinuousLayerRange(String startLayerId, String endLayerId);
@Keep
private native String[] nativeGetRetainedUnderlayDiagnostics();

View File

@@ -12,10 +12,24 @@ public final class RetainedUnderlayDiagnostics {
public final long fallback;
public final long invalidation;
@NonNull public final String lastReason;
public final boolean rangeConfigured;
public final boolean rangeValid;
@NonNull public final String startLayerId;
@NonNull public final String endLayerId;
public final int startIndex;
public final int endIndex;
public final boolean bottomPresent;
public final long bottomBuild;
public final long bottomReuse;
public final long bottomInvalidation;
public final boolean topPresent;
public final long topBuild;
public final long topReuse;
public final long topInvalidation;
RetainedUnderlayDiagnostics(@NonNull String[] values) {
if (values.length != 6) {
throw new IllegalArgumentException("Retained-underlay diagnostics require six values");
if (values.length != 20) {
throw new IllegalArgumentException("Retained-range diagnostics require 20 values");
}
enabled = Boolean.parseBoolean(values[0]);
build = Long.parseLong(values[1]);
@@ -23,5 +37,26 @@ public final class RetainedUnderlayDiagnostics {
fallback = Long.parseLong(values[3]);
invalidation = Long.parseLong(values[4]);
lastReason = values[5];
rangeConfigured = Boolean.parseBoolean(values[6]);
rangeValid = Boolean.parseBoolean(values[7]);
startLayerId = values[8];
endLayerId = values[9];
startIndex = Integer.parseInt(values[10]);
endIndex = Integer.parseInt(values[11]);
bottomPresent = Boolean.parseBoolean(values[12]);
bottomBuild = Long.parseLong(values[13]);
bottomReuse = Long.parseLong(values[14]);
bottomInvalidation = Long.parseLong(values[15]);
topPresent = Boolean.parseBoolean(values[16]);
topBuild = Long.parseLong(values[17]);
topReuse = Long.parseLong(values[18]);
topInvalidation = Long.parseLong(values[19]);
}
static RetainedUnderlayDiagnostics unavailable() {
return new RetainedUnderlayDiagnostics(new String[] {
"true", "0", "0", "0", "0", "unavailable", "false", "false", "", "", "-1", "-1",
"false", "0", "0", "0", "false", "0", "0", "0"
});
}
}