Commit Graph

424 Commits

Author SHA1 Message Date
Burcu Dogan a849359c3b mobile: deprecate Dockerfile and document gomobile
Keeping the Dockerfile as a reference to setup a working dev env
without gomobile init.

Fixes #10523

Change-Id: Ie5a359baff2c3b65ac34045fb8ab5560a23c0e22
Reviewed-on: https://go-review.googlesource.com/9686
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
2015-05-04 21:07:04 +00:00
David Crawshaw 66ea9e5b49 app: simplify and document init sequence
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>
2015-05-04 12:09:13 +00:00
David Crawshaw b364bb0348 cmd/gomobile: print error messages from javac
Useful if you are running an old unsupported Java 1.6.

Change-Id: I794bacc22a09ee339730ef7b600475eba09a3a9d
Reviewed-on: https://go-review.googlesource.com/9649
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
2015-05-04 12:06:30 +00:00
Burcu Dogan 88e68e02f0 example/basic,example/sprite: give a reference to gomobile installation
Removing the duplicate installation instructions and giving a reference
to the gomobile godoc.

Change-Id: I476e4a4f4545eeb17d9ba18f471076d63c1f15d1
Reviewed-on: https://go-review.googlesource.com/9631
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
2015-05-01 20:58:37 +00:00
Hyang-Ah (Hana) Kim 812950cfd1 bind/objc: GoSeq for obj-c and go communication.
duplicate code from bind/java/seq_android.c to use for obj-c/go binding.

Change-Id: Iefd5d4171cca3a30c5d56f9b37647463e6fd0c5a
Reviewed-on: https://go-review.googlesource.com/9409
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2015-05-01 19:28:10 +00:00
Burcu Dogan d9a820a72b cmd/gomobile: expand the docs with instructions to build Go from tip
Change-Id: Ie7bd43cdf8d759e6d739824c59cac0e01d1a4b95
Reviewed-on: https://go-review.googlesource.com/9630
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
2015-05-01 19:24:26 +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
Hyang-Ah (Hana) Kim 74be7c24e4 cmd/gomobile: update the doc.
Change-Id: Ie654ad9aaaf5a1c0394731161194a1358a075e97
Reviewed-on: https://go-review.googlesource.com/8245
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2015-04-29 16:05:14 +00:00
Hyang-Ah (Hana) Kim 30559f84c5 bind/java: add mising copyright statements.
Change-Id: Ifb120cba013d48fa83af41a43ccbbe7de87b26c8
Reviewed-on: https://go-review.googlesource.com/9408
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2015-04-28 18:08:06 +00:00
Burcu Dogan 1cb3b97c74 example/sprite: switch to gomobile build
Fixes #10523.

Change-Id: Ic0bf345624f6584757e2af5cb91a679827ee3b13
Reviewed-on: https://go-review.googlesource.com/9340
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
2015-04-25 00:22:47 +00:00
Burcu Dogan 717c2c4312 example/basic: add build instructions for gomobile
This CL also removes Android build system required files and keeping
it to the bare minimum to what gomobile requires.

Fixes #10523.

Change-Id: Iabf16e7ea040a74eaf64746e7cc4e23ef3683af2
Reviewed-on: https://go-review.googlesource.com/9204
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
2015-04-24 23:59:43 +00:00
Nigel Tao a4bb1057ff app: fix tabs vs spaces.
Change-Id: I50035006af8358ef2d794ae2c75dddc835f99f3d
Reviewed-on: https://go-review.googlesource.com/9141
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
2015-04-21 00:10:36 +00:00
Hyang-Ah (Hana) Kim 1ab6893162 cmd/gomobile: fix init_test.go to pass on windows/darwin.
Change-Id: I03a18267ddd35ce432a394732185dab0283f2da6
Reviewed-on: https://go-review.googlesource.com/9170
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2015-04-20 21:32:12 +00:00
Hyang-Ah (Hana) Kim 094aefd3b8 Dockerfile: update go version to 3f4de49.
Change-Id: Icf2fa718236810086b85a19d4f3826884c03630f
Reviewed-on: https://go-review.googlesource.com/9077
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2015-04-20 17:34:49 +00:00
Hyang-Ah Hana Kim f0c91fa51b cmd/gomobile: copy old5a to the tool chain.
The app/internal/callfn package requires old5a.

