mirror of
https://git.sr.ht/~eliasnaur/gio
synced 2026-07-04 17:05:38 +00:00
gpu,internal/ops: move gpu.clipOp to ops.ClipOp
We're about to use clip.Ops for pointer areas; this change makes the decoding accessible from the router package. Signed-off-by: Elias Naur <mail@eliasnaur.com>
This commit is contained in:
@@ -4,6 +4,7 @@ package ops
|
||||
|
||||
import (
|
||||
"encoding/binary"
|
||||
"image"
|
||||
"math"
|
||||
|
||||
"gioui.org/f32"
|
||||
@@ -86,6 +87,12 @@ type stack struct {
|
||||
|
||||
type StackKind uint8
|
||||
|
||||
// ClipOp is the shadow of clip.Op.
|
||||
type ClipOp struct {
|
||||
Bounds image.Rectangle
|
||||
Outline bool
|
||||
}
|
||||
|
||||
const (
|
||||
ClipStack StackKind = iota
|
||||
AreaStack
|
||||
@@ -126,6 +133,27 @@ const (
|
||||
TypeStrokeLen = 1 + 4
|
||||
)
|
||||
|
||||
func (op *ClipOp) Decode(data []byte) {
|
||||
if OpType(data[0]) != TypeClip {
|
||||
panic("invalid op")
|
||||
}
|
||||
bo := binary.LittleEndian
|
||||
r := image.Rectangle{
|
||||
Min: image.Point{
|
||||
X: int(int32(bo.Uint32(data[1:]))),
|
||||
Y: int(int32(bo.Uint32(data[5:]))),
|
||||
},
|
||||
Max: image.Point{
|
||||
X: int(int32(bo.Uint32(data[9:]))),
|
||||
Y: int(int32(bo.Uint32(data[13:]))),
|
||||
},
|
||||
}
|
||||
*op = ClipOp{
|
||||
Bounds: r,
|
||||
Outline: data[17] == 1,
|
||||
}
|
||||
}
|
||||
|
||||
func Reset(o *Ops) {
|
||||
o.macroStack = stack{}
|
||||
for i := range o.stacks {
|
||||
|
||||
Reference in New Issue
Block a user