Commit Graph

1719 Commits

Author SHA1 Message Date
Elias Naur bfe2d04c60 gpu,app,internal/glimpl: update GL backend for the compute renderer
Modern graphics APIs have immutable objects, with mutable data. For example,
a texture's dimensions are immutable, while the texture contents is not.
Change the GPU API abstraction to match.

Clearing a Texture is convenient to do with a plain []byte. Generalize
Texture.Upload to take a plain byte slice and introduce a helper function for
uploading *image.RGBA data.

Add TextureFormatRGBA8 a format for the linear RGB colorspace.

Add OpenGL ES 3.1 functions for compute programs.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-12-31 17:21:35 +01:00
Elias Naur 7d24b790a2 gpu: add and track fields needed by the compute renderer
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-12-31 17:21:35 +01:00
Elias Naur 0a56609769 gpu: update definition of path vertex size
The size is unchanged, but a corner is no longer encoded as two
16-bit ints (2*2 bytes); it is encoded as a float32 (1*4 bytes).

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-12-31 17:21:35 +01:00
Elias Naur e012c3f393 internal/glimpl: [wasm] pass correctly sized buffers to WebGL functions
Before this change, the entire byte buffer would be passed to WebGL, even
though its size may be (much) larger than the source data.
Remakably, this hasn't resulted in any problems until the use of
glBufferSubData, which require the passed data fits the buffer size.

As a bonus, this fix should speed up the wasm port by virtue of passing
much less data across the wasm<->js barrier.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-12-31 12:31:57 +01:00
Elias Naur 7b1783056f app/internal/window: fix iOS context creation
NewBackend was recently changed to take a context, which must only
be specified on GOOS=js.

Fixes gio#189

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-12-30 18:38:21 +01:00
pierre 33103593a1 layout: updated comment, avoid copying whole context in Flex
Signed-off-by: pierre <pierre.curto@gmail.com>
2020-12-29 01:00:53 +01:00
pierre 0416fffc09 layout.List: store constraints instead of whole context
Signed-off-by: pierre <pierre.curto@gmail.com>
2020-12-24 12:38:56 +01:00
pierre d942b5c4d0 layout.List: reduce allocations when scrolling backward
Signed-off-by: pierre <pierre.curto@gmail.com>
2020-12-24 12:38:56 +01:00
pierre 8a148ad6a1 widget/material: updated Switch comments.
Signed-off-by: pierre <pierre.curto@gmail.com>
2020-12-23 00:36:25 +01:00
Chris Waldon 18d4dbf60c layout: document how Inset modifies constraints
Signed-off-by: Chris Waldon <christopher.waldon.dev@gmail.com>
2020-12-20 10:04:21 +01:00
Elias Naur 00c4a53036 gpu: move path cache updates into drawOps.collect
The new compute backend shares drawOps but not GPU.Collect. This
change moves the common path cache code to drawOps.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-12-19 15:43:51 +01:00
Elias Naur 7adc2a884b all: go mod tidy
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-12-19 11:41:24 +01:00
Inkeliz 449dda2eb3 app/internal/window: [wasm] add support for insets and cache window-size
Currently, on iOS, the keyboard can block the content since it doesn't
trigger the "resize". Now, the `insets` will provide the size of the
keyboard (on iOS) and scrollbars. It's compatible with the Android (and
desktop), but Chrome automatic resizes the windows, so the `Inset` will
be 0.

Signed-off-by: Inkeliz <inkeliz@inkeliz.com>
2020-12-19 10:32:56 +01:00
Elias Naur 40c082e949 app/internal/window: use defer for cleanup function
Avoids a vet warning about unreachable code: currently, the cleanup
function is never reached.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-12-18 10:18:21 +01:00
Inkeliz c2a66a5481 app/internal/window: fix support for Safari 11.1
Signed-off-by: Inkeliz <inkeliz@inkeliz.com>
2020-12-18 10:02:54 +01:00
Elias Naur 74cee277ca .builds: clarify missing sign-off error message
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-12-17 21:35:18 +01:00
Elias Naur cb075ea9cf app/headless,internal/rendertest: relax tests
The Mesa software OpenGL implementation strays enough from the
reference values that tests fail. Relax the tests to make them
pass again.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-12-17 20:48:30 +01:00
Elias Naur e0a8202aa0 .builds: enable headless OpenGL tests on linux
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-12-17 20:35:28 +01:00
Elias Naur fac1d00c89 app/internal/egl: support EGL_KHR_no_config_context
The mesa surfaceless renderer doesn't support configs, but does
support EGL_KHR_no_config_context so no config is required. Don't
fail context creation in this setup.

