-
ApoloApps authored
Added some functions to Skia canvas to be able to avoid creating intermediate objects (SkRect, SkRRect, etc) on some hot paths. See [this conversation](https://github.com/JetBrains/compose-multiplatform-core/pull/2543#discussion_r2483008621) for the context of the PR. This is the first step to allow for Compose Ui SkiaBackedCanvas to avoid unnecessary intermediate allocations: 1. https://github.com/JetBrains/compose-multiplatform-core/blob/47af63a3986292608982f421bb345eb0a2032a98/compose/ui/ui-graphics/src/skikoMain/kotlin/androidx/compose/ui/graphics/SkiaBackedCanvas.skiko.kt#L189 2. https://github.com/JetBrains/compose-multiplatform-core/blob/47af63a3986292608982f421bb345eb0a2032a98/compose/ui/ui-graphics/src/skikoMain/kotlin/androidx/compose/ui/graphics/SkiaBackedCanvas.skiko.kt#L141 3. https://github.com/JetBrains/compose-multiplatform-core/blob/47af63a3986292608982f421bb345eb0a2032a98/compose/ui/ui-graphics/src/skikoMain/kotlin/androidx/compose/ui/graphics/SkiaBackedCanvas.skiko.kt#L128 4. https://github.com/JetBrains/compose-multiplatform-core/blob/47af63a3986292608982f421bb345eb0a2032a98/compose/ui/ui-graphics/src/skikoMain/kotlin/androidx/compose/ui/graphics/SkiaBackedCanvas.skiko.kt#L189 5. https://github.com/JetBrains/compose-multiplatform-core/blob/47af63a3986292608982f421bb345eb0a2032a98/compose/ui/ui-graphics/src/skikoMain/kotlin/androidx/compose/ui/graphics/SkiaBackedCanvas.skiko.kt#L211 among others. **Next steps** -> open pr in Compose Ui to use these more optimized functions -> More optimizations on the Skiko side, Matrixes is a good example, CMP and Skiko are processing Matrixes 2 times, toSkiaMatrix, which basically is the same as a wrapper around FloatArray and then in the toInterop method which copies the array (unavoidable). A good optimization would be to just pass the Compose Matrix underlying `values` property which is a FloatArray that toInterop accepts and so a lot of intermediate objects and transformations could be avoided altogether