Change-Id: Id0e084dc5c1dd1275d0043412ab9ea0423e7651d
Reviewed-on: https://go-review.googlesource.com/9034
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2015-04-17 19:43:10 +00:00
David Crawshaw d77bba0a9f app: call main.main on app startup
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>
2015-04-17 16:08:58 +00:00
Hyang-Ah Hana Kim 47553f4d42 cmd/gobind: fix a typo.
This addresses the reviewer's comment from change 8986.

Change-Id: Ibeec45fa9b8ab2ee68ebcc98f38f3538d992024d
Reviewed-on: https://go-review.googlesource.com/8987
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2015-04-16 18:47:12 +00:00
Hyang-Ah Hana Kim 5f5a5fa270 cmd/gobind: list byte slice as a supported type.
Fixes golang/go#10481.

Change-Id: I8cee771c32347c2ef641b416dbc1967dc52a0f46
Reviewed-on: https://go-review.googlesource.com/8986
Reviewed-by: Burcu Dogan <jbd@google.com>
2015-04-16 18:19:58 +00:00
Hyang-Ah (Hana) Kim bdbc727b12 bind/java: convert test.bash to go test.
This change deletes unnecessary files - they are auto-generated by
the gomobile bind command.

Change-Id: I490664dfcf52683dd8d2ea821d0b7e458bc06671
Reviewed-on: https://go-review.googlesource.com/8925
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2015-04-15 12:57:12 +00:00
Hyang-Ah (Hana) Kim 0150454fb3 bind/seq: add Buffer.{Read,Write}UTF8.
Change-Id: I204dd9c9080c9c1e350210932397a500247aea28
Reviewed-on: https://go-review.googlesource.com/8896
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2015-04-14 18:50:33 +00:00
Burcu Dogan cd5954b705 audio: add notice about the OpenAL license
OpenAL Soft is licensed with LGPL which requires users to add a notice
about its license under their open source notices screen.

Change-Id: Ic3c3bcc4a38896508b19d54a8c526bcd1fa9d5b3
Reviewed-on: https://go-review.googlesource.com/8868
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2015-04-13 22:34:15 +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
Hyang-Ah (Hana) Kim 334412418f bind: replace {Read,Write}UTF16 with {Read,Write}String for string.
This is to enable more flexible encoding/decoding of Go string.
For Java, we use UTF16 to be compatible with java string.
For other languages, we will want other way to represent a string.

Change-Id: Iccd53e2eea18d37636c3c619d06cb473facef0cd
Reviewed-on: https://go-review.googlesource.com/8628
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2015-04-09 12:44:56 +00:00
Hyang-Ah (Hana) Kim d886eeda27 bind/java: fix testpkg's gobind generate command.
Change-Id: I36494baac428ed9fdd777d2b03bf23a9cb2568b5
Reviewed-on: https://go-review.googlesource.com/8627
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2015-04-09 12:44:41 +00:00
Burcu Dogan 7858a6e1a7 sensor: minimize the number of epolls
Drain the event queue between ALooper_pollAll calls. ALooper_pollAll
makes an epoll to see if there is any I/O going on the underlying
resources and is relatively a costly operation. Try to consume the
queue first and block on pollAll again if necessary.

We should stop retrying if timeout occurs and return immediately.

Change-Id: I6e9f85df2dd275fb014f90f13de4f05d776d4b7d
Reviewed-on: https://go-review.googlesource.com/8590
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
2015-04-08 03:40:08 +00:00
Nigel Tao e5a0a60135 sensor: make the global Type values consts instead of vars.
Change-Id: I209b1d5c6e86ff08739add4aaab28e9a57565c93
Reviewed-on: https://go-review.googlesource.com/8601
Reviewed-by: Burcu Dogan <jbd@google.com>
2015-04-07 23:58:06 +00:00
Burcu Dogan 16015b6039 sensor: don't block Read more than 30 secs
Don't block on Read forever, force timeout if nothing happens for
a while. 30 secs is high enough not to be the desired delay for
the movement sensors.