With this change, the headless tests work on a headless linux with the
EGL_PLATFORM environment variable set to "surfaceless".

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-12-17 20:31:04 +01:00
Walter Werner SCHNEIDER fd2d96adfc all: fix spelling errors
Signed-off-by: Walter Werner SCHNEIDER <contact@schnwalter.eu>
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-12-17 08:55:23 +01:00
Walter Werner SCHNEIDER 83d23ab507 all: sort and group imports
Signed-off-by: Walter Werner SCHNEIDER <contact@schnwalter.eu>
2020-12-17 08:55:09 +01:00
Egon Elbre e383e6d6be widget/material: better disabled color calculation
Use desaturation in combination with alpha multiplication.

Signed-off-by: Egon Elbre <egonelbre@gmail.com>
2020-12-16 19:15:17 +01:00
Robin Eklind 9cc90d9695 cmd/gogio: sort and group imports using goimports
find gio/ -type f -name '*.go' | xargs -I '{}' goimports -w '{}'

Signed-off-by: Robin Eklind
2020-12-16 02:09:44 +01:00
Robin Eklind f3ce6ad29a app/internal/window: fix golint issues
app/internal/window/os_wayland.go:1448:12: gioui.org/io/system.StageEvent composite literal uses unkeyed fields
	app/internal/window/os_x11.go:183:12: gioui.org/io/system.StageEvent composite literal uses unkeyed fields

Signed-off-by: Robin Eklind
2020-12-16 02:09:39 +01:00
pierre 578c226278 io/pointer: CursorNameOp no longer needs an InputOp with Leave and Enter events
Signed-off-by: pierre <pierre.curto@gmail.com>
2020-12-15 18:11:48 +01:00
pierre 36b9019649 widget: added example for Clickable
Signed-off-by: pierre <pierre.curto@gmail.com>
2020-12-15 13:39:18 +01:00
Chris Waldon eb719eaa54 ci: configure automatic mirroring to GitHub
Signed-off-by: Chris Waldon <christopher.waldon.dev@gmail.com>
2020-12-14 23:56:54 +01:00
Elias Naur 5839e3e8d5 app/internal/window: don't use C.BOOL
Apparently, darwin/arm64 cgo doesn't match the types of YES and BOOL:

os_macos.go:235:40: cannot use _Ciconst_YES (type untyped int) as type _Ctype__Bool

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-12-14 23:40:29 +01:00
Elias Naur f3ab8d6368 README.md: change GitHub mirror location
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-12-14 23:29:14 +01:00
Inkeliz fe844cc489 cmd/gogio: fix support for older browsers
That change removes the "??" operator, it isn't supported
by old browsers [0].

[0]: https://caniuse.com/mdn-javascript_operators_nullish_coalescing

Signed-off-by: Inkeliz <inkeliz@inkeliz.com>
2020-12-14 16:33:56 +01:00
Egon Elbre 296303210f widget/material: remove padding from Slider
Remove padding from the sides of the Slider to align them with
other components.

However, since sliders still need to be used with fingers try to
enforce a minimum finger height, if there is sufficient room.
The sides don't need similar treatment since after grabbing it's
possible to move the finger beyond the touch area, without losing
interaction.

To not enforce finger size, the theme can be adjusted:

    theme.FingerSize = unit.Px(0)

Signed-off-by: Egon Elbre <egonelbre@gmail.com>
2020-12-14 15:56:56 +01:00
Sebastien Binet 8e7066ecd7 font/opentype: fix typo
Signed-off-by: Sebastien Binet <s@sbinet.org>
2020-12-14 15:52:39 +01:00
Inkeliz 745bb949bb cmd/gogio: [wasm] embed .js files
Similar to the Android, which includes all .jar files into the .apk.
Now, the `gogio -target js` will include all `*_js.js` files
into the resulting `wasm.js`.

That change make possible to adds custom wasm-imports, which might
be used in future versions of Gio.

Signed-off-by: Inkeliz <inkeliz@inkeliz.com>
2020-12-11 20:24:34 +01:00
Inkeliz 0dfb04eb2d app/internal/window: [windows] add icon support
That change adds the icon to the "window navbar".

Signed-off-by: Inkeliz <inkeliz@inkeliz.com>
2020-12-11 20:24:33 +01:00
Egon Elbre bd7bb4d5d2 widget/material: use float32 for progress
Signed-off-by: Egon Elbre <egonelbre@gmail.com>
2020-12-11 18:28:59 +01:00
Inkeliz fa96e12b6d cmd/gogio: add support for Windows
Now, gogio can build the program for Windows, using the `-target
windows`.

It will build with `-H=windowsgui`, by default. Also, it can compile for
multiple platforms if specified using `-target` (e.g. `-target arm, 386,
amd64`), the executable will have the respective suffix (i.e.
`_386.exe`).

gogio will also attach (any) appicon.png as executable icon resource and
include some information about the file and supported operating system.

