mirror of
https://git.sr.ht/~eliasnaur/gio
synced 2026-07-05 17:35:36 +00:00
all: remove exported Decode methods on operations
Add decode functions to the packages that need them instead. For TransformOp that is used in multiple packages, add the decode function to the internal ops package. Signed-off-by: Elias Naur <mail@eliasnaur.com>
This commit is contained in:
@@ -37,27 +37,6 @@ func (i ImageOp) Add(o *ui.Ops) {
|
||||
o.Write(data, i.Src)
|
||||
}
|
||||
|
||||
func (i *ImageOp) Decode(data []byte, refs []interface{}) {
|
||||
bo := binary.LittleEndian
|
||||
if opconst.OpType(data[0]) != opconst.TypeImage {
|
||||
panic("invalid op")
|
||||
}
|
||||
sr := 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:]))),
|
||||
},
|
||||
}
|
||||
*i = ImageOp{
|
||||
Src: refs[0].(image.Image),
|
||||
Rect: sr,
|
||||
}
|
||||
}
|
||||
|
||||
func (c ColorOp) Add(o *ui.Ops) {
|
||||
data := make([]byte, opconst.TypeColorLen)
|
||||
data[0] = byte(opconst.TypeColor)
|
||||
@@ -68,20 +47,6 @@ func (c ColorOp) Add(o *ui.Ops) {
|
||||
o.Write(data)
|
||||
}
|
||||
|
||||
func (c *ColorOp) Decode(data []byte, refs []interface{}) {
|
||||
if opconst.OpType(data[0]) != opconst.TypeColor {
|
||||
panic("invalid op")
|
||||
}
|
||||
*c = ColorOp{
|
||||
Color: color.RGBA{
|
||||
R: data[1],
|
||||
G: data[2],
|
||||
B: data[3],
|
||||
A: data[4],
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
func (d DrawOp) Add(o *ui.Ops) {
|
||||
data := make([]byte, opconst.TypeDrawLen)
|
||||
data[0] = byte(opconst.TypeDraw)
|
||||
@@ -93,26 +58,6 @@ func (d DrawOp) Add(o *ui.Ops) {
|
||||
o.Write(data)
|
||||
}
|
||||
|
||||
func (d *DrawOp) Decode(data []byte, refs []interface{}) {
|
||||
bo := binary.LittleEndian
|
||||
if opconst.OpType(data[0]) != opconst.TypeDraw {
|
||||
panic("invalid op")
|
||||
}
|
||||
r := f32.Rectangle{
|
||||
Min: f32.Point{
|
||||
X: math.Float32frombits(bo.Uint32(data[1:])),
|
||||
Y: math.Float32frombits(bo.Uint32(data[5:])),
|
||||
},
|
||||
Max: f32.Point{
|
||||
X: math.Float32frombits(bo.Uint32(data[9:])),
|
||||
Y: math.Float32frombits(bo.Uint32(data[13:])),
|
||||
},
|
||||
}
|
||||
*d = DrawOp{
|
||||
Rect: r,
|
||||
}
|
||||
}
|
||||
|
||||
// RectClip returns a ClipOp op corresponding to
|
||||
// a pixel aligned rectangular area.
|
||||
func RectClip(r image.Rectangle) ClipOp {
|
||||
|
||||
Reference in New Issue
Block a user