gioui.org/ui@v0.0.0-20190926171558-ce74bc0cbaea/internal/opconst/ops.go (about) 1 // SPDX-License-Identifier: Unlicense OR MIT 2 3 package opconst 4 5 type OpType byte 6 7 // Start at a high number for easier debugging. 8 const firstOpIndex = 200 9 10 const ( 11 TypeMacroDef OpType = iota + firstOpIndex 12 TypeMacro 13 TypeTransform 14 TypeLayer 15 TypeInvalidate 16 TypeImage 17 TypePaint 18 TypeColor 19 TypeArea 20 TypePointerInput 21 TypePass 22 TypeKeyInput 23 TypeHideInput 24 TypePush 25 TypePop 26 TypeAux 27 TypeClip 28 TypeProfile 29 ) 30 31 const ( 32 TypeMacroDefLen = 1 + 4 + 4 33 TypeMacroLen = 1 + 4 + 4 + 4 34 TypeTransformLen = 1 + 4*2 35 TypeLayerLen = 1 36 TypeRedrawLen = 1 + 8 37 TypeImageLen = 1 + 4*4 38 TypePaintLen = 1 + 4*4 39 TypeColorLen = 1 + 4 40 TypeAreaLen = 1 + 1 + 4*4 41 TypePointerInputLen = 1 + 1 42 TypePassLen = 1 + 1 43 TypeKeyInputLen = 1 + 1 44 TypeHideInputLen = 1 45 TypePushLen = 1 46 TypePopLen = 1 47 TypeAuxLen = 1 + 4 48 TypeClipLen = 1 + 4*4 49 TypeProfileLen = 1 50 ) 51 52 func (t OpType) Size() int { 53 return [...]int{ 54 TypeMacroDefLen, 55 TypeMacroLen, 56 TypeTransformLen, 57 TypeLayerLen, 58 TypeRedrawLen, 59 TypeImageLen, 60 TypePaintLen, 61 TypeColorLen, 62 TypeAreaLen, 63 TypePointerInputLen, 64 TypePassLen, 65 TypeKeyInputLen, 66 TypeHideInputLen, 67 TypePushLen, 68 TypePopLen, 69 TypeAuxLen, 70 TypeClipLen, 71 TypeProfileLen, 72 }[t-firstOpIndex] 73 } 74 75 func (t OpType) NumRefs() int { 76 switch t { 77 case TypeMacro, TypeImage, TypeKeyInput, TypePointerInput, TypeProfile: 78 return 1 79 default: 80 return 0 81 } 82 }