Toggle tile cache final API (#2723)
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Bart Louwers <bart.louwers@gmail.com>
This commit is contained in:
@@ -109,6 +109,7 @@ public:
|
||||
|
||||
// Memory
|
||||
void setTileCacheEnabled(bool);
|
||||
bool getTileCacheEnabled() const;
|
||||
void reduceMemoryUse();
|
||||
void clearData();
|
||||
|
||||
|
||||
@@ -92,6 +92,10 @@ void AndroidRendererFrontend::setTileCacheEnabled(bool enabled) {
|
||||
mapRenderer.actor().invoke(&Renderer::setTileCacheEnabled, enabled);
|
||||
}
|
||||
|
||||
bool AndroidRendererFrontend::getTileCacheEnabled() const {
|
||||
return mapRenderer.actor().ask(&Renderer::getTileCacheEnabled).get();
|
||||
}
|
||||
|
||||
void AndroidRendererFrontend::reduceMemoryUse() {
|
||||
mapRenderer.actor().invoke(&Renderer::reduceMemoryUse);
|
||||
}
|
||||
|
||||
@@ -55,6 +55,7 @@ public:
|
||||
|
||||
// Memory
|
||||
void setTileCacheEnabled(bool);
|
||||
bool getTileCacheEnabled() const;
|
||||
void reduceMemoryUse();
|
||||
|
||||
private:
|
||||
|
||||
@@ -676,10 +676,6 @@ jni::Local<jni::Array<jni::jlong>> NativeMapView::addMarkers(jni::JNIEnv& env,
|
||||
return result;
|
||||
}
|
||||
|
||||
void NativeMapView::setTileCacheEnabled(JNIEnv&, jni::jboolean enabled) {
|
||||
rendererFrontend->setTileCacheEnabled(enabled);
|
||||
}
|
||||
|
||||
void NativeMapView::onLowMemory(JNIEnv&) {
|
||||
rendererFrontend->reduceMemoryUse();
|
||||
}
|
||||
@@ -1215,6 +1211,14 @@ jni::jint NativeMapView::getPrefetchZoomDelta(JNIEnv&) {
|
||||
return jni::jint(map->getPrefetchZoomDelta());
|
||||
}
|
||||
|
||||
void NativeMapView::setTileCacheEnabled(JNIEnv&, jni::jboolean enabled) {
|
||||
rendererFrontend->setTileCacheEnabled(enabled);
|
||||
}
|
||||
|
||||
jni::jboolean NativeMapView::getTileCacheEnabled(JNIEnv&) {
|
||||
return jni::jboolean(rendererFrontend->getTileCacheEnabled());
|
||||
}
|
||||
|
||||
mbgl::Map& NativeMapView::getMap() {
|
||||
return *map;
|
||||
}
|
||||
@@ -1288,7 +1292,6 @@ void NativeMapView::registerNative(jni::JNIEnv& env) {
|
||||
METHOD(&NativeMapView::setDebug, "nativeSetDebug"),
|
||||
METHOD(&NativeMapView::getDebug, "nativeGetDebug"),
|
||||
METHOD(&NativeMapView::isFullyLoaded, "nativeIsFullyLoaded"),
|
||||
METHOD(&NativeMapView::setTileCacheEnabled, "nativeSetTileCacheEnabled"),
|
||||
METHOD(&NativeMapView::onLowMemory, "nativeOnLowMemory"),
|
||||
METHOD(&NativeMapView::getMetersPerPixelAtLatitude, "nativeGetMetersPerPixelAtLatitude"),
|
||||
METHOD(&NativeMapView::projectedMetersForLatLng, "nativeProjectedMetersForLatLng"),
|
||||
@@ -1333,6 +1336,8 @@ void NativeMapView::registerNative(jni::JNIEnv& env) {
|
||||
METHOD(&NativeMapView::getPrefetchTiles, "nativeGetPrefetchTiles"),
|
||||
METHOD(&NativeMapView::setPrefetchZoomDelta, "nativeSetPrefetchZoomDelta"),
|
||||
METHOD(&NativeMapView::getPrefetchZoomDelta, "nativeGetPrefetchZoomDelta"),
|
||||
METHOD(&NativeMapView::setTileCacheEnabled, "nativeSetTileCacheEnabled"),
|
||||
METHOD(&NativeMapView::getTileCacheEnabled, "nativeGetTileCacheEnabled"),
|
||||
METHOD(&NativeMapView::triggerRepaint, "nativeTriggerRepaint"));
|
||||
}
|
||||
|
||||
|
||||
@@ -192,8 +192,6 @@ public:
|
||||
|
||||
jni::Local<jni::Array<jni::jlong>> addMarkers(jni::JNIEnv&, const jni::Array<jni::Object<Marker>>&);
|
||||
|
||||
void setTileCacheEnabled(JNIEnv&, jni::jboolean);
|
||||
|
||||
void onLowMemory(JNIEnv& env);
|
||||
|
||||
void setDebug(JNIEnv&, jni::jboolean);
|
||||
@@ -292,6 +290,10 @@ public:
|
||||
|
||||
jni::jint getPrefetchZoomDelta(JNIEnv&);
|
||||
|
||||
void setTileCacheEnabled(JNIEnv&, jni::jboolean);
|
||||
|
||||
jni::jboolean getTileCacheEnabled(JNIEnv&);
|
||||
|
||||
mbgl::Map& getMap();
|
||||
|
||||
void triggerRepaint(JNIEnv&);
|
||||
|
||||
@@ -324,6 +324,26 @@ public final class MapLibreMap {
|
||||
return nativeMapView.getPrefetchZoomDelta();
|
||||
}
|
||||
|
||||
/**
|
||||
* Indicating whether the map may cache tiles for different zoom levels or not.
|
||||
*
|
||||
* @param enabled true causes the map view to consume more memory and have a smoother user
|
||||
* experience when zoom in/out. The default value of this property is `true`.
|
||||
*/
|
||||
public void setTileCacheEnabled(boolean enabled) {
|
||||
nativeMapView.setTileCacheEnabled(enabled);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check whether tile cache is enabled or not.
|
||||
*
|
||||
* @return true if enabled
|
||||
* @see MapLibreMap#setTileCacheEnabled(boolean)
|
||||
*/
|
||||
public boolean getTileCacheEnabled() {
|
||||
return nativeMapView.getTileCacheEnabled();
|
||||
}
|
||||
|
||||
//
|
||||
// MinZoom
|
||||
//
|
||||
@@ -2504,18 +2524,4 @@ public final class MapLibreMap {
|
||||
listener.onDeveloperAnimationStarted();
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Tile cache
|
||||
//
|
||||
|
||||
/**
|
||||
* Indicating whether the map may cache tiles for different zoom levels or not.
|
||||
*
|
||||
* @param enabled true causes the map view to consume more memory and have a smoother user
|
||||
* experience when zoom in/out. The default value of this property is `true`.
|
||||
*/
|
||||
public void experimental_setTileCacheEnabled(boolean enabled) {
|
||||
nativeMapView.setTileCacheEnabled(enabled);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -33,8 +33,6 @@ interface NativeMap {
|
||||
|
||||
void resizeView(int width, int height);
|
||||
|
||||
void setTileCacheEnabled(boolean enabled);
|
||||
|
||||
void onLowMemory();
|
||||
|
||||
void destroy();
|
||||
@@ -235,6 +233,10 @@ interface NativeMap {
|
||||
@IntRange(from = 0)
|
||||
int getPrefetchZoomDelta();
|
||||
|
||||
void setTileCacheEnabled(boolean enabled);
|
||||
|
||||
boolean getTileCacheEnabled();
|
||||
|
||||
void setGestureInProgress(boolean inProgress);
|
||||
|
||||
float getPixelRatio();
|
||||
|
||||
@@ -619,14 +619,6 @@ final class NativeMapView implements NativeMap {
|
||||
nativeSetVisibleCoordinateBounds(coordinates, padding, direction, duration);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setTileCacheEnabled(boolean enabled) {
|
||||
if (checkState("setTileCacheEnabled")) {
|
||||
return;
|
||||
}
|
||||
nativeSetTileCacheEnabled(enabled);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLowMemory() {
|
||||
if (checkState("onLowMemory")) {
|
||||
@@ -815,6 +807,21 @@ final class NativeMapView implements NativeMap {
|
||||
return nativeGetPrefetchZoomDelta();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setTileCacheEnabled(boolean enabled) {
|
||||
if (checkState("setTileCacheEnabled")) {
|
||||
return;
|
||||
}
|
||||
nativeSetTileCacheEnabled(enabled);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getTileCacheEnabled() {
|
||||
if (checkState("getTileCacheEnabled")) {
|
||||
return false;
|
||||
}
|
||||
return nativeGetTileCacheEnabled();
|
||||
}
|
||||
// Runtime style Api
|
||||
|
||||
@Override
|
||||
@@ -1340,9 +1347,6 @@ final class NativeMapView implements NativeMap {
|
||||
private native void nativeSetVisibleCoordinateBounds(LatLng[] coordinates, RectF padding,
|
||||
double direction, long duration);
|
||||
|
||||
@Keep
|
||||
private native void nativeSetTileCacheEnabled(boolean enabled);
|
||||
|
||||
@Keep
|
||||
private native void nativeOnLowMemory();
|
||||
|
||||
@@ -1510,6 +1514,12 @@ final class NativeMapView implements NativeMap {
|
||||
@Keep
|
||||
private native void nativeSetPrefetchZoomDelta(int delta);
|
||||
|
||||
@Keep
|
||||
private native void nativeSetTileCacheEnabled(boolean enabled);
|
||||
|
||||
@Keep
|
||||
private native boolean nativeGetTileCacheEnabled();
|
||||
|
||||
@Keep
|
||||
private native int nativeGetPrefetchZoomDelta();
|
||||
|
||||
|
||||
@@ -32,12 +32,12 @@ import org.maplibre.android.testapp.activity.EspressoTest
|
||||
* with the application UI-thread.
|
||||
*
|
||||
*/
|
||||
@Deprecated("remove this file when removing deprecated annotations")
|
||||
class MapLibreMapTest : EspressoTest() {
|
||||
//
|
||||
// InfoWindow
|
||||
//
|
||||
@Test
|
||||
@Deprecated("remove this test when removing deprecated annotations")
|
||||
fun testConcurrentInfoWindowEnabled() {
|
||||
validateTestSetup()
|
||||
onView(ViewMatchers.withId(R.id.mapView)).perform(MapLibreMapAction { uiController: UiController?, view: View? ->
|
||||
@@ -47,6 +47,7 @@ class MapLibreMapTest : EspressoTest() {
|
||||
}
|
||||
|
||||
@Test
|
||||
@Deprecated("remove this test when removing deprecated annotations")
|
||||
fun testConcurrentInfoWindowDisabled() {
|
||||
validateTestSetup()
|
||||
onView(ViewMatchers.withId(R.id.mapView)).perform(MapLibreMapAction { uiController: UiController?, view: View? ->
|
||||
@@ -56,6 +57,7 @@ class MapLibreMapTest : EspressoTest() {
|
||||
}
|
||||
|
||||
@Test
|
||||
@Deprecated("remove this test when removing deprecated annotations")
|
||||
fun testInfoWindowAdapter() {
|
||||
validateTestSetup()
|
||||
onView(ViewMatchers.withId(R.id.mapView)).perform(MapLibreMapAction { uiController: UiController?, view: View? ->
|
||||
@@ -69,6 +71,7 @@ class MapLibreMapTest : EspressoTest() {
|
||||
// Annotations
|
||||
//
|
||||
@Test
|
||||
@Deprecated("remove this test when removing deprecated annotations")
|
||||
fun testAddMarker() {
|
||||
validateTestSetup()
|
||||
onView(ViewMatchers.withId(R.id.mapView)).perform(MapLibreMapAction { uiController: UiController?, view: View? ->
|
||||
@@ -79,11 +82,13 @@ class MapLibreMapTest : EspressoTest() {
|
||||
}
|
||||
|
||||
@Test(expected = InvalidMarkerPositionException::class)
|
||||
@Deprecated("remove this test when removing deprecated annotations")
|
||||
fun testAddMarkerInvalidPosition() {
|
||||
MarkerOptions().marker
|
||||
}
|
||||
|
||||
@Test
|
||||
@Deprecated("remove this test when removing deprecated annotations")
|
||||
fun testAddMarkers() {
|
||||
validateTestSetup()
|
||||
onView(ViewMatchers.withId(R.id.mapView)).perform(MapLibreMapAction { uiController: UiController?, view: View? ->
|
||||
@@ -100,6 +105,7 @@ class MapLibreMapTest : EspressoTest() {
|
||||
}
|
||||
|
||||
@Test
|
||||
@Deprecated("remove this test when removing deprecated annotations")
|
||||
fun testAddMarkersEmpty() {
|
||||
validateTestSetup()
|
||||
onView(ViewMatchers.withId(R.id.mapView)).perform(MapLibreMapAction { uiController: UiController?, view: View? ->
|
||||
@@ -110,6 +116,7 @@ class MapLibreMapTest : EspressoTest() {
|
||||
}
|
||||
|
||||
@Test
|
||||
@Deprecated("remove this test when removing deprecated annotations")
|
||||
fun testAddMarkersSingleMarker() {
|
||||
validateTestSetup()
|
||||
onView(ViewMatchers.withId(R.id.mapView)).perform(MapLibreMapAction { uiController: UiController?, view: View? ->
|
||||
@@ -123,6 +130,7 @@ class MapLibreMapTest : EspressoTest() {
|
||||
}
|
||||
|
||||
@Test
|
||||
@Deprecated("remove this test when removing deprecated annotations")
|
||||
fun testAddPolygon() {
|
||||
validateTestSetup()
|
||||
onView(ViewMatchers.withId(R.id.mapView)).perform(MapLibreMapAction { uiController: UiController?, view: View? ->
|
||||
@@ -133,6 +141,7 @@ class MapLibreMapTest : EspressoTest() {
|
||||
}
|
||||
|
||||
@Test
|
||||
@Deprecated("remove this test when removing deprecated annotations")
|
||||
fun testAddEmptyPolygon() {
|
||||
validateTestSetup()
|
||||
onView(ViewMatchers.withId(R.id.mapView)).perform(MapLibreMapAction { uiController: UiController?, view: View? ->
|
||||
@@ -143,6 +152,7 @@ class MapLibreMapTest : EspressoTest() {
|
||||
}
|
||||
|
||||
@Test
|
||||
@Deprecated("remove this test when removing deprecated annotations")
|
||||
fun testAddPolygons() {
|
||||
validateTestSetup()
|
||||
onView(ViewMatchers.withId(R.id.mapView)).perform(MapLibreMapAction { uiController: UiController?, view: View? ->
|
||||
@@ -162,6 +172,7 @@ class MapLibreMapTest : EspressoTest() {
|
||||
}
|
||||
|
||||
@Test
|
||||
@Deprecated("remove this test when removing deprecated annotations")
|
||||
fun addPolygonsEmpty() {
|
||||
validateTestSetup()
|
||||
onView(ViewMatchers.withId(R.id.mapView)).perform(MapLibreMapAction { uiController: UiController?, view: View? ->
|
||||
@@ -171,6 +182,7 @@ class MapLibreMapTest : EspressoTest() {
|
||||
}
|
||||
|
||||
@Test
|
||||
@Deprecated("remove this test when removing deprecated annotations")
|
||||
fun addPolygonsSingle() {
|
||||
validateTestSetup()
|
||||
onView(ViewMatchers.withId(R.id.mapView)).perform(MapLibreMapAction { uiController: UiController?, view: View? ->
|
||||
@@ -184,6 +196,7 @@ class MapLibreMapTest : EspressoTest() {
|
||||
}
|
||||
|
||||
@Test
|
||||
@Deprecated("remove this test when removing deprecated annotations")
|
||||
fun testAddPolyline() {
|
||||
validateTestSetup()
|
||||
onView(ViewMatchers.withId(R.id.mapView)).perform(MapLibreMapAction { uiController: UiController?, view: View? ->
|
||||
@@ -194,6 +207,7 @@ class MapLibreMapTest : EspressoTest() {
|
||||
}
|
||||
|
||||
@Test
|
||||
@Deprecated("remove this test when removing deprecated annotations")
|
||||
fun testAddEmptyPolyline() {
|
||||
validateTestSetup()
|
||||
onView(ViewMatchers.withId(R.id.mapView)).perform(MapLibreMapAction { uiController: UiController?, view: View? ->
|
||||
@@ -204,6 +218,7 @@ class MapLibreMapTest : EspressoTest() {
|
||||
}
|
||||
|
||||
@Test
|
||||
@Deprecated("remove this test when removing deprecated annotations")
|
||||
fun testAddPolylines() {
|
||||
validateTestSetup()
|
||||
onView(ViewMatchers.withId(R.id.mapView)).perform(MapLibreMapAction { uiController: UiController?, view: View? ->
|
||||
@@ -219,12 +234,13 @@ class MapLibreMapTest : EspressoTest() {
|
||||
assertTrue(maplibreMap.polylines.contains(polygonOptions1.polyline))
|
||||
assertTrue(maplibreMap.polylines.contains(polygonOptions2.polyline))
|
||||
assertTrue(
|
||||
"Polyline should be ignored", !maplibreMap.polylines.contains(polygonOptions3.polyline)
|
||||
"Polyline should be ignored", !maplibreMap.polylines.contains(polygonOptions3.polyline)
|
||||
)
|
||||
})
|
||||
}
|
||||
|
||||
@Test
|
||||
@Deprecated("remove this test when removing deprecated annotations")
|
||||
fun testAddPolylinesEmpty() {
|
||||
validateTestSetup()
|
||||
onView(ViewMatchers.withId(R.id.mapView)).perform(MapLibreMapAction { uiController: UiController?, view: View? ->
|
||||
@@ -234,6 +250,7 @@ class MapLibreMapTest : EspressoTest() {
|
||||
}
|
||||
|
||||
@Test
|
||||
@Deprecated("remove this test when removing deprecated annotations")
|
||||
fun testAddPolylinesSingle() {
|
||||
validateTestSetup()
|
||||
onView(ViewMatchers.withId(R.id.mapView)).perform(MapLibreMapAction { uiController: UiController?, view: View? ->
|
||||
@@ -247,6 +264,7 @@ class MapLibreMapTest : EspressoTest() {
|
||||
}
|
||||
|
||||
@Test
|
||||
@Deprecated("remove this test when removing deprecated annotations")
|
||||
fun testRemoveMarker() {
|
||||
validateTestSetup()
|
||||
onView(ViewMatchers.withId(R.id.mapView)).perform(MapLibreMapAction { uiController: UiController?, view: View? ->
|
||||
@@ -258,6 +276,7 @@ class MapLibreMapTest : EspressoTest() {
|
||||
}
|
||||
|
||||
@Test
|
||||
@Deprecated("remove this test when removing deprecated annotations")
|
||||
fun testRemovePolygon() {
|
||||
validateTestSetup()
|
||||
onView(ViewMatchers.withId(R.id.mapView)).perform(MapLibreMapAction { uiController: UiController?, view: View? ->
|
||||
@@ -269,6 +288,7 @@ class MapLibreMapTest : EspressoTest() {
|
||||
}
|
||||
|
||||
@Test
|
||||
@Deprecated("remove this test when removing deprecated annotations")
|
||||
fun testRemovePolyline() {
|
||||
validateTestSetup()
|
||||
onView(ViewMatchers.withId(R.id.mapView)).perform(MapLibreMapAction { uiController: UiController?, view: View? ->
|
||||
@@ -280,6 +300,7 @@ class MapLibreMapTest : EspressoTest() {
|
||||
}
|
||||
|
||||
@Test
|
||||
@Deprecated("remove this test when removing deprecated annotations")
|
||||
fun testRemoveAnnotation() {
|
||||
validateTestSetup()
|
||||
onView(ViewMatchers.withId(R.id.mapView)).perform(MapLibreMapAction { uiController: UiController?, view: View? ->
|
||||
@@ -291,6 +312,7 @@ class MapLibreMapTest : EspressoTest() {
|
||||
}
|
||||
|
||||
@Test
|
||||
@Deprecated("remove this test when removing deprecated annotations")
|
||||
fun testRemoveAnnotationById() {
|
||||
validateTestSetup()
|
||||
onView(ViewMatchers.withId(R.id.mapView)).perform(MapLibreMapAction { uiController: UiController?, view: View? ->
|
||||
@@ -303,6 +325,7 @@ class MapLibreMapTest : EspressoTest() {
|
||||
}
|
||||
|
||||
@Test
|
||||
@Deprecated("remove this test when removing deprecated annotations")
|
||||
fun testRemoveAnnotations() {
|
||||
validateTestSetup()
|
||||
onView(ViewMatchers.withId(R.id.mapView)).perform(MapLibreMapAction { uiController: UiController?, view: View? ->
|
||||
@@ -318,6 +341,7 @@ class MapLibreMapTest : EspressoTest() {
|
||||
}
|
||||
|
||||
@Test
|
||||
@Deprecated("remove this test when removing deprecated annotations")
|
||||
fun testClear() {
|
||||
validateTestSetup()
|
||||
onView(ViewMatchers.withId(R.id.mapView)).perform(MapLibreMapAction { uiController: UiController?, view: View? ->
|
||||
@@ -333,6 +357,7 @@ class MapLibreMapTest : EspressoTest() {
|
||||
}
|
||||
|
||||
@Test
|
||||
@Deprecated("remove this test when removing deprecated annotations")
|
||||
fun testRemoveAnnotationsByList() {
|
||||
validateTestSetup()
|
||||
onView(ViewMatchers.withId(R.id.mapView)).perform(MapLibreMapAction { uiController: UiController?, view: View? ->
|
||||
@@ -350,6 +375,7 @@ class MapLibreMapTest : EspressoTest() {
|
||||
}
|
||||
|
||||
@Test
|
||||
@Deprecated("remove this test when removing deprecated annotations")
|
||||
fun testGetAnnotationById() {
|
||||
validateTestSetup()
|
||||
onView(ViewMatchers.withId(R.id.mapView)).perform(MapLibreMapAction { uiController: UiController?, view: View? ->
|
||||
@@ -361,22 +387,25 @@ class MapLibreMapTest : EspressoTest() {
|
||||
}
|
||||
|
||||
@Test
|
||||
@Deprecated("remove this test when removing deprecated annotations")
|
||||
fun testGetAnnotations() {
|
||||
validateTestSetup()
|
||||
onView(ViewMatchers.withId(R.id.mapView)).perform(
|
||||
MapLibreMapAction { uiController: UiController?, view: View? -> TestCase.assertNotNull("Annotations should be non null", maplibreMap.annotations) }
|
||||
MapLibreMapAction { uiController: UiController?, view: View? -> TestCase.assertNotNull("Annotations should be non null", maplibreMap.annotations) }
|
||||
)
|
||||
}
|
||||
|
||||
@Test
|
||||
@Deprecated("remove this test when removing deprecated annotations")
|
||||
fun testGetMarkers() {
|
||||
validateTestSetup()
|
||||
onView(ViewMatchers.withId(R.id.mapView)).perform(
|
||||
MapLibreMapAction { uiController: UiController?, view: View? -> TestCase.assertNotNull("Markers should be non null", maplibreMap.markers) }
|
||||
MapLibreMapAction { uiController: UiController?, view: View? -> TestCase.assertNotNull("Markers should be non null", maplibreMap.markers) }
|
||||
)
|
||||
}
|
||||
|
||||
@Test
|
||||
@Deprecated("remove this test when removing deprecated annotations")
|
||||
fun testGetPolygons() {
|
||||
validateTestSetup()
|
||||
onView(ViewMatchers.withId(R.id.mapView)).perform(MapLibreMapAction { uiController: UiController?, view: View? -> TestCase.assertNotNull("Polygons should be non null", maplibreMap.polygons) }
|
||||
@@ -384,6 +413,7 @@ class MapLibreMapTest : EspressoTest() {
|
||||
}
|
||||
|
||||
@Test
|
||||
@Deprecated("remove this test when removing deprecated annotations")
|
||||
fun testGetPolylines() {
|
||||
validateTestSetup()
|
||||
onView(ViewMatchers.withId(R.id.mapView)).perform(MapLibreMapAction { uiController: UiController?, view: View? -> TestCase.assertNotNull("Polylines should be non null", maplibreMap.polylines) }
|
||||
@@ -391,6 +421,7 @@ class MapLibreMapTest : EspressoTest() {
|
||||
}
|
||||
|
||||
@Test
|
||||
@Deprecated("remove this test when removing deprecated annotations")
|
||||
fun testGetSelectedMarkers() {
|
||||
validateTestSetup()
|
||||
onView(ViewMatchers.withId(R.id.mapView)).perform(MapLibreMapAction { uiController: UiController?, view: View? -> TestCase.assertNotNull("Selected markers should be non null", maplibreMap.selectedMarkers) }
|
||||
@@ -398,6 +429,7 @@ class MapLibreMapTest : EspressoTest() {
|
||||
}
|
||||
|
||||
@Test
|
||||
@Deprecated("remove this test when removing deprecated annotations")
|
||||
fun testSelectMarker() {
|
||||
validateTestSetup()
|
||||
onView(ViewMatchers.withId(R.id.mapView)).perform(MapLibreMapAction { uiController: UiController?, view: View? ->
|
||||
@@ -409,6 +441,7 @@ class MapLibreMapTest : EspressoTest() {
|
||||
}
|
||||
|
||||
@Test
|
||||
@Deprecated("remove this test when removing deprecated annotations")
|
||||
fun testDeselectMarker() {
|
||||
validateTestSetup()
|
||||
onView(ViewMatchers.withId(R.id.mapView)).perform(MapLibreMapAction { uiController: UiController?, view: View? ->
|
||||
@@ -421,6 +454,7 @@ class MapLibreMapTest : EspressoTest() {
|
||||
}
|
||||
|
||||
@Test
|
||||
@Deprecated("remove this test when removing deprecated annotations")
|
||||
fun testDeselectMarkers() {
|
||||
validateTestSetup()
|
||||
onView(ViewMatchers.withId(R.id.mapView)).perform(MapLibreMapAction { uiController: UiController?, view: View? ->
|
||||
@@ -434,6 +468,19 @@ class MapLibreMapTest : EspressoTest() {
|
||||
})
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testTileCache() {
|
||||
validateTestSetup()
|
||||
rule.runOnUiThread {
|
||||
maplibreMap.tileCacheEnabled = false
|
||||
assertTrue(maplibreMap.tileCacheEnabled == false)
|
||||
|
||||
maplibreMap.tileCacheEnabled = true
|
||||
assertTrue(maplibreMap.tileCacheEnabled == true)
|
||||
}
|
||||
}
|
||||
|
||||
@Deprecated("remove this class when removing deprecated annotations")
|
||||
inner class MapLibreMapAction internal constructor(private val invokeViewAction: InvokeViewAction) : ViewAction {
|
||||
override fun getConstraints(): Matcher<View> {
|
||||
return ViewMatchers.isDisplayed()
|
||||
@@ -448,6 +495,7 @@ class MapLibreMapTest : EspressoTest() {
|
||||
}
|
||||
}
|
||||
|
||||
@Deprecated("remove this interface when removing deprecated annotations")
|
||||
internal fun interface InvokeViewAction {
|
||||
fun onViewAction(uiController: UiController?, view: View?)
|
||||
}
|
||||
|
||||
@@ -63,6 +63,11 @@ class MLNRenderFrontend : public mbgl::RendererFrontend {
|
||||
renderer->setTileCacheEnabled(enable);
|
||||
}
|
||||
|
||||
bool getTileCacheEnabled() {
|
||||
if (!renderer) return false;
|
||||
return renderer->getTileCacheEnabled();
|
||||
}
|
||||
|
||||
void reduceMemoryUse() {
|
||||
if (!renderer) return;
|
||||
renderer->reduceMemoryUse();
|
||||
|
||||
@@ -152,4 +152,13 @@ static MLNMapView *mapView;
|
||||
[self waitForExpectations:@[expectation] timeout:1];
|
||||
}
|
||||
|
||||
- (void)testTileCache {
|
||||
mapView.tileCacheEnabled = NO;
|
||||
XCTAssertEqual(mapView.tileCacheEnabled, NO);
|
||||
|
||||
mapView.tileCacheEnabled = YES;
|
||||
XCTAssertEqual(mapView.tileCacheEnabled, YES);
|
||||
}
|
||||
|
||||
|
||||
@end
|
||||
|
||||
@@ -415,6 +415,17 @@ MLN_EXPORT
|
||||
*/
|
||||
@property (nonatomic, assign) BOOL prefetchesTiles;
|
||||
|
||||
/**
|
||||
A Boolean value indicating whether the map may cache tiles for different zoom levels or not.
|
||||
|
||||
When this property is set to `YES`, the map view consumes more memory and
|
||||
provide a smoother user experience when zoom in/out.
|
||||
|
||||
The default value of this property is `YES`.
|
||||
*/
|
||||
|
||||
@property (nonatomic, assign) BOOL tileCacheEnabled;
|
||||
|
||||
// MARK: Displaying the User’s Location
|
||||
|
||||
/**
|
||||
@@ -2093,16 +2104,6 @@ vertically on the map.
|
||||
predicate:(nullable NSPredicate *)predicate
|
||||
NS_SWIFT_NAME(visibleFeatures(in:styleLayerIdentifiers:predicate:));
|
||||
|
||||
// MARK: Tile Cache
|
||||
|
||||
/**
|
||||
Indicating whether the map may cache tiles for different zoom levels or not.
|
||||
|
||||
@param enabled causes the map view to consume more memory and have a smoother user
|
||||
* experience when zoom in/out. The default value of this property is `YES`.
|
||||
*/
|
||||
- (void)experimental_setTileCacheEnabled:(BOOL)enabled;
|
||||
|
||||
// MARK: Debugging the Map
|
||||
|
||||
/**
|
||||
|
||||
@@ -3149,6 +3149,16 @@ static void *windowScreenContext = &windowScreenContext;
|
||||
return self.mbglMap.getPrefetchZoomDelta() > 0 ? YES : NO;
|
||||
}
|
||||
|
||||
- (void)setTileCacheEnabled:(BOOL)enabled
|
||||
{
|
||||
_rendererFrontend->setTileCacheEnabled(enabled);
|
||||
}
|
||||
|
||||
- (BOOL)tileCacheEnabled
|
||||
{
|
||||
return _rendererFrontend->getTileCacheEnabled();
|
||||
}
|
||||
|
||||
// MARK: - Accessibility -
|
||||
|
||||
- (NSString *)accessibilityValue
|
||||
@@ -7340,12 +7350,6 @@ static void *windowScreenContext = &windowScreenContext;
|
||||
return _mbglView->getObject();
|
||||
}
|
||||
|
||||
// MARK: Tile Cache
|
||||
|
||||
- (void)experimental_setTileCacheEnabled:(BOOL)enabled {
|
||||
_rendererFrontend->setTileCacheEnabled(enabled);
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
// MARK: - IBAdditions methods
|
||||
|
||||
@@ -342,7 +342,7 @@ std::unique_ptr<RenderTree> RenderOrchestrator::createRenderTree(
|
||||
MLN_TRACE_ZONE(create source);
|
||||
std::unique_ptr<RenderSource> renderSource = RenderSource::create(entry.second, threadPool);
|
||||
renderSource->setObserver(this);
|
||||
renderSource->enableCache(tileCacheEnabled);
|
||||
renderSource->setCacheEnabled(tileCacheEnabled);
|
||||
renderSources.emplace(entry.first, std::move(renderSource));
|
||||
}
|
||||
transformState = updateParameters->transformState;
|
||||
@@ -769,10 +769,14 @@ void RenderOrchestrator::setTileCacheEnabled(bool enable) {
|
||||
tileCacheEnabled = enable;
|
||||
|
||||
for (const auto& entry : renderSources) {
|
||||
entry.second->enableCache(enable);
|
||||
entry.second->setCacheEnabled(enable);
|
||||
}
|
||||
}
|
||||
|
||||
bool RenderOrchestrator::getTileCacheEnabled() const {
|
||||
return tileCacheEnabled;
|
||||
}
|
||||
|
||||
void RenderOrchestrator::reduceMemoryUse() {
|
||||
MLN_TRACE_FUNC()
|
||||
|
||||
|
||||
@@ -93,6 +93,7 @@ public:
|
||||
const std::optional<std::string>& stateKey);
|
||||
|
||||
void setTileCacheEnabled(bool);
|
||||
bool getTileCacheEnabled() const;
|
||||
void reduceMemoryUse();
|
||||
void dumpDebugLogs();
|
||||
void collectPlacedSymbolData(bool);
|
||||
|
||||
@@ -101,7 +101,7 @@ public:
|
||||
const std::optional<std::string>&,
|
||||
const std::optional<std::string>&) {}
|
||||
|
||||
virtual void enableCache(bool) {};
|
||||
virtual void setCacheEnabled(bool) {};
|
||||
|
||||
virtual void reduceMemoryUse() = 0;
|
||||
|
||||
|
||||
@@ -138,6 +138,10 @@ void Renderer::setTileCacheEnabled(bool enable) {
|
||||
impl->orchestrator.setTileCacheEnabled(enable);
|
||||
}
|
||||
|
||||
bool Renderer::getTileCacheEnabled() const {
|
||||
return impl->orchestrator.getTileCacheEnabled();
|
||||
}
|
||||
|
||||
void Renderer::reduceMemoryUse() {
|
||||
gfx::BackendScope guard{impl->backend};
|
||||
impl->reduceMemoryUse();
|
||||
|
||||
@@ -497,8 +497,8 @@ void RenderTileSource::removeFeatureState(const std::optional<std::string>& sour
|
||||
featureState.removeState(sourceLayerID, featureID, stateKey);
|
||||
}
|
||||
|
||||
void RenderTileSource::enableCache(bool enable) {
|
||||
tilePyramid.enableCache(enable);
|
||||
void RenderTileSource::setCacheEnabled(bool enable) {
|
||||
tilePyramid.setCacheEnabled(enable);
|
||||
}
|
||||
|
||||
void RenderTileSource::reduceMemoryUse() {
|
||||
|
||||
@@ -47,7 +47,7 @@ public:
|
||||
const std::optional<std::string>&,
|
||||
const std::optional<std::string>&) override;
|
||||
|
||||
void enableCache(bool) override;
|
||||
void setCacheEnabled(bool) override;
|
||||
void reduceMemoryUse() override;
|
||||
void dumpDebugLogs() const override;
|
||||
|
||||
|
||||
@@ -23,7 +23,7 @@ namespace mbgl {
|
||||
using namespace style;
|
||||
|
||||
static TileObserver nullObserver;
|
||||
static std::map<OverscaledTileID, std::unique_ptr<Tile>> emptyPrefetchedTiles;
|
||||
static const std::map<OverscaledTileID, std::unique_ptr<Tile>> emptyPrefetchedTiles;
|
||||
|
||||
TilePyramid::TilePyramid(const TaggedScheduler& threadPool_)
|
||||
: cache(threadPool_),
|
||||
@@ -398,7 +398,7 @@ std::vector<Feature> TilePyramid::querySourceFeatures(const SourceQueryOptions&
|
||||
return result;
|
||||
}
|
||||
|
||||
void TilePyramid::enableCache(bool enable) {
|
||||
void TilePyramid::setCacheEnabled(bool enable) {
|
||||
cacheEnabled = enable;
|
||||
}
|
||||
|
||||
|
||||
@@ -60,7 +60,7 @@ public:
|
||||
|
||||
std::vector<Feature> querySourceFeatures(const SourceQueryOptions&) const;
|
||||
|
||||
void enableCache(bool);
|
||||
void setCacheEnabled(bool);
|
||||
void reduceMemoryUse();
|
||||
|
||||
void setObserver(TileObserver*);
|
||||
|
||||
Reference in New Issue
Block a user