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
+7 -6
View File
@@ -83,8 +83,9 @@ const (
thresholdVelocity = 1
)
func (c *Click) Op(a pointer.Area) pointer.OpHandler {
return pointer.OpHandler{Area: a, Key: c}
func (c *Click) Op(ops *ui.Ops, a pointer.Area) {
op := pointer.OpHandler{Area: a, Key: c}
op.Add(ops)
}
func (c *Click) Update(q pointer.Events) []ClickEvent {
@@ -115,12 +116,12 @@ func (c *Click) Update(q pointer.Events) []ClickEvent {
return events
}
func (s *Scroll) Op(a pointer.Area) ui.Op {
func (s *Scroll) Op(ops *ui.Ops, a pointer.Area) {
oph := pointer.OpHandler{Area: a, Key: s, Grab: s.grab}
if !s.flinger.Active() {
return oph
oph.Add(ops)
if s.flinger.Active() {
ui.OpRedraw{}.Add(ops)
}
return ui.Ops{oph, ui.OpRedraw{}}
}
func (s *Scroll) Stop() {