Initial commit
This commit is contained in:
@@ -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
|
||||
)
|
||||
@@ -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=
|
||||
@@ -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))
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user