all: serialize ops

Pros:
- Much less per-frame garbage
- Allow future preprocessing of ops while building it
- Much fewer interface calls and pointer chasing
- Allow future serialization of ops for remote rendering

Cons:
- Slightly clumsier API

Signed-off-by: Elias Naur <mail@eliasnaur.com>
This commit is contained in:
Elias Naur
2019-04-24 13:33:01 +02:00
parent 7b6e1ce35a
commit 252e058766
21 changed files with 809 additions and 385 deletions
+3 -3
View File
@@ -16,7 +16,7 @@ type Image struct {
Rect image.Rectangle
}
func (im Image) Layout(cs layout.Constraints) (ui.Op, layout.Dimens) {
func (im Image) Layout(ops *ui.Ops, cs layout.Constraints) layout.Dimens {
d := image.Point{X: cs.Width.Max, Y: cs.Height.Max}
if d.X == ui.Inf {
d.X = cs.Width.Min
@@ -27,6 +27,6 @@ func (im Image) Layout(cs layout.Constraints) (ui.Op, layout.Dimens) {
dr := f32.Rectangle{
Max: f32.Point{X: float32(d.X), Y: float32(d.Y)},
}
op := draw.OpImage{Rect: dr, Src: im.Src, SrcRect: im.Rect}
return op, layout.Dimens{Size: d, Baseline: d.Y}
draw.OpImage{Rect: dr, Src: im.Src, SrcRect: im.Rect}.Add(ops)
return layout.Dimens{Size: d, Baseline: d.Y}
}