Signed-off-by: Inkeliz <inkeliz@inkeliz.com>
2020-12-11 17:00:21 +01:00
Egon Elbre 0b2a2d6c2e {gesture,widget}: expose Dragging
Knowing whether a widget is being interacted with allows to implement
bi-directional updates without feedbacks.

Signed-off-by: Egon Elbre <egonelbre@gmail.com>
2020-12-11 16:44:22 +01:00
Inkeliz b79c2dec79 app/internal/window: [wasm] fix on-screen-keyboard
Previously, the keyboard is open by default, even without any focus.
Now, the keyboard will remain closed, until `.focus()` is called. That
change also prevents the keyboard from reopening immediately after blur.

Signed-off-by: Inkeliz <inkeliz@inkeliz.com>
2020-12-11 16:43:31 +01:00
Elias Naur 5a51f40cf7 LICENSE: tighten license language
"provided under terms" is a better match to the UNLICENSE, which puts
the project in the public domain the fullest extent possible.

This is a wording update, not a change in licesing terms.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-12-11 16:42:04 +01:00
Elias Naur 2dce8a0155 internal/unsafe: fix vet warnings about SliceHeader use
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-12-10 18:33:02 +01:00
Egon Elbre 679bf092cb layout: add Spacer
Signed-off-by: Egon Elbre <egonelbre@gmail.com>
2020-12-09 17:41:49 +01:00
Sebastien Binet e71bf13c9a gpu,op/clip: implement dashed stroked paths
Signed-off-by: Sebastien Binet <s@sbinet.org>
2020-12-09 11:23:13 +01:00
Elias Naur ac14320bec example: delete
Examples now live in the https://git.sr.ht/~eliasnaur/gio-example
repository.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-12-09 10:39:30 +01:00
Sebastien Binet be89f8b945 all: introduce Outline and Stroke builders
This CL introduces 2 new path builders:
- Outline which takes a PathSpec to be outlined
- Stroke which takes a PathSpec and a stroke style, to stroke a path.

typically, code like this:

  var p clip.Path
  ...
  p.Outline().Add(o)

should be replaced with:

  var p clip.Path
  ...
  clip.Outline{Path: p.End()}.Op().Add(o)

similarly, stroking should be modified from:

  var p clip.Path
  ...
  p.Stroke(width, clip.StrokeStyle{...}).Add(o)

to:

  var p clip.Path
  ...
  clip.Stroke{Path: p.End(), Style: clip.StrokeStyle{Width:...}}.Op().Add(o)

here are tentative 'rf' scripts (see rsc.io/rf for more details):

  ```
  ex {
  	import "gioui.org/op";
  	import "gioui.org/op/clip";

  	var p clip.Path;
  	var o *op.Ops;

  	p.Outline().Add(o) -> clip.Outline{Path:p.End()}.Op().Add(o);
  }

  ex {
  	import "gioui.org/op";
  	import "gioui.org/op/clip";

  	var o *op.Ops;
  	var p clip.Path;
  	var sty clip.StrokeStyle;
  	var width float32;

  	p.Stroke(width, sty).Add(o) ->   \
	    clip.Stroke{                 \
		Path:p.End(),            \
		Style: clip.StrokeStyle{ \
		    Width: width,        \
	    }}.Op().Add(o);
  }
  ```

Signed-off-by: Sebastien Binet <s@sbinet.org>
2020-12-09 09:44:15 +01:00
pierre 7c5bcd3db8 io/pointer: added CursorNameOp
The cursor can now be customized for a given area.

Signed-off-by: pierre <pierre.curto@gmail.com>
2020-12-09 09:38:31 +01:00
Egon Elbre 675e86b8e8 internal/unsafe: fix empty slice
Signed-off-by: Egon Elbre <egonelbre@gmail.com>
2020-12-09 09:36:07 +01:00
Elias Naur b456e987f7 .builds: prepare for splitting out examples in separate repository
The example module is moving to git.sr.ht/~eliasnaur/gio-example.
We still need some main package for testing gogio, so update reference
to use the module path (gioui.org/example).

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-12-08 19:40:57 +01:00
Chris Waldon acc3f704e4 example/{kitchen,tabs,gophers}: update to use material.Palette
Update gioui.org/cmd while here.

Signed-off-by: Chris Waldon <christopher.waldon.dev@gmail.com>
2020-12-06 23:04:52 +01:00
Chris Waldon a87a520ae8 widget/material: manage widget colors with Palette type
This introduces a new material.Palette type that captures the color information
necessary to render a widget. This type is embedded in the material.Theme to
make it easier to swap to a different palette for part of the UI by reassinging
the Palette field.

Signed-off-by: Chris Waldon <christopher.waldon.dev@gmail.com>
2020-12-06 23:02:30 +01:00
Elias Naur 47ba975899 example,cmd: bump gio version
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-12-06 22:59:51 +01:00