Change-Id: I257120809855382d7a945a132f5b7a2cff1ecfca
Reviewed-on: https://go-review.googlesource.com/8580
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
2015-04-07 20:44:27 +00:00
Burcu Dogan dad00d93e6 Revert "mobile/sensor: block until timeout occurs"
If the looper is waking up, the current timeout limit is exceeded.
There are no external APIs to query if a looper is trying to wake up
or blocking to wait for the event data. Therefore, I'm this
change and will replace the timeout with a significantly high number
that could only be exceeded if sensor fails with a fatal problem.
The goal is not to wait on ALooper_pollAll forever.

This reverts commit 1575a42f33.

Change-Id: I861d81f2550c4435247a0b1d4ce141e94d1e3ec9
Reviewed-on: https://go-review.googlesource.com/8565
Reviewed-by: Burcu Dogan <jbd@google.com>
2015-04-07 20:20:34 +00:00
Burcu Dogan bf1596d2ef audio/al: destroy the internal context while finalizing Context
The necessity to destroy an ALC context is not to leave a leaking
context as Context instances are being collected. If the user doesn't
Destroy, do it when finalizing. If a context is destroyed by the user,
a finalizer is no more needed.

Change-Id: If6330361f7983ec8ede0e93b7f6e3a440de9fd6c
Reviewed-on: https://go-review.googlesource.com/8497
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
2015-04-07 15:24:13 +00:00
Burcu Dogan 6544820032 audio/al: don't define MakeContextCurrent on the pointer
It's a common requirement to call MakeContextCurrent with a nil value
before destroying a context. Nil value as a reciever is not as user-
friendly as a standalone MakeContextCurrent.

Change-Id: I537ec0330657ef134f97a3c3b0d32793012eee86
Reviewed-on: https://go-review.googlesource.com/8500
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
2015-04-06 22:23:13 +00:00
Burcu Dogan c2bf90dc60 audio/al: add bindings for alcDestroyContext
Fixes #10330.

Change-Id: Ib5c379593ac4afef11b465773f6373dd5775ce98
Reviewed-on: https://go-review.googlesource.com/8492
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
2015-04-06 16:20:40 +00:00
Burcu Dogan 1575a42f33 mobile/sensor: block until timeout occurs
Avoid blocking forever until there are no new events in the
queue. The queue should have been fed with new events once in each t,
where t is 2 * minimum delay enabled on the queue.

Change-Id: Ie6c754816e89a93adf62d71448c6c85f167350eb
Reviewed-on: https://go-review.googlesource.com/8414
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
2015-04-06 14:29:59 +00:00
Burcu Dogan 55736cdd50 mobile/sensor: readability fixes
Change-Id: I0550055b54545b75248bb76086377ebbedda7f58
Reviewed-on: https://go-review.googlesource.com/8458
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
2015-04-03 23:04:21 +00:00
Burcu Dogan 96e541427e mobile/sensor: don't panic, return an availability error on non-android
Change-Id: I42152d6fd5af220a780a6e3a288a97551ee53f39
Reviewed-on: https://go-review.googlesource.com/8413
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
2015-04-02 22:59:47 +00:00
Burcu Dogan 2beb6b6bcd mobile: list the sensor package on README
Change-Id: Iae635926dad40248df2a14a6bb2fbaff1b5bcd03
Reviewed-on: https://go-review.googlesource.com/8412
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
2015-04-02 22:12:29 +00:00
Burcu Dogan f48e3e4998 mobile/sensor: add android support
This CL contains an Android-specific Manager implementation.
On Android, we create a new ALooper for each Manager instance and
all CGO calls are proxified to an OS-thread-locked goroutine.

