mirror of
https://git.sr.ht/~eliasnaur/gio
synced 2026-07-01 07:35:40 +00:00
94d242d18c
PaintOp.Rect is the wrong abstraction; it implies a clip operation better handled by package clip, and not all paints need it (colors). Furthermore, it's awkward to specify a PaintOp that fills up the current clip area, regardless of its size. Redefine PathOp to mean "fill current clip area". API change. Replace uses of PaintOp.Rect with a TransformOp applied before the PaintOp. Leave a TODO for the PathOp infinity area. Fixes gio#167 Signed-off-by: Elias Naur <mail@eliasnaur.com>
88 lines
1.6 KiB
Go
88 lines
1.6 KiB
Go
// SPDX-License-Identifier: Unlicense OR MIT
|
|
|
|
package opconst
|
|
|
|
type OpType byte
|
|
|
|
// Start at a high number for easier debugging.
|
|
const firstOpIndex = 200
|
|
|
|
const (
|
|
TypeMacro OpType = iota + firstOpIndex
|
|
TypeCall
|
|
TypeTransform
|
|
TypeLayer
|
|
TypeInvalidate
|
|
TypeImage
|
|
TypePaint
|
|
TypeColor
|
|
TypeLinearGradient
|
|
TypeArea
|
|
TypePointerInput
|
|
TypePass
|
|
TypeKeyInput
|
|
TypeHideInput
|
|
TypePush
|
|
TypePop
|
|
TypeAux
|
|
TypeClip
|
|
TypeProfile
|
|
)
|
|
|
|
const (
|
|
TypeMacroLen = 1 + 4 + 4
|
|
TypeCallLen = 1 + 4 + 4
|
|
TypeTransformLen = 1 + 4*6
|
|
TypeLayerLen = 1
|
|
TypeRedrawLen = 1 + 8
|
|
TypeImageLen = 1
|
|
TypePaintLen = 1
|
|
TypeColorLen = 1 + 4
|
|
TypeLinearGradientLen = 1 + 8*2 + 4*2
|
|
TypeAreaLen = 1 + 1 + 4*4
|
|
TypePointerInputLen = 1 + 1 + 1
|
|
TypePassLen = 1 + 1
|
|
TypeKeyInputLen = 1 + 1
|
|
TypeHideInputLen = 1
|
|
TypePushLen = 1
|
|
TypePopLen = 1
|
|
TypeAuxLen = 1
|
|
TypeClipLen = 1 + 4*4
|
|
TypeProfileLen = 1
|
|
)
|
|
|
|
func (t OpType) Size() int {
|
|
return [...]int{
|
|
TypeMacroLen,
|
|
TypeCallLen,
|
|
TypeTransformLen,
|
|
TypeLayerLen,
|
|
TypeRedrawLen,
|
|
TypeImageLen,
|
|
TypePaintLen,
|
|
TypeColorLen,
|
|
TypeLinearGradientLen,
|
|
TypeAreaLen,
|
|
TypePointerInputLen,
|
|
TypePassLen,
|
|
TypeKeyInputLen,
|
|
TypeHideInputLen,
|
|
TypePushLen,
|
|
TypePopLen,
|
|
TypeAuxLen,
|
|
TypeClipLen,
|
|
TypeProfileLen,
|
|
}[t-firstOpIndex]
|
|
}
|
|
|
|
func (t OpType) NumRefs() int {
|
|
switch t {
|
|
case TypeKeyInput, TypePointerInput, TypeProfile, TypeCall:
|
|
return 1
|
|
case TypeImage:
|
|
return 2
|
|
default:
|
|
return 0
|
|
}
|
|
}
|