Commit Graph

16 Commits

Author SHA1 Message Date
Elias Naur f1d971268e op/paint: guard against nil image in ImageOp.Size
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-11-07 21:08:01 +01:00
aarzilli 454b226404 op/paint: NewImageOp does not need to make copies of RGBA images
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-11-07 18:44:31 +01:00
Elias Naur 97299dc2f9 op/paint: make every ImageOp unique
The gioui.org/commit/74407a50d598bfd27e8f8e48b6832cc5df04de77
added a NewImageOp constructor that always copies the supplied
image. It does that for two reasons:

First, the image.Image reference is used in the image=>texture
map of cached textures. Without a copy, we wouldn't detect a
modified image even if a new ImageOp was created.

Second, we don't want the program to touch the image while the GPU
is uploading it.

The second reason was removed in a previous change that blocks
FrameEvent.Frame until we're done with the operations, including
uploading images to the GPU.

The first reason is easily fixed by using a unique per ImageOp,
as pointed out by Alessandro Arzilli.

This change switches to using the unique key. Alessandro's patch
avoids the copy when possible.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-11-07 18:27:06 +01:00
aarzilli 299e966816 op/paint: make documentation of Line clearer
The movement is not to an absolute coordinate but by a delta relative
to the current position of the pen.
2019-11-05 17:57:50 +01:00
Elias Naur 4da6c57d83 op: complete the MacroOp example
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-10-14 23:18:49 +02:00
Elias Naur fa00b53e13 op: change signature of Ops.Write
By returning the allocated data buffer, Ops can become an interface
in a future change without forcing operations to allocate.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-10-14 23:10:35 +02:00
Elias Naur 88208891de op/paint,app/internal/gpu: post-process paths during GPU upload
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-10-14 22:51:52 +02:00
Elias Naur d9100b506f op,op/paint: remove aux awareness from Ops
Aux data is now entirely confined to the writers (Path) and the
ops Reader parser.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-10-14 20:20:56 +02:00
Elias Naur 41eb3807f7 op: assume aux ops are always wrapped by a macro
Shaves off a length, and prepares for further simplification.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-10-14 20:02:14 +02:00
Elias Naur 74407a50d5 op/paint: add NewImageOp, unexport ImageOp fields
With public ImageOp fields there was no way to mark an image.Image as modified.
Replace them with NewImageOp that always make a copy, and use the opportunity
to ensure the copy is ready to upload to a GPU texture.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-10-14 18:06:50 +02:00
Elias Naur ef5cf5b724 op/paint: return ClipOp from Path.End
Instead of adding an implicit ClipOp, return a ClipOp ready to use, freeing the
caller from recording a macro.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-10-12 14:01:46 +02:00
Elias Naur 31e12607d7 op/paint: note that ImageOp caches image contents
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-10-03 19:26:37 +02:00
Elias Naur 6dad034b22 op/paint: rename PathBuilder to Path
There was no "Path" to "Build", so let's just use the simpler name.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-10-03 13:35:38 +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 beaec661d2 op/paint: move paint package below the op package
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