Skip to content

Commit 6c21968

Browse files
committed
Register the Skiko UI implementation at Compose entry points
Wire registerSkikoComposeImplementation() into the Skiko-backed Compose entry points so the ui-graphics/ui-text registries are populated before any scene is created: desktop ComposePanel/ComposeWindowPanel, macOS ComposeWindow, iOS ComposeUIViewController, web ComposeWindowInternal, ImageComposeScene, and the ui-test rules. Adds the :compose:ui:ui-skiko dependency to the modules that rely on the Skiko backend transitively (ui, ui-test, ui-test-junit4, foundation) and registers in the affected test harnesses.
1 parent 59933d2 commit 6c21968

21 files changed

Lines changed: 73 additions & 10 deletions

File tree

compose/foundation/foundation/build.gradle

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,7 @@ androidXMultiplatform {
125125
// TODO(https://youtrack.jetbrains.com/issue/CMP-219) Remove API
126126
api(libs.skiko)
127127
implementation(libs.atomicFu)
128+
implementation(project(":compose:ui:ui-skiko"))
128129
}
129130
}
130131

compose/ui/ui-test-junit4/build.gradle

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,7 @@ androidXMultiplatform {
119119
dependencies {
120120
implementation(libs.truth)
121121
implementation(libs.skiko)
122+
implementation(project(":compose:ui:ui-skiko"))
122123
}
123124
}
124125

compose/ui/ui-test-junit4/src/desktopMain/kotlin/androidx/compose/ui/test/junit4/DesktopComposeTestRule.desktop.kt

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ package androidx.compose.ui.test.junit4
1818

