Scoop API

scoop:scoop.ui:0.1.0

src/paint/options.scoop

Selected production source · src/paint/options.scoop

1package scoop.ui
3import scoop.graphics.Rect
4import scoop.graphics.Size
6/** Stable identity for one finite layer in an element's scene. */
7public class PaintKey public constructor()
9/** Pixel retention is independent of child instance retention. */
10public enum PaintCachePolicy {
11 None, Tiles(val tileSize: Int = 256, val overscan: Int = 1)
14internal fun checkPaintCachePolicy(value: PaintCachePolicy) {
15 when (value) {
16 case None -> {}
17 case Tiles(val size, val overscan) -> {
18 requireUi(size > 0, "paint tile size must be positive")
19 requireUi(overscan >= 0, "paint tile overscan must be nonnegative")
20 }
21 }
24/** Known source-over text can replay without the isolation required by arbitrary drawing. */
25internal enum PaintComposition {
26 Isolated, SourceOver
29internal struct PaintLayerInput(
30 val size: Size,
31 val bounds: Rect,
32 val revision: Long,
33 val samplingOutset: Double,
34 val composition: PaintComposition = PaintComposition.Isolated
35) {
36 fun check() {
37 checkLayoutSize(size)
38 for (
39 value in [
40 bounds.x,
41 bounds.y,
42 bounds.width,
43 bounds.height,
44 bounds.x + bounds.width,
45 bounds.y + bounds.height
46 ]
47 )
48 requireUi(value.isFinite() && value.toFloat().isFinite(), "invalid paint bounds")
49 requireUi(bounds.width >= 0.0 && bounds.height >= 0.0, "negative paint bounds")
50 requireUi(
51 samplingOutset.isFinite() && samplingOutset >= 0.0,
52 "invalid paint sampling outset"
53 )
54 }