Commit Graph

146 Commits

Author SHA1 Message Date
Elias Naur 1f422ef960 all: gofmt
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-02-08 00:04:15 +01:00
Elias Naur d2d495416a gpu: rename method GPU.Frame to BeginFrame and drop redundant argument
The viewport size was already specified in the call to Collect.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-02-07 21:35:19 +01:00
Elias Naur 3b6646933d gpu: expose the rendering implementation
The rendering implementation is needed for using Gio UI with external
window libraries such as GLFW. Expose it in the new package gpu.

Updates #26

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-02-07 21:21:38 +01:00
Elias Naur 34c6a2f735 io/router: expose the event router
For integrating with external window implementations (replacing
package app), access to the event router is required. Extract it
and put it into the new package router.

Router may belong in package io/event, but can't without introducing
import cycles.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-02-07 20:41:04 +01:00
Elias Naur 6e98132ebb app/internal/gpu: extract profile in separate method, Profile
Updates #26

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-02-07 20:08:50 +01:00
Elias Naur 81f958fc70 app/internal/gpu: remove profile flag
Automatically determine whether to profile GPU operations from
the existence of a profiling op.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-02-07 20:00:52 +01:00
Elias Naur 320535a978 app/internal/input: remove AddProfile method
Merge it into the general Add method.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-02-07 19:41:39 +01:00
Elias Naur 251c075093 app/internal/gl/impl: extract platform dependent opengl bindings
We'd like to support Gio using a different renderer binding than
the builtin. A first step is to define the Functions interface
in package gl, and extract the concrete implementations to a
separate package.

Updates #26

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-02-07 19:22:30 +01:00
Greg Pomerantz 72cb36c5f9 app/internal/gpu: make the zero value of paint.ImageOp useful
Do not panic when drawing the zero value of paint.ImageOp.

Signed-off-by: Greg Pomerantz <gmp.gio@wow.st>
2020-01-29 15:58:45 +01:00
Daniel Martí 54ed198cb0 app: don't discard android touch events of unknown tool type
This is the kind of event one gets when using 'adb shell input tap x y',
which I am trying to use for the end-to-end tests.

Right now, we only have two pointer source types: mouse and touch.
On Android, emulated touch events tend to simulate the touchscreen, not
a mouse, so let's go with that as a fallback.

Perhaps in the future we will have another special pointer source for
this kind of event, such as "unknown" or "virtual".

Signed-off-by: Daniel Martí <mvdan@mvdan.cc>
2020-01-27 11:17:47 +01:00
Aaron Bieber fdaf891732 app: Enable building on OpenBSD
Currently the golang.org/x/sys package is missing the Pipe2 call for OpenBSD.
The call exists on OpenBSD, it just isn't exposed.

This diff was tested buy adding the Pipe2 call and setting:

   go mod edit -replace=golang.org/x/sys=/pat/to/modified/sys

Signed-off-by: Aaron Bieber <aaron@bolddaemon.com>
2020-01-24 14:32:54 +01:00
mural a7dc7c01c0 app/internal/log: add logger for Windows DebugView
Signed-off-by: mural <mural@ctli.io>
2020-01-13 21:48:13 +01:00
Elias Naur f176cbfe88 app/internal/egl: try EGL_DEFAULT_DISPLAY is eglGetDisplay fails
Fixes #77

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-01-11 23:21:27 +01:00
Elias Naur bc30683588 Revert "app/internal/egl: accept zero EGLDisplay values as valid"
This reverts commit 66138e7890.

Reason: According to #77, it didn't work and the proposed fix
(retry when EGL_NO_DISPLAY is returned) is correct.
2020-01-11 23:15:23 +01:00
Elias Naur 66138e7890 app/internal/egl: accept zero EGLDisplay values as valid
Issue #77 seems to be caused by eglGetDisplay returning a zero
EGLDisplay, yet eglGetError returns EGL_SUCCESS. Since EGLDisplay
is not necessary a pointer type, the zero value may be valid.

Updates #77

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-01-08 13:28:12 +01:00
Elias Naur 95903aafda app/internal/window: add errno to wl_display_connect errors
Updates #40

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-01-03 11:28:53 +01:00
Greg Pomerantz 8a4d0007f3 app: clarify documentation of app.Main()
Signed-off-by: Greg Pomerantz <gmp.gio@wow.st>
2019-12-16 19:06:05 +01:00
Elias Naur 9114dbe759 app/internal/gl: gofmt -w -s
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-12-12 00:45:36 +01:00
Elias Naur 4a628d1c2c app/internal/gpu: re-add check for GL_EXT_color_buffer_half_float
As noted in #49, GL_EXT_color_buffer_half_float is required for
GL_OES_texture_half_float to be useful for FBOs.

Updates #49

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-12-11 15:12:57 +01:00
Elias Naur 8a44ac11d8 app/internal/gpu: use single channel floating point FBO if possible
Remove dependency on EXT_color_buffer_half_float, it's not clear it's
necessary. In any case the following FBO sanity check will catch invalid
FBO format combinations.

Updates #49

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-12-11 13:54:24 +01:00
Elias Naur 86d69859b9 app/internal/gpu: query GL_EXTENSIONS correctly on macOS
macOS supports the OpenGL core profiles where glGetString(GL_EXTENSIONS)
is not supported. Use glGetStringi(GL_EXTENSIONS, <index>) instead.

The wrong query didn't make any practical difference because Gio doesn't
need any extensions on OpenGL 3 and better.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-12-04 00:29:43 +01:00
Elias Naur d9212263aa app/headless: prepare OpenGL context on macOS
The macOS backend uses a desktop OpenGL context, not a OpenGL ES
context. The main difference is that sRGB have to be enabled and
a vertex buffer must be bound.

