Skip to content

Commit 2fa745d

Browse files
authored
Chore/update native (#125)
* chore: 🤖 updated dotlottie-rs to 0.1.57-372c366
1 parent b776c04 commit 2fa745d

20 files changed

Lines changed: 485 additions & 611 deletions

dotlottie/build.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ dotlottieRust {
3737
}
3838

3939
group = "com.github.LottieFiles"
40-
version = "0.13.8"
40+
version = "0.14.0"
4141

4242
android {
4343
namespace = "com.lottiefiles.dotlottie.core"

dotlottie/src/main/cpp/dotlottie_player.h

Lines changed: 171 additions & 249 deletions
Large diffs are not rendered by default.

dotlottie/src/main/cpp/jni_bridge.cpp

Lines changed: 198 additions & 210 deletions
Large diffs are not rendered by default.

dotlottie/src/main/cpp/version.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
dlplayer-version=0.1.56-cfddbc8
1+
dlplayer-version=0.1.57-372c366
22
api-type=c-api

dotlottie/src/main/java/com/lottiefiles/dotlottie/core/compose/runtime/DotLottieController.kt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -445,8 +445,7 @@ class DotLottieController {
445445
fun loadAnimation(
446446
animationId: String,
447447
) {
448-
val result =
449-
dlplayer?.loadAnimation(animationId, this._width.value, this._height.value) ?: false
448+
val result = dlplayer?.loadAnimation(animationId) ?: false
450449

451450
if (result) {
452451
_bufferNeedsUpdate.value = true

dotlottie/src/main/java/com/lottiefiles/dotlottie/core/compose/ui/DotLottieAnimation.kt

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,8 @@ fun DotLottieAnimation(
7171
) {
7272
val context = LocalContext.current
7373

74+
remember(context) { DotLottieJNI.ensureAndroidInitialized(context); Unit }
75+
7476
val rController = remember { controller ?: DotLottieController() }
7577

7678
val dlConfig = remember {
@@ -117,9 +119,9 @@ fun DotLottieAnimation(
117119
}
118120

119121
val ticked = if (rController.stateMachineIsActive) {
120-
dlPlayer.stateMachineTick()
122+
dlPlayer.stateMachineTick(frameTimeNanos)
121123
} else {
122-
dlPlayer.tick()
124+
dlPlayer.tick(frameTimeNanos)
123125
}
124126

125127
// Poll and dispatch events
@@ -190,11 +192,11 @@ fun DotLottieAnimation(
190192

191193
when (animationData) {
192194
is DotLottieContent.Json -> {
193-
dlPlayer.loadAnimationData(animationData.jsonString, width, height)
195+
dlPlayer.loadAnimationData(animationData.jsonString)
194196
}
195197

196198
is DotLottieContent.Binary -> {
197-
dlPlayer.loadDotlottieData(animationData.data, width, height)
199+
dlPlayer.loadDotlottieData(animationData.data)
198200
}
199201
}
200202

@@ -297,7 +299,6 @@ fun DotLottieAnimation(
297299
val newBitmap = createBitmap(_width.toInt(), _height.toInt())
298300
val pixelPtr = DotLottieJNI.nativeLockBitmapPixels(newBitmap)
299301
if (pixelPtr == 0L) return@withLock
300-
dlPlayer.resize(_width, _height)
301302
dlPlayer.setSwTarget(pixelPtr, _width, _height)
302303
bitmap = newBitmap
303304
drawVersion++

dotlottie/src/main/java/com/lottiefiles/dotlottie/core/compose/ui/DotLottieGLAnimationHardwareBuffer.kt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,9 @@ internal fun DotLottieGLAnimationHardwareBuffer(
6262
loopCount: UInt = 0u,
6363
) {
6464
val context = LocalContext.current
65+
remember(context) {
66+
com.lottiefiles.dotlottie.core.jni.DotLottiePlayer.ensureAndroidInitialized(context); Unit
67+
}
6568
val rController = remember { controller ?: DotLottieController() }
6669
val initialStateMachineId = remember { stateMachineId }
6770

dotlottie/src/main/java/com/lottiefiles/dotlottie/core/compose/ui/DotLottieGLSurfaceAnimation.kt

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@ internal fun DotLottieGLSurfaceAnimation(
4545
val lifecycleOwner = LocalLifecycleOwner.current
4646

4747
val rController = remember { controller ?: DotLottieController() }
48-
val initialStateMachineId = remember { stateMachineId }
4948

5049
// Hold a reference to the widget so we can interact with it
5150
val glWidgetRef = remember { arrayOfNulls<GLWidget>(1) }
@@ -61,6 +60,7 @@ internal fun DotLottieGLSurfaceAnimation(
6160
.useFrameInterpolation(useFrameInterpolation)
6261
.marker(marker ?: "")
6362
.loopCount(loopCount)
63+
.stateMachineId(stateMachineId ?: "")
6464
.build()
6565
}
6666

@@ -119,11 +119,6 @@ internal fun DotLottieGLSurfaceAnimation(
119119
widget.setOnPlayerCreated { player, config ->
120120
rController.setPlayerInstance(player, config)
121121
rController.init()
122-
123-
if (!initialStateMachineId.isNullOrEmpty()) {
124-
rController.stateMachineLoad(initialStateMachineId)
125-
rController.stateMachineStart()
126-
}
127122
}
128123

129124
// Load content

dotlottie/src/main/java/com/lottiefiles/dotlottie/core/drawable/DotLottieDrawable.kt

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -111,9 +111,9 @@ class DotLottieDrawable(
111111

112112
// stateMachineTick() calls player tick() internally (player is borrowed by state machine)
113113
val ticked = if (stateMachineIsActive) {
114-
player.stateMachineTick()
114+
player.stateMachineTick(frameTimeNanos)
115115
} else {
116-
player.tick()
116+
player.tick(frameTimeNanos)
117117
}
118118

119119
// Poll and dispatch events on main thread
@@ -289,15 +289,11 @@ class DotLottieDrawable(
289289
// 2. Load animation
290290
when (animationData) {
291291
is DotLottieContent.Json -> {
292-
player.loadAnimationData(
293-
animationData.jsonString,
294-
width.toUInt(),
295-
height.toUInt()
296-
)
292+
player.loadAnimationData(animationData.jsonString)
297293
}
298294

299295
is DotLottieContent.Binary -> {
300-
player.loadDotlottieData(animationData.data, width.toUInt(), height.toUInt())
296+
player.loadDotlottieData(animationData.data)
301297
}
302298
}
303299

@@ -341,7 +337,6 @@ class DotLottieDrawable(
341337
val pixelPtr = DotLottieJNI.nativeLockBitmapPixels(newBitmap)
342338
if (pixelPtr == 0L) return@withLock
343339
player.setSwTarget(pixelPtr, width.toUInt(), height.toUInt())
344-
player.resize(width.toUInt(), height.toUInt())
345340
bitmapBuffer = newBitmap
346341

347342
// Unlock and recycle old bitmap
@@ -405,7 +400,7 @@ class DotLottieDrawable(
405400
fun loadAnimation(
406401
animationId: String,
407402
) {
408-
val result = dlPlayer?.loadAnimation(animationId, width.toUInt(), height.toUInt())
403+
val result = dlPlayer?.loadAnimation(animationId)
409404
if (result == true) {
410405
scheduleFrame(forceUpdate = true)
411406
}

dotlottie/src/main/java/com/lottiefiles/dotlottie/core/util/GlHardwareRenderer.kt

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -164,18 +164,10 @@ internal class GlHardwareRenderer : SharedGlThread.RenderClient {
164164

165165
val loaded = when (content) {
166166
is DotLottieContent.Json -> {
167-
player.loadAnimationData(
168-
content.jsonString,
169-
bufferWidth.toUInt(),
170-
bufferHeight.toUInt()
171-
)
167+
player.loadAnimationData(content.jsonString)
172168
}
173169
is DotLottieContent.Binary -> {
174-
player.loadDotlottieData(
175-
content.data,
176-
bufferWidth.toUInt(),
177-
bufferHeight.toUInt()
178-
)
170+
player.loadDotlottieData(content.data)
179171
}
180172
}
181173
GLES20.glBindFramebuffer(GLES20.GL_FRAMEBUFFER, 0)
@@ -213,7 +205,6 @@ internal class GlHardwareRenderer : SharedGlThread.RenderClient {
213205
createRenderFbo()
214206

215207
val player = dlPlayer ?: return@post
216-
player.resize(width.toUInt(), height.toUInt())
217208
if (buffersValid && renderFboId != 0) {
218209
GLES20.glBindFramebuffer(GLES20.GL_FRAMEBUFFER, renderFboId)
219210
GLES20.glViewport(0, 0, width, height)
@@ -341,7 +332,7 @@ internal class GlHardwareRenderer : SharedGlThread.RenderClient {
341332
return player.isPlaying() || player.stateMachineIsActive || !player.isLoaded()
342333
}
343334

344-
override fun onRenderFrame() {
335+
override fun onRenderFrame(frameTimeNanos: Long) {
345336
val player = dlPlayer ?: return
346337
if (bufferWidth <= 0 || bufferHeight <= 0) return
347338
if (!buffersValid) return
@@ -370,9 +361,9 @@ internal class GlHardwareRenderer : SharedGlThread.RenderClient {
370361

371362
// Tick the player — ThorVG renders into renderFbo
372363
val ticked = if (player.stateMachineIsActive) {
373-
player.stateMachineTick()
364+
player.stateMachineTick(frameTimeNanos)
374365
} else {
375-
player.tick()
366+
player.tick(frameTimeNanos)
376367
}
377368

378369
// Poll and dispatch events

0 commit comments

Comments
 (0)