aboutsummaryrefslogtreecommitdiff
path: root/vendor/gioui.org/internal/opconst/ops.go
blob: 62365b8fabe480e92d90d52f42a3c8b320095ee4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
// 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
	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 + 4*4
	TypePaintLen        = 1 + 4*4
	TypeColorLen        = 1 + 4
	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,
		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
	}
}