ui: build paths as ops

Instead of allocating and constructing a clip path, store path data
directly in op lists. Use separate op lists for cached text layout
paths.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
This commit is contained in:
Elias Naur
2019-06-02 16:43:28 +02:00
parent 9f58ed0fea
commit 1e38eec0ab
15 changed files with 248 additions and 160 deletions
+3 -8
View File
@@ -11,7 +11,6 @@ import (
"gioui.org/ui"
"gioui.org/ui/f32"
"gioui.org/ui/internal/ops"
"gioui.org/ui/internal/path"
)
type OpImage struct {
@@ -114,14 +113,10 @@ func (d *OpDraw) Decode(data []byte, refs []interface{}) {
}
}
// RectPath constructs a path corresponding to
// RectClip append a clip op corresponding to
// a pixel aligned rectangular area.
func RectPath(r image.Rectangle) *Path {
return &Path{
data: &path.Path{
Bounds: toRectF(r),
},
}
func RectClip(ops *ui.Ops, r image.Rectangle) {
opClip{bounds: toRectF(r)}.Add(ops)
}
func itof(i int) float32 {