On my 2013 Nexus 7, a simple
start := time.Now()
draw.Draw(etc)
log.Printf("draw.Draw took %v", time.Since(start))
around the draw.Draw call dropped from 12ms to 30µs.
Change-Id: I12aea4a4ade07eedb8ee86f7c8d4a4ed49f39f36
Reviewed-on: https://go-review.googlesource.com/11299
Reviewed-by: David Crawshaw <crawshaw@golang.org>
x11/gl is not thread-safe, so all x11/gl related API should be called
from one thread. There's already a dedicated thread for GL calls, so
move all x11 API calls to GL thread using gl.Do(...)
Fixesgolang/go#11066
Change-Id: If84a8d56e978ce30d7fbbc310740fcc794ce61d7
Reviewed-on: https://go-review.googlesource.com/10744
Reviewed-by: Nigel Tao <nigeltao@golang.org>
Change AppDelegate, AppController to GoAppAppDelegate,
GoAppAppController - which are ugly enough so gobind users
is unlikely to use in their objective-c code.
Change-Id: I69305994a83405a1d8499df661bd5f63757a7fd6
Reviewed-on: https://go-review.googlesource.com/10852
Reviewed-by: David Crawshaw <crawshaw@golang.org>
- Fix hangs on linux/x11. x11-related code remains outdated since
068a51c19, which seperates GL calls to dedicated thread. Update x11
code to work with GL thread.
- Fix bug on coordinate system. x11 has same coordinate system with
android, (0,0) on top-left.
Change-Id: I0b3ab97fd4842b1c9f730e1c90a5840f540fcb7a
Reviewed-on: https://go-review.googlesource.com/10623
Reviewed-by: David Crawshaw <crawshaw@golang.org>
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>
This trusts bionic's reading of the system clock.
Future work should address the fact we cannot read the Android
zoneinfo file.
Fixesgolang/go#10857.
Change-Id: I5a684fecc920dce5ab8f624658e91d9e2d71738d
Reviewed-on: https://go-review.googlesource.com/10299
Reviewed-by: Elias Naur <elias.naur@gmail.com>
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
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.
Fixesgolang/go#10686Fixesgolang/go#10461Fixesgolang/go#10442Fixesgolang/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>
The global constructor added for -buildmode=c-shared takes care
of a lot of the messier steps that were being done here.
Change-Id: I00525765855b2ad0fcecb0639d6a7ee3feea9ed9
Reviewed-on: https://go-review.googlesource.com/9648
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
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>
Change-Id: I50035006af8358ef2d794ae2c75dddc835f99f3d
Reviewed-on: https://go-review.googlesource.com/9141
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
There is some cleanup to be done in this package now, but I'm
deferring it until later in the cycle.
We should probably also change the semantics slightly: main should
be called for all-Go apps (that is, apps that use NativeActivity),
but it would be more consistent with buildmode=c-shared and c-archive
if we did not call main for Go shared libraries being included in
Java android apps.
Change-Id: I13ca797a478edb22b0c602c1ee6e616fe4fea1e6
Reviewed-on: https://go-review.googlesource.com/9016
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
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>
Change-Id: Id3c5c58050fa11ec57e8efd2661047dc5e0dfc2d
Reviewed-on: https://go-review.googlesource.com/7665
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
When the preferred visual returned by EGL is different from the parent
window's visual, a private colormap is needed in the call to
XCreateWindow. See X server source code
http://cgit.freedesktop.org/xorg/xserver/tree/dix/window.c#n708
This patch systematically creates a TrueColor XColormap, regardless of
the visual returned by eglGetConfigAttrib().
Fixes#9997
Change-Id: I3caf7c6d46991b1f0268e72197fca5186612b5da
Reviewed-on: https://go-review.googlesource.com/6260
Reviewed-by: David Crawshaw <crawshaw@golang.org>
Reviewed-by: Nigel Tao <nigeltao@golang.org>
Tested manually by modifying example/libhello to read an asset file,
and checking crawshaw's balloon app continues to work.
Fixesgolang/go#9422.
Change-Id: I17b25d9456a4023c68be1de82ee071ea01299e68
Reviewed-on: https://go-review.googlesource.com/5680
Reviewed-by: David Crawshaw <crawshaw@golang.org>
Change-Id: Ia39f134c5ffe39decc04c2bd59b69981c1c46e41
Reviewed-on: https://go-review.googlesource.com/5579
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
Change-Id: Ida06858336eb482d1d804279c468e09fad12b97f
Reviewed-on: https://go-review.googlesource.com/5578
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
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>
Still needs some geometry adjustments, coming in a followup CL.
Change-Id: If1298a0deef117ee635db1af78fb743a60a8c8d5
Reviewed-on: https://go-review.googlesource.com/5480
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
Not thought through. For gobind-based apps, JNI_OnLoad is called and there is never any NativeActivity.
This reverts commit b781b80ee8.
Change-Id: Ib076f30d144cbacb7926d54981ac86bbb8a5a4ff
Reviewed-on: https://go-review.googlesource.com/4440
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
I am working on a virtual keyboard package that needs access to the
*ANativeActivity. As the *ANativeActivity contains *JavaVM, this CL
deprecates JavaInit. I'll remove it in a subsequent CL that updates
gobind to use RegisterAndroidInit.
Change-Id: Ib1d60bbaac5de4583b368c93ab90b764c6081291
Reviewed-on: https://go-review.googlesource.com/4400
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
They don't make sense for other platforms yet.
See golang/go#9603
Change-Id: I2ed269a00b1e1961aadf0a47fc95bbe3cd230113
Reviewed-on: https://go-review.googlesource.com/2902
Reviewed-by: David Crawshaw <crawshaw@golang.org>
This initially supports reading two common system fonts. At some point
there should be a more general Open function, but first I need to work
out how to to turn font names into android file names.
Fixesgolang/go#9419.
Change-Id: I8321df873315a5222c39dccf961f742f2e2a7a4c
Reviewed-on: https://go-review.googlesource.com/2059
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
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>
Still working on how/when to call Stop.
Change-Id: Ice56c4c71ba351765657bb86dc01649c8238859e
Reviewed-on: https://go-review.googlesource.com/1885
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
Change-Id: If8ea6aaf2fb2c62eaf4119526a8bb46b8a84b982
Reviewed-on: https://go-review.googlesource.com/1881
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
Some Android systems cannot read from /proc/self/auxv. Work around
this by creating a minimal fake auxv for the Go runtime.
Fixes#9229
Change-Id: Id2d743f43d91be23006aac708a5b5b5cd60a6dca
Reviewed-on: https://go-review.googlesource.com/1284
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
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
Drawing now supports defining both the source and destination
bounds, which is equivalent to clipping and scaling an image.
LGTM=nigeltao
R=nigeltao, crawshaw
CC=adg, golang-codereviews
https://golang.org/cl/144480043
This lets you run really simple apps in a window on an OS X
machine. It's not an official target, but slightly more
productive than waiting for an apk install when working on
the sprite package.
LGTM=adg
R=golang-codereviews, adg
CC=golang-codereviews
https://golang.org/cl/147910043
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
This is the minimum amount of machinery necessary to get
libgojni.so loading and callable from an Android App.
To keep impact on the Go runtime small, we construct an
auxv array here from /proc/self/auxv.
LGTM=minux, adonovan
R=adonovan, golang-codereviews, minux, bradfitz
CC=golang-codereviews
https://golang.org/cl/107500043