Scoop API

scoop:scoop.surface:0.1.0

src/shared/frame/renderer.scoop

Selected production source · src/shared/frame/renderer.scoop

1package scoop.surface
3import scoop.graphics.Canvas
4import scoop.window.*
6/** Only the platform adapter owns native frame opportunities, targets and presentation. */
7internal interface RendererHost: Closeable {
8 fun create(window: Window, proxy: ApplicationProxy): WindowRenderer
9}
11internal interface WindowRenderer: Closeable {
12 fun configure(metrics: WindowMetrics)
13 fun setFrameDemand(required: Boolean)
14 fun acquire(): FrameAcquisition
17internal enum FrameAcquisition {
18 Ready(RenderFrame), Deferred
21internal interface RenderFrame: Closeable {
22 fun draw(block: (Canvas) -> Unit)
23 /** False means the target became invalid; geometry must not be published. */
24 fun submit(): Boolean
27internal fun cleanupFailure(previous: Throwable?, action: () -> Unit): Throwable? {
28 try {
29 action();
30 return previous
31 }
32 catch (error: Throwable) {
33 return Some(
34 when (previous) {
35 case Some(val primary) -> ResourceUseException(primary, error)
36 case None -> error
37 }
38 )
39 }
42internal fun throwFailure(failure: Throwable?) {
43 when (failure) {
44 case Some(val error) -> throw error;
45 case None -> {}
46 }