Commit Graph

1042 Commits

Author SHA1 Message Date
Elias Naur 3ae5a37c24 gpu,gpu/gl: introduce Backend
A recent change made the OpenGL functions an interface of the functions
required for the implementation of GPU, a renderer for Gio operations.
That allowed for running Gio on external systems where OpenGL is
available.

However, to allow for non-OpenGL flavored backends such as Vulkan,
Metal and Direct3D, this change introduces Backend for the high-level
operations required by GPU. This change also adds a concrete backend
to package gl.

Type Backend is a first cut heavily based on OpenGL. Future changes will add
more backends, where the Backend interface quite possibly will need refinement.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-02-10 18:22:57 +01:00
Elias Naur 9602337b45 gpu/gl: remove redundant glClear from sRGB emulation
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-02-10 15:58:36 +01:00
Daniel Martí 47544697fa .builds: switch to Go 1.14rc1 release downloads
On Linux and FreeBSD, this means we no longer need to install Go twice,
since we don't need to bootstrap a Go build. This reduces the "install
go" step by over half a minute, and avoids installing a number of distro
packages.

Debian requires the pkg-config package to be explicit, as it's not part
of the build-essential metapackage, and we need it. It was being pulled
as a dependency from the golang package before.

OpenBSD is nearly the same change, modulo the fact that Go doesn't have
a binary release for it. So instead, we keep installing Go via the
system's package, and we download and build a source archive.

Finally, switch from Debian testing+experimental to simply unstable.
Sway 1.4 finally hit unstable a few days ago, and experimental is
extremely unstable, so this is a step in the right direction. Add a TODO
about going to just testing once sway 1.4 arrives there.

Signed-off-by: Daniel Martí <mvdan@mvdan.cc>
2020-02-09 10:58:35 +01:00
Elias Naur 5f3f7b3514 .builds: make the GLFW example build on the automatic builders
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-02-08 00:14:20 +01:00
Elias Naur 1f422ef960 all: gofmt
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-02-08 00:04:15 +01:00
Elias Naur 140888ec86 example/glfw: add example demonstrating GLFW integration
Updates gio#26

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-02-07 23:15:05 +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
Larry Clapp e672d71c61 widget: add some utility methods on Editor
- Focused: returns whether editor is focused
- CaretPos: returns the text line & column numbers of the caret.
- CaretCoords: returns the x & y pixel coordinates of the caret.
- NumLines: returns the number of text lines in the editor

Signed-off-by: Larry Clapp <larry@theclapp.org>
2020-02-06 14:54:08 +01:00
Daniel Martí ed8a0c4909 cmd/gogio: extract endtoend driver base into a type
This type contains all the common bits, such as *testing.T, as well as
the channel and method used to wait for blocking until a frame is ready.

It also allows us to initialise this base separately from Start, which
keeps the exported method simpler to understand.

The base type is embedded into the specific driver types, so that the
code remains simple. While at it, start embedding *testing.T too, so
that we can write d.Fatalf instead of d.t.Fatalf. The drivers will only
have a small number of exported methods as per the interface, so it's
easy to keep those from colliding with the method set on T.

Signed-off-by: Daniel Martí <mvdan@mvdan.cc>
2020-02-06 08:15:32 +01:00
Elias Naur b8b8003a7a example/gophers: update gio version
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-02-03 23:53:45 +01:00
Elias Naur 383f3eca40 widget: re-layout Editor before processing events if layout is invalid
Editor's event processing assumes the cached layout is valid, but
it might not be if the program changed the Editor text between calling
Layout and Events.

Fixes #85 (I think)

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-02-03 23:48:20 +01:00
Elias Naur c178ade323 widget: remove Editor field carWidth
The caret width can be computed in the only method that needs it,
PaintCaret.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-02-03 23:37:46 +01:00
Elias Naur b0af85d3c3 widget: remove scale detection hack from Editor
Now that text layout and shaping operate on concrete sizes and not
units, Editor no longer needs to detect scaling changes. Remove it.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-02-03 23:32:55 +01:00
Elias Naur 4c220f4554 text: simplify text layout and shaping API
First, replace LayoutOptions with an explicit maximum width parameter.  The
single-field option struct doesn't carry its weight, and I don't think we'll
see more global layout options in the future. Rather, I expect options to cover
spans of text or be part of a Font.

Second, replace the unit.Converter with an scaled text size. It's simpler and
allow the Editor and similar widgets to easily detect whether their cached
layouts are stale. Package text no longer depends on package unit, which is
now dealt with at the widget-level only.

Finally, remove the Size field from Font. It was a design mistake: a Font is
assumed to cover all sizes, as evidenced by the FontRegistry disregarding
Size when looking up fonts.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-02-03 23:32:55 +01:00
Elias Naur dcacca3442 .builds: don't rely on Sway being available
The Sway Debian experimental package is currently broken. Make it
optional.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-02-03 14:47:11 +01:00
Elias Naur 1cf8fee73f example/gophers: update Gio version
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-02-02 17:19:27 +01:00
Elias Naur fb7337f794 layout: replace Align with a Layout method on Direction
It's one less type (Align) and shorter:

Before:

	layout.Align(layout.Center).Layout(...)

After

	layout.Center.Layout(...)

It is also safer: since `layout.Align(...)` was a casting operation,
the Go compiler would not complain about an incompatible constant.

For example, the widget/material package contained a wrong cast:

	layout.Align(layout.Start)

which should have been

	layout.Align(layout.W)

