feat: add retained underlay runtime controls
This commit is contained in:
@@ -716,6 +716,27 @@ jni::jboolean NativeMapView::getDebug(JNIEnv&) {
|
||||
return map->getDebug() != DebugOptions::NoDebug;
|
||||
}
|
||||
|
||||
void NativeMapView::setRetainedUnderlayEnabled(JNIEnv&, jni::jboolean enabled) {
|
||||
map->setRetainedUnderlayEnabled(enabled);
|
||||
}
|
||||
|
||||
jni::Local<jni::Array<jni::String>> NativeMapView::getRetainedUnderlayDiagnostics(JNIEnv& env) {
|
||||
const auto snapshot = map->getRetainedUnderlayDiagnostics();
|
||||
const std::array<std::string, 6> 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,
|
||||
};
|
||||
auto result = jni::Array<jni::String>::New(env, values.size());
|
||||
for (std::size_t index = 0; index < values.size(); ++index) {
|
||||
result.Set(env, index, jni::Make<jni::String>(env, values[index]));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
jni::Local<jni::Array<jni::String>> NativeMapView::getActionJournalLogFiles(JNIEnv& env) {
|
||||
const auto& actionJournal = map->getActionJournal();
|
||||
if (!actionJournal) {
|
||||
@@ -1795,6 +1816,8 @@ void NativeMapView::registerNative(jni::JNIEnv& env) {
|
||||
METHOD(&NativeMapView::addMarkers, "nativeAddMarkers"),
|
||||
METHOD(&NativeMapView::setDebug, "nativeSetDebug"),
|
||||
METHOD(&NativeMapView::getDebug, "nativeGetDebug"),
|
||||
METHOD(&NativeMapView::setRetainedUnderlayEnabled, "nativeSetRetainedUnderlayEnabled"),
|
||||
METHOD(&NativeMapView::getRetainedUnderlayDiagnostics, "nativeGetRetainedUnderlayDiagnostics"),
|
||||
METHOD(&NativeMapView::getActionJournalLogFiles, "nativeGetActionJournalLogFiles"),
|
||||
METHOD(&NativeMapView::getActionJournalLog, "nativeGetActionJournalLog"),
|
||||
METHOD(&NativeMapView::clearActionJournalLog, "nativeClearActionJournalLog"),
|
||||
|
||||
@@ -201,6 +201,10 @@ public:
|
||||
|
||||
jni::jboolean getDebug(JNIEnv&);
|
||||
|
||||
void setRetainedUnderlayEnabled(JNIEnv&, jni::jboolean);
|
||||
|
||||
jni::Local<jni::Array<jni::String>> getRetainedUnderlayDiagnostics(JNIEnv&);
|
||||
|
||||
jni::Local<jni::Array<jni::String>> getActionJournalLogFiles(JNIEnv&);
|
||||
|
||||
jni::Local<jni::Array<jni::String>> getActionJournalLog(JNIEnv&);
|
||||
|
||||
@@ -111,6 +111,22 @@ public final class MapLibreMap {
|
||||
nativeMapView.triggerRepaint();
|
||||
}
|
||||
|
||||
/** Enables or disables the renderer's map-scoped retained static underlay optimization. */
|
||||
public void setRetainedUnderlayEnabled(boolean enabled) {
|
||||
nativeMapView.setRetainedUnderlayEnabled(enabled);
|
||||
}
|
||||
|
||||
/** Returns whether the retained static underlay optimization is enabled for this map. */
|
||||
public boolean isRetainedUnderlayEnabled() {
|
||||
return nativeMapView.getRetainedUnderlayDiagnostics().enabled;
|
||||
}
|
||||
|
||||
/** Returns a thread-safe, pull-based retained-underlay diagnostics snapshot. */
|
||||
@NonNull
|
||||
public RetainedUnderlayDiagnostics getRetainedUnderlayDiagnostics() {
|
||||
return nativeMapView.getRetainedUnderlayDiagnostics();
|
||||
}
|
||||
|
||||
/**
|
||||
* Query rendering statistics overlay status.
|
||||
*/
|
||||
|
||||
@@ -286,6 +286,10 @@ interface NativeMap {
|
||||
|
||||
boolean getDebug();
|
||||
|
||||
void setRetainedUnderlayEnabled(boolean enabled);
|
||||
|
||||
RetainedUnderlayDiagnostics getRetainedUnderlayDiagnostics();
|
||||
|
||||
String[] getActionJournalLogFiles();
|
||||
|
||||
String[] getActionJournalLog();
|
||||
|
||||
@@ -653,6 +653,22 @@ final class NativeMapView implements NativeMap {
|
||||
return nativeGetDebug();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setRetainedUnderlayEnabled(boolean enabled) {
|
||||
if (checkState("setRetainedUnderlayEnabled")) {
|
||||
return;
|
||||
}
|
||||
nativeSetRetainedUnderlayEnabled(enabled);
|
||||
}
|
||||
|
||||
@Override
|
||||
public RetainedUnderlayDiagnostics getRetainedUnderlayDiagnostics() {
|
||||
if (checkState("getRetainedUnderlayDiagnostics")) {
|
||||
return new RetainedUnderlayDiagnostics(new String[] {"true", "0", "0", "0", "0", "unavailable"});
|
||||
}
|
||||
return new RetainedUnderlayDiagnostics(nativeGetRetainedUnderlayDiagnostics());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getActionJournalLogFiles() {
|
||||
if (checkState("getActionJournalLogFiles")) {
|
||||
@@ -1702,6 +1718,12 @@ final class NativeMapView implements NativeMap {
|
||||
@Keep
|
||||
private native boolean nativeGetDebug();
|
||||
|
||||
@Keep
|
||||
private native void nativeSetRetainedUnderlayEnabled(boolean enabled);
|
||||
|
||||
@Keep
|
||||
private native String[] nativeGetRetainedUnderlayDiagnostics();
|
||||
|
||||
@Keep
|
||||
private native String[] nativeGetActionJournalLogFiles();
|
||||
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
package org.maplibre.android.maps;
|
||||
|
||||
import androidx.annotation.Keep;
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
/** A pull-based snapshot of this map's retained-underlay renderer state. */
|
||||
@Keep
|
||||
public final class RetainedUnderlayDiagnostics {
|
||||
public final boolean enabled;
|
||||
public final long build;
|
||||
public final long reuse;
|
||||
public final long fallback;
|
||||
public final long invalidation;
|
||||
@NonNull public final String lastReason;
|
||||
|
||||
RetainedUnderlayDiagnostics(@NonNull String[] values) {
|
||||
if (values.length != 6) {
|
||||
throw new IllegalArgumentException("Retained-underlay diagnostics require six values");
|
||||
}
|
||||
enabled = Boolean.parseBoolean(values[0]);
|
||||
build = Long.parseLong(values[1]);
|
||||
reuse = Long.parseLong(values[2]);
|
||||
fallback = Long.parseLong(values[3]);
|
||||
invalidation = Long.parseLong(values[4]);
|
||||
lastReason = values[5];
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user