Skip to content

Commit

Permalink
fix: use texture mode on android to fix compose animations (#214)
Browse files Browse the repository at this point in the history
  • Loading branch information
sargunv authored Dec 31, 2024
1 parent 241b266 commit e5f281d
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ private val DEMOS = buildList {
add(AnimatedLayerDemo)
}
if (!Platform.isDesktop) add(CameraStateDemo)
if (Platform.isNative) add(CameraFollowDemo)
if (Platform.usesMaplibreNative) add(CameraFollowDemo)
if (!Platform.isDesktop) add(FrameRateDemo)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import dev.sargunv.maplibrecompose.demoapp.DemoOrnamentSettings
import dev.sargunv.maplibrecompose.demoapp.DemoScaffold
import dev.sargunv.maplibrecompose.demoapp.FrameRateState
import dev.sargunv.maplibrecompose.demoapp.Platform
import dev.sargunv.maplibrecompose.demoapp.isNative
import dev.sargunv.maplibrecompose.demoapp.usesMaplibreNative
import kotlin.math.roundToInt

object FrameRateDemo : Demo {
Expand Down Expand Up @@ -59,7 +59,7 @@ object FrameRateDemo : Demo {
value = maximumFps.toFloat(),
onValueChange = { maximumFps = it.roundToInt() },
valueRange = 15f..systemRefreshRate.toFloat().coerceAtLeast(15f),
enabled = Platform.isNative,
enabled = Platform.usesMaplibreNative,
)
Text(
"Target: $maximumFps ${fpsState.spinChar} Actual: ${fpsState.avgFps}",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,5 @@ val Platform.supportsLayers: Boolean
val Platform.supportsBlending: Boolean
get() = isAndroid || isIos

val Platform.isNative: Boolean
val Platform.usesMaplibreNative: Boolean
get() = isAndroid || isIos

val Platform.isJs: Boolean
get() = isWeb || isDesktop
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import dev.sargunv.maplibrecompose.core.AndroidMap
import dev.sargunv.maplibrecompose.core.AndroidScaleBar
import dev.sargunv.maplibrecompose.core.MaplibreMap
import org.maplibre.android.MapLibre
import org.maplibre.android.maps.MapLibreMapOptions
import org.maplibre.android.maps.MapView

@Composable
Expand Down Expand Up @@ -58,7 +59,8 @@ internal fun AndroidMapView(
modifier = modifier,
factory = { context ->
MapLibre.getInstance(context)
MapView(context).also { mapView ->
MapView(context, MapLibreMapOptions.createFromAttributes(context).textureMode(true)).also {
mapView ->
currentMapView = mapView
mapView.getMapAsync { map ->
currentMap =
Expand Down

0 comments on commit e5f281d

Please sign in to comment.