scoop:scoop.ui:0.1.0
src/paint/options.scoop
Selected production source · src/paint/options.scoop
1
package scoop.ui3
import scoop.graphics.Rect4
import scoop.graphics.Size6
/** Stable identity for one finite layer in an element's scene. */7
public class PaintKey public constructor()9
/** Pixel retention is independent of child instance retention. */10
public enum PaintCachePolicy {11
None, Tiles(val tileSize: Int = 256, val overscan: Int = 1)12
}14
internal 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
}22
}24
/** Known source-over text can replay without the isolation required by arbitrary drawing. */25
internal enum PaintComposition {26
Isolated, SourceOver27
}29
internal struct PaintLayerInput(30
val size: Size,31
val bounds: Rect,32
val revision: Long,33
val samplingOutset: Double,34
val composition: PaintComposition = PaintComposition.Isolated35
) {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.height46
]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
}55
}