Initial commit

This commit is contained in:
Greg 2019-10-10 10:29:00 -04:00
commit 07ba8917e0
7 changed files with 155 additions and 0 deletions

2
.gitignore vendored Normal file
View File

@ -0,0 +1,2 @@
fast/fast
slow/slow

8
fast/go.mod Normal file
View File

@ -0,0 +1,8 @@
module git.wow.st/gmp/giotest/fast
go 1.13
require (
gioui.org/ui v0.0.0-20190918172808-816f0e901fc6
golang.org/x/image v0.0.0-20190703141733-d6a02ce849c9
)

11
fast/go.sum Normal file
View File

@ -0,0 +1,11 @@
gioui.org v0.0.0-20190918172808-816f0e901fc6 h1:cLijG4iiMdm+SX/Py5GXgVxuj7PpEKSHBA7LbR4tSzs=
gioui.org v0.0.0-20191002205528-32bda106e7ff h1:pLleCPnIUzrPrjM+kad+jVhU31lzoEfINETZkLcTMRQ=
gioui.org/ui v0.0.0-20190918172808-816f0e901fc6 h1:LvHEYxyOW7g+PhOiAm8Delc3AUv9EH219oDvaUMeKBw=
gioui.org/ui v0.0.0-20190918172808-816f0e901fc6/go.mod h1:PssKPKlqVIeyaed+0w492Xc2NgX5M3n6oZKOAj5rxoE=
gioui.org/ui v0.0.0-20190926171558-ce74bc0cbaea h1:rv21Wx1Inf27NY453rrrP6tuEG65PyWPhnP2Jx+Qb8k=
golang.org/x/image v0.0.0-20190703141733-d6a02ce849c9 h1:uc17S921SPw5F2gJo7slQ3aqvr2RwpL7eb3+DZncu3s=
golang.org/x/image v0.0.0-20190703141733-d6a02ce849c9/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0=
golang.org/x/sys v0.0.0-20190813064441-fde4db37ae7a h1:aYOabOQFp6Vj6W1F80affTUvO9UxmJRx8K0gsfABByQ=
golang.org/x/sys v0.0.0-20190813064441-fde4db37ae7a/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/text v0.3.0 h1:g61tztE5qeGQ89tm6NTjjM9VPIm088od1l6aSorWRWg=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=

60
fast/main.go Normal file
View File

@ -0,0 +1,60 @@
// SPDX-License-Identifier: Unlicense OR MIT
package main
// A simple Gio program. See https://gioui.org for more information.
import (
"fmt"
"log"
"time"
"gioui.org/ui"
"gioui.org/ui/app"
"gioui.org/ui/layout"
"gioui.org/ui/measure"
"gioui.org/ui/text"
"golang.org/x/image/font/gofont/goregular"
"golang.org/x/image/font/sfnt"
)
func main() {
go func() {
w := app.NewWindow()
if err := loop(w); err != nil {
log.Fatal(err)
}
}()
app.Main()
}
func loop(w *app.Window) error {
regular, err := sfnt.Parse(goregular.TTF)
if err != nil {
panic("failed to load font")
}
var faces measure.Faces
ops := new(ui.Ops)
q := w.Queue()
face := faces.For(regular, ui.Sp(16))
lst := layout.List{Axis: layout.Vertical}
for {
e := <-w.Events()
switch e := e.(type) {
case app.DestroyEvent:
return e.Err
case app.UpdateEvent:
stime := time.Now()
c := e.Config
ops.Reset()
faces.Reset(&c)
for lst.Init(&c, q, ops, layout.RigidConstraints(e.Size), 200); lst.More(); lst.Next() {
lst.End(text.Label{Face: face, Text: fmt.Sprintf("label %d",lst.Index())}.Layout(ops, lst.Constraints()))
}
lst.Layout()
w.Update(ops)
log.Printf("Frame time: %s\n", time.Since(stime))
}
}
}

8
slow/go.mod Normal file
View File

@ -0,0 +1,8 @@
module git.wow.st/gmp/giotest/slow
go 1.13
require (
gioui.org v0.0.0-20191010132702-163d9037e6c8
golang.org/x/image v0.0.0-20191009234506-e7c1f5e7dbb8
)

9
slow/go.sum Normal file
View File

@ -0,0 +1,9 @@
gioui.org v0.0.0-20191010132702-163d9037e6c8 h1:/Z760sQoOvY1RMAoC4hWn00quB4w4UuEOdg/csh9aCs=
gioui.org v0.0.0-20191010132702-163d9037e6c8/go.mod h1:+CEjc9B//HrBfWsQOVxjCyih7HGIj3Pww1xFHVDZyyk=
golang.org/x/image v0.0.0-20190703141733-d6a02ce849c9/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0=
golang.org/x/image v0.0.0-20191009234506-e7c1f5e7dbb8 h1:hVwzHzIUGRjiF7EcUjqNxk3NCfkPxbDKRdnNE1Rpg0U=
golang.org/x/image v0.0.0-20191009234506-e7c1f5e7dbb8/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0=
golang.org/x/sys v0.0.0-20190813064441-fde4db37ae7a h1:aYOabOQFp6Vj6W1F80affTUvO9UxmJRx8K0gsfABByQ=
golang.org/x/sys v0.0.0-20190813064441-fde4db37ae7a/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/text v0.3.0 h1:g61tztE5qeGQ89tm6NTjjM9VPIm088od1l6aSorWRWg=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=

57
slow/main.go Normal file
View File

@ -0,0 +1,57 @@
// SPDX-License-Identifier: Unlicense OR MIT
package main
// A simple Gio program. See https://gioui.org for more information.
import (
"fmt"
"log"
"time"
"gioui.org/app"
"gioui.org/layout"
"gioui.org/text"
"gioui.org/text/shape"
"gioui.org/unit"
"golang.org/x/image/font/gofont/goregular"
"golang.org/x/image/font/sfnt"
)
func main() {
go func() {
w := app.NewWindow()
if err := loop(w); err != nil {
log.Fatal(err)
}
}()
app.Main()
}
func loop(w *app.Window) error {
regular, err := sfnt.Parse(goregular.TTF)
if err != nil {
panic("failed to load font")
}
family := &shape.Family{Regular: regular}
gtx := &layout.Context{Queue: w.Queue()}
lst := &layout.List{Axis: layout.Vertical}
for {
e := <-w.Events()
switch e := e.(type) {
case app.DestroyEvent:
return e.Err
case app.UpdateEvent:
stime := time.Now()
gtx.Reset(&e.Config, e.Size)
for i := 0; i < 200; i++ {
lst.Layout(gtx, 200, func(i int) {
text.Label{Size: unit.Dp(16), Text: fmt.Sprintf("label %d", i)}.Layout(gtx, family)
})
}
w.Update(gtx.Ops)
log.Printf("Frame time: %s\n", time.Since(stime))
}
}
}