Commit Graph

14 Commits

Author SHA1 Message Date
David Crawshaw 068a51c195 gl: batch calls onto a dedicated context thread
All GL function calls fill out a C.struct_fnargs and drop it on the
work queue. The Start function drains the work queue and hands
over a batch of calls to C.process which runs them. This allows
multiple GL calls to be executed in a single cgo call.

A GL call is marked as blocking if it returns a value, or if it
takes a Go pointer. In this case the call will not return until
C.process sends a value on the retvalue channel.

Change-Id: I4c76b2a8ad55f57b0c98d200d0fb708d4634e042
Reviewed-on: https://go-review.googlesource.com/10452
Reviewed-by: Nigel Tao <nigeltao@golang.org>
2015-06-01 15:35:03 +00:00
David Crawshaw 5cddc1460e app: introduce Config and start registration
Config provides a way to concurrently access Width and Height.

Register provides a way for packages to run code on app state change
without plumbing changes all the way to the process main function.
This is motivated by gl/glutil.Image which needs to rebuild its
textures on start/stop and can be deeply nested.
(See golang.org/cl/9707 for the followup.)

Tested manually on android and darwin/amd64. Doing this kind makes it
clear any CL modifying this code needs a lot of manual testing right
now, so some kind of trybot support is something I'm going to
prioritise.

Fixes golang/go#10686
Fixes golang/go#10461
Fixes golang/go#10442
Fixes golang/go#10226
Updates golang/go#10327

Change-Id: I2882ebf3995b6ed857cda823e94fbb17c54b43a8
Reviewed-on: https://go-review.googlesource.com/9708
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
2015-05-06 17:32:53 +00:00
Gordon Klaus 253eb63b86 mobile/app: identify touches by ID to enable multitouch
An example of how to handle multiple concurrent touches using this design:

var touched = map[event.TouchSequenceID]*Widget{}
func touch(t event.Touch) {
    if t.Type == event.TouchStart {
        if w := widgetAt(t.Loc); w != nil {
            touched[t.ID] = w
        }
    }
    if w, ok := touched[t.ID]; ok {
         // move/scroll widget, etc
    }
    if t.Type == event.TouchEnd {
        delete(touched, t.ID)
    }
}

Change-Id: I79910ef30abe9a41bc0720783022b1af081fbd43
Reviewed-on: https://go-review.googlesource.com/1895
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
Reviewed-by: Burcu Dogan <jbd@google.com>
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2015-04-29 16:53:16 +00:00
Burcu Dogan 2952048198 mobile/app: update the window width and height after rotation
Orientation invokes onNativeWindowRedrawNeeded.
Requery the window width and height when redraw needed.

Change-Id: I45816f13b42db38e71d28cb05bf7cfffda75882c
Reviewed-on: https://go-review.googlesource.com/8700
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2015-04-11 11:51:47 +00:00
David Crawshaw 39aa39772d app: remove excess call to Start callback
Change-Id: Ida06858336eb482d1d804279c468e09fad12b97f
Reviewed-on: https://go-review.googlesource.com/5578
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
2015-02-23 17:58:15 +00:00
David Crawshaw b2dee7a880 app, cmd/gomobile: expose an app.State variable
The State can be used in the Start callback (and lazily-initialized
packages) instead of JavaInit. This stores a reference to the
android.context.Context for the (future) keyboard package and for
setting TMPDIR.

Second attempt at https://golang.org/cl/4400.

Change-Id: I673997b26ab25ce5140cb31950593d8c6dbd9c51
Reviewed-on: https://go-review.googlesource.com/5555
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
2015-02-23 17:54:17 +00:00
Gordon Klaus f8e3bd5ba6 mobile: Deliver all touch events.
Android delivers events in a batch.  Previously, only the first event of the batch was passed to the Go callback, resulting in many events (typically corresponding to non-primary touches) being dropped.

Change-Id: I4b01bb6c4d1c88dec6c8fa379875043dfc0e9986
Reviewed-on: https://go-review.googlesource.com/1894
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2014-12-21 16:17:07 +00:00
David Crawshaw 1aa04cf038 app: Start and Stop callbacks
Change-Id: If8ea6aaf2fb2c62eaf4119526a8bb46b8a84b982
Reviewed-on: https://go-review.googlesource.com/1881
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
2014-12-19 19:01:54 +00:00
David Crawshaw a67e60175f x/mobile/app: remove gl.CULL_FACE
Leave this up to the apps. Right now the current face culling
direction does not match glimage.

LGTM=nigeltao
R=hyangah, nigeltao
CC=golang-codereviews
https://golang.org/cl/185870043
2014-12-05 09:59:45 -05:00
Andrew Gerrand 9470e0ba58 go.mobile: use golang.org/x/... import paths
LGTM=bradfitz, rsc
R=rsc, bradfitz
CC=golang-codereviews
https://golang.org/cl/162710043
2014-11-10 08:55:57 +11:00
Nigel Tao fab1e51609 go.mobile/geom: rename Scale to PixelsPerPt.
LGTM=crawshaw
R=crawshaw
CC=golang-codereviews
https://golang.org/cl/160160043
2014-10-22 13:50:04 +11:00
Nigel Tao c2d8ff3468 go.mobile/app: add an X11 implementation, for non-Android Linux.
LGTM=crawshaw
R=crawshaw
CC=golang-codereviews
https://golang.org/cl/155270043
2014-10-13 09:24:05 +11:00
David Crawshaw 56cb2dac4e go.mobile/app: Touch callback
LGTM=adg, nigeltao
R=nigeltao, adg, bryanturley
CC=davidday, golang-codereviews
https://golang.org/cl/140450043
2014-09-11 19:39:16 -04:00
David Crawshaw e27dbf7bf9 go.mobile/app: an exceedingly simple display loop
Missing many features (like event processing). This is
just enough to get example/basic working.

LGTM=nigeltao
R=golang-codereviews, capnm9, bryanturley, nigeltao, crawshaw
CC=golang-codereviews
https://golang.org/cl/131030043
2014-09-09 19:51:04 -04:00