Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: use texture mode on android to fix compose animations #214

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading