Skip to content

Commit

Permalink
add comment
Browse files Browse the repository at this point in the history
  • Loading branch information
gabrielittner committed Jan 14, 2024
1 parent d98022f commit 747d2ee
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion paparazzi/src/main/java/app/cash/paparazzi/Paparazzi.kt
Original file line number Diff line number Diff line change
Expand Up @@ -351,14 +351,16 @@ class Paparazzi @JvmOverloads constructor(
timeNanos: Long,
block: () -> Unit
) {
val frameNanos = timeNanos + TIME_OFFSET_NANOS
val frameNanos = TIME_OFFSET_NANOS + timeNanos

// System_Delegate.nanoTime() is nanoTime - previousNanoTime + sChoreographerTime.
// Because of that setNanosTime needs to be called with 0 first so that the previous time will be 0 for the actual
// call. sChoreographerTime does not matter because doFrame which modifies it is not called by Paparazzi.
System_Delegate.setNanosTime(0L)
// Execute the block at the requested time.
System_Delegate.setNanosTime(frameNanos)

// should happen before doCallbacks so that compose re-composition happens
executeHandlerCallbacks()
// 1 is the only callbackType allowed by doCallbacks
Choreographer_Delegate.doCallbacks(Choreographer.getInstance(), 1, frameNanos)
Expand Down

0 comments on commit 747d2ee

Please sign in to comment.