feat: add generic render segment model
Some checks failed
validate-scripts / validate-scripts (push) Has been cancelled
Some checks failed
validate-scripts / validate-scripts (push) Has been cancelled
This commit is contained in:
@@ -36,6 +36,7 @@
|
||||
#include <mbgl/style/image.hpp>
|
||||
#include <mbgl/style/filter.hpp>
|
||||
#include <mbgl/renderer/query.hpp>
|
||||
#include <mbgl/renderer/render_segment_json.hpp>
|
||||
#include <mbgl/particle/field/field_profile_contract_json.hpp>
|
||||
#include <mbgl/particle/ingress/encoded_field_transport.hpp>
|
||||
|
||||
@@ -727,6 +728,19 @@ jni::jboolean NativeMapView::setContinuousLayerRange(JNIEnv& env,
|
||||
jni::Make<std::string>(env, endLayerId));
|
||||
}
|
||||
|
||||
jni::jboolean NativeMapView::setRenderSegmentPlan(JNIEnv& env, const jni::String& planJson) {
|
||||
const auto plan = parseRenderSegmentPlanJSON(jni::Make<std::string>(env, planJson));
|
||||
if (plan) return map->setRenderSegmentPlan(*plan);
|
||||
RenderSegmentPlan invalid;
|
||||
invalid.schemaVersion = 0;
|
||||
map->setRenderSegmentPlan(std::move(invalid));
|
||||
return false;
|
||||
}
|
||||
|
||||
jni::Local<jni::String> NativeMapView::getRenderSegmentDiagnostics(JNIEnv& env) {
|
||||
return jni::Make<jni::String>(env, renderSegmentDiagnosticsToJSON(map->getRenderSegmentDiagnostics()));
|
||||
}
|
||||
|
||||
jni::Local<jni::Array<jni::String>> NativeMapView::getRetainedUnderlayDiagnostics(JNIEnv& env) {
|
||||
const auto snapshot = map->getRetainedUnderlayDiagnostics();
|
||||
const std::array<std::string, 39> values = {
|
||||
@@ -1858,6 +1872,8 @@ void NativeMapView::registerNative(jni::JNIEnv& env) {
|
||||
METHOD(&NativeMapView::getDebug, "nativeGetDebug"),
|
||||
METHOD(&NativeMapView::setRetainedUnderlayEnabled, "nativeSetRetainedUnderlayEnabled"),
|
||||
METHOD(&NativeMapView::setContinuousLayerRange, "nativeSetContinuousLayerRange"),
|
||||
METHOD(&NativeMapView::setRenderSegmentPlan, "nativeSetRenderSegmentPlan"),
|
||||
METHOD(&NativeMapView::getRenderSegmentDiagnostics, "nativeGetRenderSegmentDiagnostics"),
|
||||
METHOD(&NativeMapView::getRetainedUnderlayDiagnostics, "nativeGetRetainedUnderlayDiagnostics"),
|
||||
METHOD(&NativeMapView::getActionJournalLogFiles, "nativeGetActionJournalLogFiles"),
|
||||
METHOD(&NativeMapView::getActionJournalLog, "nativeGetActionJournalLog"),
|
||||
|
||||
@@ -205,6 +205,10 @@ public:
|
||||
|
||||
jni::jboolean setContinuousLayerRange(JNIEnv&, const jni::String&, const jni::String&);
|
||||
|
||||
jni::jboolean setRenderSegmentPlan(JNIEnv&, const jni::String&);
|
||||
|
||||
jni::Local<jni::String> getRenderSegmentDiagnostics(JNIEnv&);
|
||||
|
||||
jni::Local<jni::Array<jni::String>> getRetainedUnderlayDiagnostics(JNIEnv&);
|
||||
|
||||
jni::Local<jni::Array<jni::String>> getActionJournalLogFiles(JNIEnv&);
|
||||
|
||||
@@ -121,6 +121,17 @@ public final class MapLibreMap {
|
||||
return nativeMapView.setContinuousLayerRange(startLayerId, endLayerId);
|
||||
}
|
||||
|
||||
/** Configures the renderer execution topology using schema-versioned JSON. */
|
||||
public boolean setRenderSegmentPlan(@NonNull String planJson) {
|
||||
return nativeMapView.setRenderSegmentPlan(planJson);
|
||||
}
|
||||
|
||||
/** Returns the pull-based Style-to-Segment-to-Layer diagnostics snapshot as JSON. */
|
||||
@NonNull
|
||||
public String getRenderSegmentDiagnostics() {
|
||||
return nativeMapView.getRenderSegmentDiagnostics();
|
||||
}
|
||||
|
||||
/** Returns whether the retained static underlay optimization is enabled for this map. */
|
||||
public boolean isRetainedUnderlayEnabled() {
|
||||
return nativeMapView.getRetainedUnderlayDiagnostics().enabled;
|
||||
|
||||
@@ -290,6 +290,10 @@ interface NativeMap {
|
||||
|
||||
boolean setContinuousLayerRange(String startLayerId, String endLayerId);
|
||||
|
||||
boolean setRenderSegmentPlan(String planJson);
|
||||
|
||||
String getRenderSegmentDiagnostics();
|
||||
|
||||
RetainedUnderlayDiagnostics getRetainedUnderlayDiagnostics();
|
||||
|
||||
String[] getActionJournalLogFiles();
|
||||
|
||||
@@ -667,6 +667,19 @@ final class NativeMapView implements NativeMap {
|
||||
return nativeSetContinuousLayerRange(startLayerId, endLayerId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean setRenderSegmentPlan(@NonNull String planJson) {
|
||||
if (checkState("setRenderSegmentPlan")) return false;
|
||||
return nativeSetRenderSegmentPlan(planJson);
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public String getRenderSegmentDiagnostics() {
|
||||
if (checkState("getRenderSegmentDiagnostics")) return "{\"schemaVersion\":1,\"valid\":false}";
|
||||
return nativeGetRenderSegmentDiagnostics();
|
||||
}
|
||||
|
||||
@Override
|
||||
public RetainedUnderlayDiagnostics getRetainedUnderlayDiagnostics() {
|
||||
if (checkState("getRetainedUnderlayDiagnostics")) {
|
||||
@@ -1730,6 +1743,12 @@ final class NativeMapView implements NativeMap {
|
||||
@Keep
|
||||
private native boolean nativeSetContinuousLayerRange(String startLayerId, String endLayerId);
|
||||
|
||||
@Keep
|
||||
private native boolean nativeSetRenderSegmentPlan(String planJson);
|
||||
|
||||
@Keep
|
||||
private native String nativeGetRenderSegmentDiagnostics();
|
||||
|
||||
@Keep
|
||||
private native String[] nativeGetRetainedUnderlayDiagnostics();
|
||||
|
||||
|
||||
@@ -2321,6 +2321,12 @@ of north, the map will automatically snap to exact north.
|
||||
- (BOOL)setContinuousLayerRangeFromLayerIdentifier:(NSString *)startLayerId
|
||||
toLayerIdentifier:(NSString *)endLayerId;
|
||||
|
||||
/** Configures the schema-versioned renderer segment plan transported as JSON. */
|
||||
- (BOOL)setRenderSegmentPlanJSON:(NSString *)planJSON;
|
||||
|
||||
/** Returns a pull-based Style-to-Segment-to-Layer diagnostics JSON snapshot. */
|
||||
@property (nonatomic, readonly) NSString *renderSegmentDiagnosticsJSON;
|
||||
|
||||
/** Returns a thread-safe retained-underlay diagnostics snapshot without enabling periodic events. */
|
||||
@property (nonatomic, readonly) MLNRetainedUnderlayDiagnostics *retainedUnderlayDiagnostics;
|
||||
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
#include <mbgl/layermanager/layer_manager.hpp>
|
||||
#include <mbgl/map/camera.hpp>
|
||||
#include <mbgl/map/map.hpp>
|
||||
#include <mbgl/renderer/render_segment_json.hpp>
|
||||
#include <mbgl/map/map_options.hpp>
|
||||
#include <mbgl/map/mode.hpp>
|
||||
#include <mbgl/math/wrap.hpp>
|
||||
@@ -3160,6 +3161,22 @@ static void *windowScreenContext = &windowScreenContext;
|
||||
return self.mbglMap.setContinuousLayerRange(startLayerId.UTF8String, endLayerId.UTF8String);
|
||||
}
|
||||
|
||||
- (BOOL)setRenderSegmentPlanJSON:(NSString *)planJSON {
|
||||
if (!_mbglMap) return NO;
|
||||
const auto plan = mbgl::parseRenderSegmentPlanJSON(planJSON.UTF8String);
|
||||
if (plan) return self.mbglMap.setRenderSegmentPlan(*plan);
|
||||
mbgl::RenderSegmentPlan invalid;
|
||||
invalid.schemaVersion = 0;
|
||||
self.mbglMap.setRenderSegmentPlan(std::move(invalid));
|
||||
return NO;
|
||||
}
|
||||
|
||||
- (NSString *)renderSegmentDiagnosticsJSON {
|
||||
if (!_mbglMap) return @"{\"schemaVersion\":1,\"valid\":false}";
|
||||
const auto json = mbgl::renderSegmentDiagnosticsToJSON(self.mbglMap.getRenderSegmentDiagnostics());
|
||||
return [NSString stringWithUTF8String:json.c_str()];
|
||||
}
|
||||
|
||||
- (MLNRetainedUnderlayDiagnostics *)retainedUnderlayDiagnostics {
|
||||
if (!_mbglMap) {
|
||||
return [[MLNRetainedUnderlayDiagnostics alloc] initWithEnabled:YES
|
||||
|
||||
Reference in New Issue
Block a user