scoop:scoop.surface:0.1.0
src/shared/frame/context.scoop
Selected production source · src/shared/frame/context.scoop
1
package scoop.surface3
import scoop.graphics.*4
import scoop.platform.time.MonotonicInstant5
import scoop.window.WindowInsets7
/** One owner-thread frame; its Canvas is valid only while the painter runs. */8
public class FrameContext internal constructor(9
public val window: SurfaceWindow,10
public val canvas: Canvas,11
public val size: Size,12
public val time: MonotonicInstant,13
internal val input: InputFrame,14
internal val scaleFactor: Double,15
public val safeAreaInsets: WindowInsets = WindowInsets()16
) {17
/** Keeps this frame's input collector while borrowing an isolated child canvas. */18
public fun <T> withState(block: (FrameContext) -> T): T = canvas19
.withState { child -> block(FrameContext(window, child, size, time, input, scaleFactor, safeAreaInsets)) }21
public fun place(area: InputArea, shape: Rect) {22
input.place(canvas, area, shape)23
}24
public fun place(area: InputArea, shape: Path) {25
input.place(canvas, area, shape)26
}27
}