mirror of
https://git.sr.ht/~eliasnaur/gio
synced 2026-07-06 09:55:40 +00:00
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:
+4
-2
@@ -46,14 +46,16 @@ func loop(w *app.Window) {
|
||||
maroon := &image.Uniform{color.RGBA{127, 0, 0, 255}}
|
||||
face := faces.For(regular, ui.Sp(72))
|
||||
message := "Hello, Gio"
|
||||
ops := new(ui.Ops)
|
||||
for w.IsAlive() {
|
||||
e := <-w.Events()
|
||||
switch e := e.(type) {
|
||||
case app.Draw:
|
||||
faces.Cfg = e.Config
|
||||
cs := layout.ExactConstraints(w.Size())
|
||||
root, _ := (text.Label{Src: maroon, Face: face, Alignment: text.Center, Text: message}).Layout(cs)
|
||||
w.Draw(root)
|
||||
ops.Reset()
|
||||
(text.Label{Src: maroon, Face: face, Alignment: text.Center, Text: message}).Layout(ops, cs)
|
||||
w.Draw(ops)
|
||||
faces.Frame()
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user