op: add package op for operations

Extract operation types from package ui into package op.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
This commit is contained in:
Elias Naur
2019-09-30 15:41:15 +02:00
parent eba1b3a95f
commit 8cf35a1f97
27 changed files with 225 additions and 227 deletions
+4 -4
View File
@@ -8,9 +8,9 @@ import (
"image/color"
"math"
"gioui.org/ui"
"gioui.org/f32"
"gioui.org/internal/opconst"
"gioui.org/op"
)
// ImageOp sets the material to a section of an
@@ -33,7 +33,7 @@ type PaintOp struct {
Rect f32.Rectangle
}
func (i ImageOp) Add(o *ui.Ops) {
func (i ImageOp) Add(o *op.Ops) {
data := make([]byte, opconst.TypeImageLen)
data[0] = byte(opconst.TypeImage)
bo := binary.LittleEndian
@@ -44,7 +44,7 @@ func (i ImageOp) Add(o *ui.Ops) {
o.Write(data, i.Src)
}
func (c ColorOp) Add(o *ui.Ops) {
func (c ColorOp) Add(o *op.Ops) {
data := make([]byte, opconst.TypeColorLen)
data[0] = byte(opconst.TypeColor)
data[1] = c.Color.R
@@ -54,7 +54,7 @@ func (c ColorOp) Add(o *ui.Ops) {
o.Write(data)
}
func (d PaintOp) Add(o *ui.Ops) {
func (d PaintOp) Add(o *op.Ops) {
data := make([]byte, opconst.TypePaintLen)
data[0] = byte(opconst.TypePaint)
bo := binary.LittleEndian
+4 -4
View File
@@ -7,10 +7,10 @@ import (
"math"
"unsafe"
"gioui.org/ui"
"gioui.org/f32"
"gioui.org/internal/opconst"
"gioui.org/internal/path"
"gioui.org/op"
)
// PathBuilder builds and adds a general ClipOp clip path
@@ -19,7 +19,7 @@ import (
// dynamic paths; path data is stored directly in the Ops
// list supplied to Init.
type PathBuilder struct {
ops *ui.Ops
ops *op.Ops
firstVert int
nverts int
maxy float32
@@ -33,7 +33,7 @@ type ClipOp struct {
bounds f32.Rectangle
}
func (p ClipOp) Add(o *ui.Ops) {
func (p ClipOp) Add(o *op.Ops) {
data := make([]byte, opconst.TypeClipLen)
data[0] = byte(opconst.TypeClip)
bo := binary.LittleEndian
@@ -46,7 +46,7 @@ func (p ClipOp) Add(o *ui.Ops) {
// Init the builder and specify the operations list for
// storing the path data and final ClipOp.
func (p *PathBuilder) Init(ops *ui.Ops) {
func (p *PathBuilder) Init(ops *op.Ops) {
p.ops = ops
}