gio/op/clip/clip.go -rw-r--r-- 9.8 KiB
op/clip: handle zero Cube

Currently this comes up with RRect/Border that has zero corners. It
improves them from ~250ns to ~170ns. While it's possible to check this
in RRect implementation, however it'll slow down calls with non-zero

Signed-off-by: Egon Elbre <egonelbre@gmail.com>
op/clip: expose LineTo and QuadTo

Using delta position with Line and Quad can drift over successive calls.
Also, in some cases it's much more convenient to use absolute
coordinates rather than relative.

Signed-off-by: Egon Elbre <egonelbre@gmail.com>
gpu,op/clip: implement stroked paths with miter joins

Signed-off-by: Sebastien Binet <s@sbinet.org>
gpu,op/clip: implement stroked paths with round joins

Signed-off-by: Sebastien Binet <s@sbinet.org>
op/clip: use stroked path to draw Border

Signed-off-by: Sebastien Binet <s@sbinet.org>
gpu,op/clip: implement stroked paths

Flat and Square caps are implemented.
Bevel joins are implemented.

Round caps, Round joins and Miter joins are left for another PR.

Signed-off-by: Sebastien Binet <s@sbinet.org>
all: rename clip.Path.End into clip.Path.Outline

Signed-off-by: Sebastien Binet <s@sbinet.org>
op/clip: remove unused parameter from Rect.Op

Signed-off-by: Elias Naur <mail@eliasnaur.com>
op/clip: export Op method of clip shapes

This allows passing the resulting clip.Op types into functions that
draw shapes.

Signed-off-by: Chris Waldon <christopher.waldon.dev@gmail.com>
op/clip: smoother implementation of Arc for large angles

Signed-off-by: Sebastien Binet <s@sbinet.org>
op/clip: export Path's current pen position

Signed-off-by: Sebastien Binet <s@sbinet.org>
op/clip: implement arc path

Signed-off-by: Sebastien Binet <s@sbinet.org>
op/clip: split Rect into pixel-aligned Rect and rounded RRect

The pixel-aligned Rect is more efficient and easier to use in the common case
of layout clipping.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
op/clip: unexport Rect.Op

It wasn't used anywhere outside Rect.Add.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
op/clip, gpu: split complex curves in package gpu instead

This is a first step towards supporting affine drawing transforms.
The rendering algorithm relies on quadratic curves that do not cross
x = 0 more than once, thus curves must be split after any rotation/shear
transforms. Move this logic and the generation of vertices to package gpu.
Also close all curves and draw zero-width edges as preparation for
transform since the will no longer implicitly be vertical with no

This commit will severely affect performance since vertexes are now
transformed also for cached items, using cpu resources.

Signed-off-by: Viktor <viktor.ogeman@gmail.com>
op: change CallOp to be a return value from MacroOp.Stop


	macro := op.Record(ops)



	macro := op.Record(ops)
	call := macro.Stop()


Which is more general (call.Add can take a different ops than the op.Record
that started it), and enforced the order between Stop and the subsequent Add.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
ae8a377c — Thomas Bruyelle 5 months ago
op: add op.Push and op.Record funcs

The funcs replace stack.Push and macro.Record, which become private.
This makes stack and macro faster to write, in particular for stacks
where you can just write the following line to save and restore the
state :

  defer op.Push(ops).Pop()

This usage requires Push to return a pointer (since Pop has a pointer
receiver), or else the code doesn't compile.

For consistancy, I tried to do the same for op.Record, but this implied
to turn all the MacroOp fields into pointers, and this caused some
panics. As a result, op.Record doesn't return a pointer.

An other side effect pointed by Larry Clapp: StackOp and MacroOp are not
re-usable any more, you have to allocate a new one for each usage, using
the described funcs above.

Signed-off-by: Thomas Bruyelle <thomas.bruyelle@gmail.com>
op/clip: add Rect.Add shorthand

Signed-off-by: Elias Naur <mail@eliasnaur.com>
all: use new rectangle and point convenience functions

Signed-off-by: Elias Naur <mail@eliasnaur.com>
gpu: drop use of integer shader inputs

They're a pain to support. Encode the single integer value we have
as a float instead.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
op: remove operation list argument from MacroOp.Add

The ability to invoke other operation lists belongs in the new CallOp.

While we're here, make MacroOp.Add use a pointer receiver to match the
other methods.

Signed-off-by: Elias Naur <mail@eliasnaur.com>