1919
import androidx.compose.runtime.Composable
2020
import androidx.compose.ui.InternalComposeUiApi
21+
import androidx.compose.ui.platform.registerSkikoComposeImplementation
2122
import androidx.compose.ui.scene.ComposeScene
2223
import androidx.compose.ui.test.DesktopComposeUiTest
2324
import androidx.compose.ui.test.ExperimentalTestApi
@@ -44,14 +45,16 @@ import org.junit.runners.model.Statement
4445
"coroutines are queued rather than executed immediately.",
4546
level = DeprecationLevel.WARNING,
4647
)
47-
@OptIn(InternalTestApi::class, ExperimentalTestApi::class)
48-
actual fun createComposeRule(): ComposeContentTestRule =
49-
DesktopComposeTestRule(
48+
@OptIn(InternalTestApi::class, ExperimentalTestApi::class, InternalComposeUiApi::class)
49+
actual fun createComposeRule(): ComposeContentTestRule {
50+
registerSkikoComposeImplementation()
51+
return DesktopComposeTestRule(
5052
DesktopComposeUiTest(
5153
effectContext = EmptyCoroutineContext,
5254
useStandardTestDispatcherForComposition = false
5355
)
5456
)
57+
}
5558

5659
@Deprecated(
5760
message =
@@ -61,14 +64,16 @@ actual fun createComposeRule(): ComposeContentTestRule =
6164
level = DeprecationLevel.WARNING,
6265
)
6366
@ExperimentalTestApi
64-
@OptIn(InternalTestApi::class)
65-
actual fun createComposeRule(effectContext: CoroutineContext): ComposeContentTestRule =
66-
DesktopComposeTestRule(
67+
@OptIn(InternalTestApi::class, InternalComposeUiApi::class)
68+
actual fun createComposeRule(effectContext: CoroutineContext): ComposeContentTestRule {
69+
registerSkikoComposeImplementation()
70+
return DesktopComposeTestRule(
6771
DesktopComposeUiTest(
6872
effectContext = effectContext,
6973
useStandardTestDispatcherForComposition = false
7074
)
7175
)
76+
}
7277

7378
@InternalTestApi
7479
@OptIn(ExperimentalTestApi::class)

compose/ui/ui-test-junit4/src/desktopMain/kotlin/androidx/compose/ui/test/junit4/DesktopScreenshotTestRule.desktop.kt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616
package androidx.compose.ui.test.junit4
1717

1818
import androidx.annotation.FloatRange
19+
import androidx.compose.ui.InternalComposeUiApi
20+
import androidx.compose.ui.platform.registerSkikoComposeImplementation
1921
import androidx.compose.ui.test.InternalTestApi
2022
import androidx.compose.ui.test.junit4.ScreenshotResultProto.Status
2123
import androidx.compose.ui.test.junit4.matchers.BitmapMatcher
@@ -57,10 +59,12 @@ private data class ScreenshotResultProto(
5759
}
5860

5961
@InternalTestApi
62+
@OptIn(InternalComposeUiApi::class)
6063
fun DesktopScreenshotTestRule(
6164
modulePath: String,
6265
fsGoldenPath: String = System.getProperty("GOLDEN_PATH")
6366
): ScreenshotTestRule {
67+
registerSkikoComposeImplementation()
6468
return ScreenshotTestRule(fsGoldenPath, modulePath)
6569
}
6670

compose/ui/ui-test/build.gradle

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,7 @@ androidXMultiplatform {
125125
dependsOn(commonMain)
126126
dependencies {
127127
implementation(libs.atomicFu)
128+
implementation(project(":compose:ui:ui-skiko"))
128129

129130
// Required to properly resolve supertypes of DefaultArchitectureComponentsOwner
130131
// Keep in sync with :ui:ui module

compose/ui/ui-test/src/desktopMain/kotlin/androidx/compose/ui/test/ComposeUiTest.desktop.kt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616

1717
package androidx.compose.ui.test
1818

19+
import androidx.compose.ui.InternalComposeUiApi
20+
import androidx.compose.ui.platform.registerSkikoComposeImplementation
1921
import androidx.compose.ui.unit.Density
2022
import kotlin.coroutines.CoroutineContext
2123
import kotlin.coroutines.EmptyCoroutineContext
@@ -38,6 +40,7 @@ import kotlinx.coroutines.ExperimentalCoroutinesApi
3840
level = DeprecationLevel.WARNING,
3941
)
4042
@ExperimentalTestApi
43+
@OptIn(InternalComposeUiApi::class)
4144
fun runDesktopComposeUiTest(
4245
width: Int = 1024,
4346
height: Int = 768,
@@ -46,6 +49,7 @@ fun runDesktopComposeUiTest(
4649
testTimeout: Duration = Duration.INFINITE,
4750
block: suspend DesktopComposeUiTest.() -> Unit
4851
) {
52+
registerSkikoComposeImplementation()
4953
kotlinx.coroutines.test.runTest {
5054
with(
5155
DesktopComposeUiTest(

compose/ui/ui-test/src/skikoMain/kotlin/androidx/compose/ui/test/ComposeUiTest.skiko.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ import androidx.compose.ui.platform.PlatformDragAndDropSource
3636
import androidx.compose.ui.platform.PlatformTextInputMethodRequest
3737
import androidx.compose.ui.platform.PlatformWindowInsets
3838
import androidx.compose.ui.platform.WindowInfo
39+
import androidx.compose.ui.platform.registerSkikoComposeImplementation
3940
import androidx.compose.ui.scene.CanvasLayersComposeScene
4041
import androidx.compose.ui.scene.ComposeScene
4142
import androidx.compose.ui.semantics.SemanticsNode
@@ -113,6 +114,7 @@ fun runSkikoComposeUiTest(
113114
testTimeout: Duration = Duration.INFINITE,
114115
block: suspend SkikoComposeUiTest.() -> Unit
115116
): TestResult {
117+
registerSkikoComposeImplementation()
116118
return SkikoComposeUiTest(
117119
width = size.width.roundToInt(),
118120
height = size.height.roundToInt(),

compose/ui/ui/build.gradle

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,7 @@ androidXMultiplatform {
206206
dependsOn(commonMain)
207207
dependencies {
208208
api(project(":compose:ui:ui-graphics"))
209+
implementation(project(":compose:ui:ui-skiko"))
209210
api(project(":compose:ui:ui-text"))
210211
api(libs.skiko)
211212
implementation(libs.atomicFu)
@@ -222,6 +223,7 @@ androidXMultiplatform {
222223
// TODO: Move to commonTest?
223224
implementation(project(":compose:material:material"))
224225
implementation(project(":compose:foundation:foundation"))
226+
implementation(project(":compose:ui:ui-skiko"))
225227
implementation(project(":compose:ui:ui-test"))
226228
}
227229
}

compose/ui/ui/src/desktopMain/kotlin/androidx/compose/ui/awt/ComposePanel.desktop.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ import androidx.compose.ui.awt.RenderSettings.SkiaSurface
3030
import androidx.compose.ui.awt.RenderSettings.SwingGraphics
3131
import androidx.compose.ui.focus.FocusDirection
3232
import androidx.compose.ui.isClearFocusOnMouseDownEnabled
33+
import androidx.compose.ui.platform.registerSkikoComposeImplementation
3334
import androidx.compose.ui.scene.ComposeContainer
3435
import androidx.compose.ui.semantics.SemanticsOwner
3536
import androidx.compose.ui.unit.ExperimentalUnitApi
@@ -96,6 +97,7 @@ class ComposePanel @ExperimentalComposeUiApi constructor(
9697
}
9798

9899
init {
100+
registerSkikoComposeImplementation()
99101
check(isEventDispatchThread()) {
100102
"ComposePanel should be created inside AWT Event Dispatch Thread" +
101103
" (use SwingUtilities.invokeLater).\n" +

compose/ui/ui/src/desktopMain/kotlin/androidx/compose/ui/awt/ComposeWindowPanel.desktop.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import androidx.compose.ui.ComposeFeatureFlags
2222
import androidx.compose.ui.LayerType
2323
import androidx.compose.ui.Modifier
2424
import androidx.compose.ui.input.key.KeyEvent
25+
import androidx.compose.ui.platform.registerSkikoComposeImplementation
2526
import androidx.compose.ui.scene.ComposeContainer
2627
import androidx.compose.ui.unit.Constraints
2728
import androidx.compose.ui.unit.IntSize
@@ -108,6 +109,7 @@ internal class ComposeWindowPanel(
108109
}
109110

110111
init {
112+
registerSkikoComposeImplementation()
111113
layout = null
112114
focusTraversalPolicy = object : FocusTraversalPolicy() {
113115
override fun getComponentAfter(aContainer: Container?, aComponent: Component?) = null

0 commit comments

Comments
 (0)