Browse Source

Add macOS native target to visual-effects-ny benchmark (#3180)

* Add macOS native target to visual-effects-ny benchmark

* handle width/height with expect/actuals
pull/3193/head
Nikita Lipsky 2 years ago committed by GitHub
parent
commit
9b09e68e79
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 1
      benchmarks/ios/visual-effects-ny/androidApp/src/androidMain/kotlin/MainActivity.kt
  2. 21
      benchmarks/ios/visual-effects-ny/shared/build.gradle.kts
  3. 5
      benchmarks/ios/visual-effects-ny/shared/src/androidMain/kotlin/main.android.kt
  4. 7
      benchmarks/ios/visual-effects-ny/shared/src/commonMain/kotlin/HappyNY.kt
  5. 3
      benchmarks/ios/visual-effects-ny/shared/src/desktopMain/kotlin/main.desktop.kt
  6. 4
      benchmarks/ios/visual-effects-ny/shared/src/iosMain/kotlin/actuals.ios.kt
  7. 4
      benchmarks/ios/visual-effects-ny/shared/src/macosMain/kotlin/actuals.macos.kt
  8. 19
      benchmarks/ios/visual-effects-ny/shared/src/macosMain/kotlin/main.macos.kt
  9. 3
      benchmarks/ios/visual-effects-ny/shared/src/macosMain/kotlin/platform/NanoTime.kt

1
benchmarks/ios/visual-effects-ny/androidApp/src/androidMain/kotlin/MainActivity.kt

@ -1,6 +1,5 @@
package org.jetbrains.compose.demo.visuals package org.jetbrains.compose.demo.visuals
import MainView
import android.os.Bundle import android.os.Bundle
import androidx.activity.compose.setContent import androidx.activity.compose.setContent
import androidx.appcompat.app.AppCompatActivity import androidx.appcompat.app.AppCompatActivity

21
benchmarks/ios/visual-effects-ny/shared/build.gradle.kts

@ -15,6 +15,21 @@ kotlin {
ios() ios()
iosSimulatorArm64() iosSimulatorArm64()
macosX64 {
binaries {
executable {
entryPoint = "main"
}
}
}
macosArm64 {
binaries {
executable {
entryPoint = "main"
}
}
}
cocoapods { cocoapods {
summary = "Shared code for the sample" summary = "Shared code for the sample"
homepage = "https://github.com/JetBrains/compose-jb" homepage = "https://github.com/JetBrains/compose-jb"
@ -54,6 +69,12 @@ kotlin {
implementation(compose.desktop.common) implementation(compose.desktop.common)
} }
} }
val macosMain by creating {
dependsOn(commonMain)
}
val macosArm64Main by getting {
dependsOn(macosMain)
}
} }
} }

5
benchmarks/ios/visual-effects-ny/shared/src/androidMain/kotlin/main.android.kt

@ -1,5 +1,10 @@
package org.jetbrains.compose.demo.visuals
import androidx.compose.runtime.Composable import androidx.compose.runtime.Composable
import org.jetbrains.compose.demo.visuals.NYContent import org.jetbrains.compose.demo.visuals.NYContent
actual fun width(): Int = 400
actual fun height(): Int = 800
@Composable @Composable
fun MainView() = NYContent() fun MainView() = NYContent()

7
benchmarks/ios/visual-effects-ny/shared/src/commonMain/kotlin/HappyNY.kt

@ -17,8 +17,11 @@ import org.jetbrains.compose.demo.visuals.platform.nanoTime
import kotlin.math.* import kotlin.math.*
import kotlin.random.Random import kotlin.random.Random
const val width = 400 expect fun width(): Int
const val height = 800 expect fun height(): Int
val width = width()
val height = height()
const val snowCount = 80 const val snowCount = 80
const val starCount = 60 const val starCount = 60
const val rocketPartsCount = 30 const val rocketPartsCount = 30

3
benchmarks/ios/visual-effects-ny/shared/src/desktopMain/kotlin/main.desktop.kt

@ -5,6 +5,9 @@ import androidx.compose.runtime.remember
import androidx.compose.ui.unit.dp import androidx.compose.ui.unit.dp
import androidx.compose.ui.window.* import androidx.compose.ui.window.*
actual fun width(): Int = 640
actual fun height(): Int = 480
@Composable @Composable
fun NYWindow(onCloseRequest: () -> Unit) { fun NYWindow(onCloseRequest: () -> Unit) {
val windowState = remember { WindowState(width = width.dp, height = height.dp) } val windowState = remember { WindowState(width = width.dp, height = height.dp) }

4
benchmarks/ios/visual-effects-ny/shared/src/iosMain/kotlin/actuals.ios.kt

@ -0,0 +1,4 @@
package org.jetbrains.compose.demo.visuals
actual fun width(): Int = 400
actual fun height(): Int = 800

4
benchmarks/ios/visual-effects-ny/shared/src/macosMain/kotlin/actuals.macos.kt

@ -0,0 +1,4 @@
package org.jetbrains.compose.demo.visuals
actual fun width(): Int = 640
actual fun height(): Int = 480

19
benchmarks/ios/visual-effects-ny/shared/src/macosMain/kotlin/main.macos.kt

@ -0,0 +1,19 @@
/*
* Copyright 2020-2021 JetBrains s.r.o. and respective authors and developers.
* Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE.txt file.
*/
import androidx.compose.ui.window.Window
import androidx.compose.runtime.remember
import androidx.compose.ui.unit.dp
import org.jetbrains.compose.demo.visuals.NYContent
import platform.AppKit.NSApp
import platform.AppKit.NSApplication
fun main() {
NSApplication.sharedApplication()
Window("Visual Effects") {
NYContent()
}
NSApp?.run()
}

3
benchmarks/ios/visual-effects-ny/shared/src/macosMain/kotlin/platform/NanoTime.kt

@ -0,0 +1,3 @@
package org.jetbrains.compose.demo.visuals.platform
actual fun nanoTime(): Long = kotlin.system.getTimeNanos()
Loading…
Cancel
Save