Do that and fix Window.Screenshot for scenes more complex than a
glClear.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-12-04 00:29:43 +01:00
Elias Naur fddb0af6f6 app/internal/gpu: default to color material
Before this change the default material were a texture, which leads
to a crash when no texture is current.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-12-03 16:48:48 +01:00
Elias Naur 6fbdefa21f app/headless: compensate for OpenGL's lower left origin
The origin of image.Images is the upper left corner. Convert the
ReadPixels result by flipping the image the y-direction.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-12-02 13:59:34 +01:00
Elias Naur 41116b5cb8 app/headless: add package docs
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-12-02 00:05:30 +01:00
Elias Naur 0b84137f40 app/headless: implement headless windows
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-12-01 23:40:02 +01:00
Elias Naur 9df3c76aa2 app/internal/egl: don't exit if EGL dlls fails to load
We want a useful error instead of a hard exit for headless windows.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-12-01 23:40:02 +01:00
Elias Naur 06a2228798 app/internal/windows: split out Windows syscalls from package window
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-12-01 23:25:04 +01:00
Elias Naur 9b4176c475 app/internal/egl,app/internal/window: move Lock/Unlock methods
EGL contexts don't need locking, so their Lock and Unlock methods
are empty. Remove them and add them where necessary instead.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-12-01 23:25:04 +01:00
Elias Naur 15a1261cfc app/internal/egl: only create a compatibility FBO if there is a surface
While here, only refresh the FBO if needed to make MakeCurrent faster.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-12-01 23:25:04 +01:00
Elias Naur f25f647a66 app/internal/window,app/internal/gl: move gl.Context to package window
Package gl now only defines opengl types and functions.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-12-01 23:25:04 +01:00
Elias Naur 5fa3dbc70d app,app/internal/gpu: split render loop from GPU
The policy of rendering on a separate goroutine is separate from
the actual rendering. Reflect that by introducing the RenderLoop
type for driving a GPU from a separate goroutine.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-12-01 23:25:04 +01:00
Elias Naur 8cec7d1a40 app/internal/window: move context refresh to window
Instead of calling from the low level context into the window
for its surface and dimensions, add a Context.MakeCurrent method
that does it directly.

The result is simpler and clearer logic. For example, synchronization
is obviously no longer needed. It wasn't necessary before, but the
reason was unclear.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-12-01 23:25:04 +01:00
Elias Naur 3199ae7600 app/internal/window: fix typo
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-12-01 23:25:04 +01:00
Elias Naur 14dad238f3 app/internal/gl: lazy load blitting program and quad in SRGBFBO
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-12-01 23:25:04 +01:00
Elias Naur f9f6f2d3ea app/internal/gl: delete buffer and program in SRGBFBO.Release
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-12-01 23:25:04 +01:00
Elias Naur 809b4a2cf9 app/internal/gpu: don't release the context when New fails
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-12-01 23:25:04 +01:00
Elias Naur c49f214f4a app/internal/egl: support surfaceless contexts
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-12-01 23:25:04 +01:00
Elias Naur 5016c98739 app/internal/egl: split surface creation from making context current
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-12-01 23:25:04 +01:00
Elias Naur 99b6ad09e5 app/internal/egl: move EGL interface to its own package
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-12-01 23:25:04 +01:00
Elias Naur 9528a6e0d4 app/internal/gpu: rename NewGPU to New
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-12-01 22:38:39 +01:00
Elias Naur eb8745eb32 app/internal/window: remove redundant return
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-12-01 22:38:38 +01:00
Elias Naur 77d21ddf38 app/internal/gl: fix ReadPixels on Windows
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-12-01 20:16:32 +01:00
Larry Clapp 0ddcee4ec6 app/internal/windows: modifiers & punctuation hotkeys
For Windows:
- Add shift/ctrl/etc modifiers to mouse events, so you can recognize the
  difference between "click" and "shift-click".
- Add several allowed punctuation characters as single key events, so
  you can (for example) use "." as a hotkey.

Signed-off-by: Larry Clapp <larry@theclapp.org>
2019-11-30 10:31:04 +01:00
Greg Pomerantz 2ca2e5462f app: add RegisterFragment method on *Window for Android
RegisterFragment creates an instance of a Java class and registers
it as a Fragment in the window's Context.

Signed-off-by: Greg Pomerantz <gmp.gio@wow.st>
2019-11-26 18:52:43 +01:00
Greg Pomerantz 8321745de9 app/permission: add documentation and storage permissions
Storage permissions enables the Android permissions
READ_EXTERNAL_STORAGE and WRITE_EXTERNAL_STORAGE.
2019-11-26 12:29:00 +01:00
Elias Naur aca511f849 app/internal/window: (wasm) generate key.Events for all printable characters
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-11-24 19:41:11 +01:00
Larry Clapp 65bc7be256 app/internal/window: allow punctuation as keycode events
Allows things like "ctrl-{" and ".".

All punctuation is returned as-is, e.g. "!" is "!", not "shift-1", and
"{" is "{", not "shift-[".

Also add the Enter key as a known key (fn-return on my Mac).

Signed-off-by: Larry Clapp <larry@theclapp.org>
2019-11-24 19:41:11 +01:00
Elias Naur d5424ef7fc app/internal/window: replace X11 input handling with xkb
Unifies Wayland and X11 keyboard handling.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-11-24 19:41:11 +01:00
Elias Naur 5a34b6f2c3 app/internal/xkb: send key.Events for shifted keysyms
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-11-22 16:13:38 +01:00