After this change, attempting `layout.Start.Layout(...)` result
in a compile error.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-02-02 17:13:02 +01:00
Elias Naur 359839ad07 README.md: add OpenBSD to list of supported platforms
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-02-01 15:56:50 +01:00
Elias Naur f640b798ee example: update gio version to fix OpenBSD build
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-01-29 18:16:18 +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í 8d1e53cfa9 cmd/gogio: add the first Android end-to-end test
It passes the whole e2e test flow on my real device, a OnePlus 5 running
LineageOS 16.0 (Android 9).

I was also successful at running it against an x86-64 Android 8.0
emulator, but I'm not including any of that just yet. A patch later this
week will include a piece of code to set up and start an emulator, which
CI can then use to run the test.

Also stop requiring the screen dimensions to be enforced when running in
non-headless mode. An Android emulator can run at an arbitrary
resolution, and even in headless mode, but a real Android device will
have its own predefined resolution. Forcing the test user to set the
-headless=false flag to not get annoying "unexpected dimensions" errors
would be annoying.

That check doesn't really mean much, as our test app doesn't care about
the screen resolution. And we were only doing the check sometimes. Drop
it entirely, making the resolution parameters merely a hint so that we
can keep the drivers a bit more consistent.

Signed-off-by: Daniel Martí <mvdan@mvdan.cc>
2020-01-29 14:50:42 +01:00
Aaron Bieber ff6c798a28 app: Extend CI to build on OpenBSD now that golang.org/x/sys is updated.
I was able to get the Pipe2 syscall added for OpenBSD:
https://go.googlesource.com/sys/+/9fbb57f87de9ccfe3a99d4e3270ce8a926ebba4f

This also updates the dependencies to include the latest sys and gio.

I submitted a patch to the builder environment to include the xshare sets on
OpenBSD. Once that is in it will mean the "install_deps" block can be removed.

  https://lists.sr.ht/~sircmpwn/sr.ht-dev/patches/9640

Here is a link to a successful build: https://builds.sr.ht/~qbit/job/143004

Signed-off-by: Aaron Bieber <aaron@bolddaemon.com>
2020-01-28 17:21:01 +01:00
Daniel Martí 6819dea21c cmd/gogio: attempt to fix timeout failures on CI
I've seen a couple of "timed out waiting for a frame to be ready" errors
on CI in the past week. I think two seconds is a bit low, if the machine
in question is not very powerful or under stress - which is common for
CI environments.

Raise the timeout to 5s.

While at it, add some log lines to each e2e test, and mark waitForFrame
as a helper func, so that its errors show up at the caller's location.

Signed-off-by: Daniel Martí <mvdan@mvdan.cc>
2020-01-28 15:27:50 +01:00
Elias Naur 761ab68868 cmd/gogio: support newer NDKs
Newer Windows NDKs add the "x86_64" platform suffix like other
OS'es. Remove the special case.

Newer NDKs are also installed in "ndk/x.y.z" versioned directories
instead of in "ndk-bundle". Support that.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-01-27 17:34:43 +00: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
Elias Naur fb07ad6593 .builds: add missing dependency
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-01-24 15:00:46 +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
Elias Naur 18cddc0300 layout: include Expanded sizes in Stack size calculation
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-01-16 13:20:50 +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 b331407e81 text: add io.Reader Layout method to Shaper
use them for Editor, which is no longer required to construct a string
for laying out its content.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-01-13 21:38:54 +01:00
Elias Naur 16d2a3ac0a text: remove String, Layout and add Glyph
In preparation for using Shaper with an io.Reader, rework the API to not refer
to strings. In particular, introduce Glyph for holding the rune in addition to
the advance. For fast traversing of the underlying text, add Len to Line with
the UTF8 length.

Layout is a useless wrapper around []Line; remove it while we're
here.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-01-13 19:54:11 +01:00
Elias Naur e25b1639b9 text: make Shaper an interface
And rename out the caching implementation to FontRegistry.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-01-13 14:48:31 +01:00
Elias Naur 3f6a1c34d3 text: correct Shaper comment about the default face
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-01-13 13:52:33 +01:00
Daniel Martí 170e86142c cmd/gogio: don't hang on some e2e test errors
For example, if the test app fails to start on wayland, we'd block
~forever (ten minutes) waiting for it to render its first frame.

We don't have a good solution right now. But at least we can use a
relatively short timeout, to help out the human who rightfully expects
a result within ten seconds.

While at it, remove a sway "get_seats" command, which was a leftover
from my debugging of what input devices are available when running
headless.

Signed-off-by: Daniel Martí <mvdan@mvdan.cc>
2020-01-13 13:36:51 +01:00
Elias Naur 08b840f114 example/go.*: update gio version
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-01-11 23:23:11 +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
axel paulander 2e66c90aee op/paint: correct image loading
Corrected the use of draw.Draw in paint.NewImageOp as the old use only works for images starting at the origin

Signed-off-by: Axel Paulander <axel.paulander@gmail.com>
2020-01-10 17:52:33 +01:00
Elias Naur 631c3b0e02 example/go.*: update gio version
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-01-08 13:31:16 +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 ccbcbdbfbd example/go.*: update Gio version
Updates #40

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-01-03 11:31: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 3dd7c8121c font/opentype: add Collection type and methods
The Collection type wraps sfnt.Collection and allows lazy-loading
of fonts from SFNT collections.

Signed-off-by: Greg Pomerantz <gmp.gio@wow.st>
2019-12-18 19:07:54 +01:00
Elias Naur 19acf05820 COPYING: extract licensing information into COPYING
This is hopefully clear enough for license detectors and lawyers.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-12-18 09:58:21 +01:00