Change-Id: I33272cd4369d0b7850f97e840fe4bbe5aee78ec0
Reviewed-on: https://go-review.googlesource.com/8249
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
2015-04-02 19:28:00 +00:00
Burcu Dogan dfdb6c5a4a mobile/sensor: remove the unnecessary init mutex
Manager ops are not promised to be thread-safe.

Change-Id: Ib28b80d758234a7a19287c457c57099e36d73f9b
Reviewed-on: https://go-review.googlesource.com/8248
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2015-03-30 20:55:46 +00:00
Hyang-Ah (Hana) Kim d04e7395d9 cmd/gomobile: change the bind command to output .aar format for Android.
Instead of the ad-hoc output directory structure to hold java source code
and compiled .so files, this change makes the bind command create an AAR
bundle.  AAR is the format for Android library project/module outputs.
AAR is similar to .jar except that includes resource files.

http://tools.android.com/tech-docs/new-build-system/aar-format

This AAR format is in the Android's new build system's roadmap (
http://tools.android.com/tech-docs/jackandjill) and Android IDEs
are likely supporting the format.

For integration with Android Studio project, the user is expected to place
the .aar file to the main app's libs directory and specify the dependency
in the gradle rule. This can be done through a gradle plugin or with Android
Studio integration. For Buck, the .aar file can be the input of the
android_prebuilt_aar rule.

This depends on the availability of javac and android SDK -
which may not be an issue because the bind users will need them anyway
to build their main app.

Change-Id: I635902e994d002bb875c7838e19f172e187b0b87
Reviewed-on: https://go-review.googlesource.com/8084
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2015-03-30 20:00:37 +00:00
Dmitri Shuralyov a01c060faa gl: Improve API signatures to match spec, improve docs.
Reorder DrawElements arguments to match OpenGL spec order:
    DrawElements(mode, ty, offset, count) -> (mode, count, ty, offset)
GetActiveAttrib, GetActiveUniform are defined by spec to accept
corresponding integer _index_, not location type. Change their
signature to do that:
    GetActiveAttrib(p Program, a Attrib) -> (p Program, index uint32)
    GetActiveUniform(p Program, u Uniform) -> (p Program, index uint32)
Clarify and make documentation, parameter names more clear for Uniform
(uniform location), Attrib (attribute location) types,
EnableVertexAttribArray, DisableVertexAttribArray, GetAttribLocation,
GetUniformLocation funcs.
Resolves golang/go#10218 again.

Change-Id: I5b822235d9485701186a43dae0b9fd898cc6a3d8
Reviewed-on: https://go-review.googlesource.com/8166
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2015-03-30 19:58:17 +00:00
Burcu Dogan 4d47512510 mobile/sensor: initialize the sensor package
Sensors package will contain APIs to read data from a wide variety
of movement, position and other physical signals.

This CL contains the initial APIs that are targeting event-based
sensors. Some of the concerns that influenced the APIs are:

- Target game developers. Latency is critical, allow output rates
up to ~10 samples per second.
- It’s rarely possible to predetermine the minimally viable sample
rate requirement of the app. - Allow users to set an upper bound rate
to avoid garbage and preserve battery life.
- Allow multiple instances of accelerometer, gyroscope, magnetometer
and altimeter sensors to be started. Optimize the share of the
underlying resources as long as it is not a bottleneck for the
sample rate.
- Prefer blocking APIs. An automatic
poll-timeout could be useful if we’re far behind the sample rate.
But, sensor initialization and waking-up significantly take longer
and there is no easy way to determine a sensor is in either one of
these states.
- Provide timestamps for each event to determine the actual rate of
the sensor data.
- Allow user to return multiple events from each call. Buffering the
events at the cost of additional latency is sometimes more
neglectable than the overhead of a function call that polls the
events one by one. Allow user to determine how many items they want
to buffer. The typical latency of a read a single event is 56 usec.
Reading 8-16 events at once has a relatively lower bound per event.
For high precision throughput, the opportunity to minimize a
function call overhead could be useful.
- Allow users to check the sensor availability on the device.

Change-Id: I9582c8f025d9f922d9635e247d60817f95bdacb9
Reviewed-on: https://go-review.googlesource.com/8174
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
2015-03-30 18:49:53 +00:00
David Crawshaw 502bceb448 cmd/gomobile: generate package documentation
Change-Id: I2a41cf0f16dcefe87c73ab0a8f02a251c1243157
Reviewed-on: https://go-review.googlesource.com/8121
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
2015-03-26 19:42:25 +00:00
Hyang-Ah (Hana) Kim 2965d09ba5 cmd/gomobile: don't create .apk file with the -n option.
Change-Id: If69b82f1c64c950fb5c0440dc5837f4ad7e1037a
Reviewed-on: https://go-review.googlesource.com/8085
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2015-03-26 13:49:12 +00:00
Dmitri Shuralyov eaba00bca5 gl: use better spec-defined func names, fix bug, increase consistency
Change func names and parameter order to more closely follow OpenGL
ES/WebGL spec.
    BufferData(target, usage, src) -> BufferData(target, src, usage)
    GenBuffer -> CreateBuffer
    GenFramebuffer -> CreateFramebuffer
    GenRenderbuffer -> CreateRenderbuffer
    GenTexture -> CreateTexture
Fix issue where glBoolean helper was returning inverted result.
Make Attrib.String() logic consistent with others (print value, not
struct).
Make internal code of GetUniformLocation the same as GetAttribLocation
and BindAttribLocation for consistency.
Resolves golang/go#10218.

Change-Id: Ib33dfff7c22c4d178b2e6b8d228f80f3c17308a8
Reviewed-on: https://go-review.googlesource.com/8000
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2015-03-25 21:38:11 +00:00
Burcu Dogan 6ed9b243b1 mobile/audio: use AL_TRUE and ALC_TRUE
Change-Id: I8c1a3e72f06a02c18bff3a348e86e78040007867
Reviewed-on: https://go-review.googlesource.com/7770
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2015-03-18 20:10:10 +00:00
Josh Bleecher Snyder 48cfa1a0a0 mobile: add codereview.cfg
See golang.org/cl/4131 for context.

Change-Id: I94f2b9dc20fc8ab6156257de157c98cb887a0709
Reviewed-on: https://go-review.googlesource.com/7725
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2015-03-18 17:03:44 +00:00
David Crawshaw f28a01df97 app: set valid geom.Width/Height on darwin/arm
Change-Id: Id3c5c58050fa11ec57e8efd2661047dc5e0dfc2d
Reviewed-on: https://go-review.googlesource.com/7665
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
2015-03-17 19:43:15 +00:00
Burcu Dogan 2476462d4e mobile: add a link to the audio package
The audio package runs on Android now, we can list it on README.

Change-Id: I2ff03f025328a1d0e6ffc12b860ace9c980dc422
Reviewed-on: https://go-review.googlesource.com/7521
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
2015-03-13 16:13:12 +00:00
Hyang-Ah (Hana) Kim f1ef55e1be cmd/gobind: simplify filepath.Join uses.
filepath.Join returns a Cleaned path that went through FromSlash.

Change-Id: I23afeea32453c3eb271d4e4bf47147940061c20f
Reviewed-on: https://go-review.googlesource.com/7161
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2015-03-09 16:35:40 +00:00
Burcu Dogan b316a2d0ce cmd/gomobile: pack OpenAL libraries into the apk if audio is imported
Fixes #10058.

Change-Id: Ie947f98d2ebbf1f851e1eb68132ddfe848c9aa94
Reviewed-on: https://go-review.googlesource.com/7020
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
2015-03-07 02:57:56 +00:00
Burcu Dogan 33ee14d530 mobile/audio: add instructions how to install OpenAL on Linux desktop
Change-Id: I47b42db1443040bcd9c77cd1d19a0e0f8c5119ec
Reviewed-on: https://go-review.googlesource.com/7090
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
2015-03-07 01:01:31 +00:00