Commit Graph

24 Commits

Author SHA1 Message Date
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 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 9528a6e0d4 app/internal/gpu: rename NewGPU to New
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-12-01 22:38:39 +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
Elias Naur 1d0a7b845e app: destroy GPU before ack'ing the DestroyEvent
The DestroyEvent ack allows the backend to release the window.
Ensure that the GPU associated with the window is done before that
happens.

Updates gio#67

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-11-12 22:17:29 +01:00
Elias Naur 41abb5b08d Revert "app: release GPU before processing DestroyEvent"
This reverts commit 8620b43eb3.

Releasing the GPU after ack'ing the DestroyEvent is too late.

Updates gio#67
2019-11-12 22:12:57 +01:00
Elias Naur 8620b43eb3 app: release GPU before processing DestroyEvent
In fact, move the release of the GPU to a deferred function, saving
a release.

Fixes #65

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-11-09 18:17:11 +01:00
Elias Naur 1eaa5dd15e app,app/internal/gpu: process frame in parallel
A frame ops buffers is tracersed twice: once for GPU commands,
and once for everything else. There is already a GPU goroutine for
concurrentl issuing of GPU commands; move the frame ops processing
to the goroutine as well. Both frame ops passed can then proceed
in parallel.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-11-08 13:53:11 +01:00
Elias Naur 1678f922e7 app: make CPU timings more useful
Record the time for generating a frame and submitting it as well
as the time for issuing the frame to the GPU and swapping buffers.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-11-08 13:29:35 +01:00
Elias Naur f6cdc62120 app: don't schedule a new frame for profiling events
Sometimes it's useful to profile yet not continously re-draw. If the programs
wants the old behaviour, it can issue an InvalidateOp or call
Window.Invalidate.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-11-08 13:02:19 +01:00
Elias Naur d980c4652a app: don't touch the frame after returning from FrameEvent.Frame
It was already true that the GPU wouldn't touch the frame after
calling GPU.Draw. This change makes FrameEvent.Frame block until
GPU.Draw is complete.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-11-07 17:34:32 +01:00
Elias Naur 9126da41f4 app: accept pending frame before reporting error
If creating a GPU instance fails for some reason, we need to
receive the incoming frame from the application before reporting
the error in a DestroyEvent. If we don't, the a deadlock will occur
where the app is waiting for FrameEvent.Frame to complete, while
the Window waits for the app the receive a DestroyEvent.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-11-01 19:38:13 +01:00
Elias Naur 2e605f2dcb app: ensure the previous frame is complete before accepting another
It matters for end-to-end tests that rely on the window contents.

Before this change, tests had to wait for 2 extra frames. This change
ensures that the first completed FrameEvent.Frame call guarantees
the previous frame is complete.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-10-30 00:53:21 +01:00
Elias Naur b30bf3cef8 app/internal/log: extract log setup to separate package
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-10-14 16:39:32 +02:00
Elias Naur 10c1b2cb8d app,internal/window: extract native window code to separate package
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-10-14 16:39:32 +02:00
Elias Naur 36d1cd90f2 app,io/system: extract system events to separate package
Package app is the only package that depends on native libraries and
Cgo. Minimize its API, thereby minimizing Gio clients' dependency on
it. In the future, a headless, testing or remote "Window" should be
very easy to replace app.Window.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-10-14 16:20:20 +02:00
Elias Naur a937a76534 app: rename UpdateEvent to FrameEvent and add Frame field
While "DrawEvent" was too specific (op.Ops contains non-draw events),
"Update" is too vague: it's a common word, and could be misunderstood
to mean update parts of a window, not replace it.

"FrameEvent" is more specific, and is the usual way to refer to immediate
mode drawing.

While we're here, unexport Window.Update and add a Frame function to
FrameEvent, to emphasize that updating the window frame is only
appropriate during the handling of a FrameEvent.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-10-12 14:01:46 +02:00
Elias Naur 4864459291 app: rename WindowOption to Option, and leave out "With" from options
While we're here, replace Height and Width options with just a Size; the value
of separate width and height options is not clear to me.

Finally, leave out the wrapping struct from the Option type, the
function is enough.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-10-07 12:00:17 +02:00
Elias Naur 3784ece6dd all: rename package ui to unit
Package ui is now only about units except for the Config.Now method.
Remove Now and rename Config to Converter. Add layout.Config to
replace the old ui.Config.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-09-30 16:55:47 +02:00
Elias Naur 8cf35a1f97 op: add package op for operations
Extract operation types from package ui into package op.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-09-30 16:55:47 +02:00
Elias Naur e7a97bf176 io/event: move event types from package ui to its own package
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-09-30 15:18:08 +02:00
Elias Naur 7a259e68f7 io: give event packages a common prefix
Packages that provide support for external events such as pointer, key and
system are only the beginning. Future packages are expected for clipboard
access, drag and drop, gps positions and so on.

To keep the number of top-level packages under control, move such I/O packages
to the new `io` directory.

The `system` package name was the previous solution to keeping the number of
top-level packages under control: I named it `system` instead of the narrower
`profile` because I expected to put all the less common events into it, turning
`system` into a "package util" smell.

With `io`, package system can be renamed to `profile`.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-09-30 14:50:55 +02:00
Elias Naur 22cd88df9f all: rename the gioui.org/ui module to gioui.org
The "ui" is redundant and stutters.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-09-30 12:37:06 +02:00