Commit Graph

27 Commits

Author SHA1 Message Date
Elias Naur 00a87f542d ui: introduce OpColor, a specialized OpImage for uniform colors
To avoid allocating an image.Image for OpImage.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-06-01 13:01:51 +02:00
Elias Naur 0061c73a89 ui: split OpImage into OpImage and OpDraw
In preparation for an OpColor (and future OpGradient and similar).

Label and Editor no longer take an explicit source image. They
draw with the current image.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-06-01 12:44:49 +02:00
Elias Naur a1c0693eeb ui/app: add Lock/Unlock to Context for macOS
Without locking, asynchronous OpenGL rendering crashes on macOS.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-05-24 14:01:26 +02:00
Elias Naur c3ea85801c ui/app: (wasm) replace TypedArrayOf with the CopyBytes* API
syscall/js.TypedArrayOf is going away in Go 1.13 and is replaced by
the CopyBytesToGo, CopyBytesToJS.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-05-24 12:30:34 +02:00
Elias Naur edec032ae6 ui/app: (wasm) re-use javascript buffer
Now that syscall/js.TypedArrayOf is going away in Go 1.13 (sse
https://golang.org/issue/31980), copying byte slices to JS before
use is necessary. To avoid garbage, re-use a single buffer for all
transfers.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-05-23 10:16:49 +02:00
Elias Naur 7b13da7299 ui/app: (wasm) use JS allocated buffer for invalidateFramebuffer
syscall/js.TypedArrayOf is going away in Go 1.13. Avoid it for
invalidateFramebuffer by using a buffer managed by JS.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-05-23 10:16:49 +02:00
Elias Naur da598663f7 ui/app: add GL buffer caches
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-05-16 21:47:30 +02:00
Elias Naur 642318842c ui/app/internal/gpu: add pathOp cache
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-05-16 21:16:36 +02:00
Elias Naur 32c525f7fd ui/app/internal/gpu: check for GL_EXT_disjoint_timer_query_webgl2
GL_EXT_disjoint_timer_query_webgl2 is the WebGL 2 counterpart to
the WebGL 1 GL_EXT_disjoint_timer_query extension.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-05-13 19:50:26 +02:00
Elias Naur 18c74f00af ui/app/internal/gpu: check floating point FBO support
Some devices don't support floating point FBOs even though they
support OpenGL ES 3. Check support by creating a FBO and fail early
if no support is found.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-05-13 12:44:47 +02:00
Elias Naur 8f3384ffe4 ui/app/internal/gl: add RENDERER enum value
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-05-13 09:52:39 +02:00
Elias Naur 530b9b09b2 ui/app/internal/gpu: drop useless timing
It is almost always 0.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-05-12 18:00:25 +02:00
Elias Naur 0397cbb599 ui/app: add basic webassembly/webgl support
It is still slow. And crashy: https://github.com/golang/go/issues/31980.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-05-11 13:17:57 +02:00
Elias Naur f1c87417bd ui/app: split extension string before matching
Avoids false matches for extensions whose names are substrings of
other extensions.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-05-11 13:17:57 +02:00
Elias Naur c6863581e0 ui/app/internal/gl: add workaround for broken sRGB FBOs
Safari on macOS don't treat sRGB correctly.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-05-10 17:50:14 +02:00
Elias Naur 51482b6493 ui/app/internal/gpu: move sRGBA feature detection to context
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-05-10 17:50:06 +02:00
Elias Naur fd9eb029c8 ui/app/internal/gpu: drop opaque texture optimization
It doesn't seem worth the trouble: images must be scanned for
alpha != 1 and GPUs don't like RGB formats. Use RGBA always.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-05-08 17:57:10 +02:00
Elias Naur 871ae34be5 ui/app/internal/gl: move single channel format detection to context
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-05-08 17:57:10 +02:00
Elias Naur f5fa968038 ui/app/internal/gpu: implement OpenGL ES 2 float fbo fallbacks
Also applicable to WebGL.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-05-08 17:57:10 +02:00
Elias Naur d118bd5a88 ui/app/internal/gpu: introduce caps and context
Enables graceful fallback to OpenGL ES 2 and WebGL.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-05-08 17:57:10 +02:00
Elias Naur 8df5feeeea ui/app: make opengl objects structs
WebGL use opaque values for object handles, not integers. To ensure
portability, wrap handle types with a struct.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-05-08 17:57:10 +02:00
Elias Naur 2af0f63cfb ui/app/internal/gl: parse WebGL versions
And drop a redundant error message while here.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-05-08 17:57:09 +02:00
Elias Naur 350dc19108 ui/app/internal/gl: invalidate the correct fbo in sRGB fallback
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-05-08 14:28:43 +02:00
Elias Naur 252e058766 all: serialize ops
Pros:
- Much less per-frame garbage
- Allow future preprocessing of ops while building it
- Much fewer interface calls and pointer chasing
- Allow future serialization of ops for remote rendering

Cons:
- Slightly clumsier API

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-04-27 22:19:34 +02:00
Elias Naur e0d586893d ui/app/internal/gpu: flush before drawing
And delete an unnecessary error check from Flush to make sure pending
draws are always finalized.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-04-25 10:01:58 +02:00
Elias Naur 48b6a73753 all: run goimports
gioui.org/ui was renamed from gioui.org/ui/ui before the release,
but the import order wasn't changed accordingly.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-04-02 17:09:06 +02:00
Elias Naur 0f05231c35 all: initial import
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-03-31 10:47:22 +02:00