This thread contains a patchset. You're looking at the original emails, but you may wish to use the patch review UI. Review patch
2 2

[PATCH gio] f32: add Affine2D.Split

Message ID
DKIM signature
Download raw message
Patch: +11 -11
From: Egon Elbre <egonelbre@gmail.com>

splitTransform func was creating multiple copies of f32.Affine2D
due to not having access to the internal and passing around non-pointer.

This makes splitTransform from ~8ns to .Split ~2ns.

It seems that the non-pointer receiver was ~0.6ns slower in this case.

Signed-off-by: Egon Elbre <egonelbre@gmail.com>
 f32/affine.go |  9 +++++++++
 gpu/gpu.go    | 13 ++-----------
 2 files changed, 11 insertions(+), 11 deletions(-)

diff --git a/f32/affine.go b/f32/affine.go
index 667f7e98..b056f720 100644
--- a/f32/affine.go
+++ b/f32/affine.go
@@ -112,6 +112,15 @@ func (a Affine2D) Elems() (sx, hx, ox, hy, sy, oy float32) {
	return a.a + 1, a.b, a.c, a.d, a.e + 1, a.f

// Split a transform into two parts, one which is pure offset and the
// other representing the scaling, shearing and rotation part.
func (a *Affine2D) Split() (srs Affine2D, offset Point) {
	return Affine2D{
		a: a.a, b: a.b, c: 0,
		d: a.d, e: a.e, f: 0,
	}, Point{X: a.c, Y: a.f}

func (a Affine2D) scale(factor Point) Affine2D {
	return Affine2D{
		(a.a+1)*factor.X - 1, a.b * factor.X, a.c * factor.X,
diff --git a/gpu/gpu.go b/gpu/gpu.go
index 43300492..0977415b 100644
--- a/gpu/gpu.go
+++ b/gpu/gpu.go
@@ -821,15 +821,6 @@ func (d *drawOps) addClipPath(state *drawState, aux []byte, auxKey opKey, bounds
	state.cpath = npath

// split a transform into two parts, one which is pure offset and the
// other representing the scaling, shearing and rotation part
func splitTransform(t f32.Affine2D) (srs f32.Affine2D, offset f32.Point) {
	sx, hx, ox, hy, sy, oy := t.Elems()
	offset = f32.Point{X: ox, Y: oy}
	srs = f32.NewAffine2D(sx, hx, 0, hy, sy, 0)

func (d *drawOps) save(id int, state f32.Affine2D) {
	if extra := id - len(d.states) + 1; extra > 0 {
		d.states = append(d.states, make([]f32.Affine2D, extra)...)
@@ -889,7 +880,7 @@ loop:
			quads.key.outline = op.Outline
			bounds := f32.FRect(op.Bounds)
			trans, off := splitTransform(state.t)
			trans, off := state.t.Split()
			if len(quads.aux) > 0 {
				// There is a clipping path, build the gpu data and update the
				// cache key such that it will be equal only if the transform is the
@@ -935,7 +926,7 @@ loop:
			// Transform (if needed) the painting rectangle and if so generate a clip path,
			// for those cases also compute a partialTrans that maps texture coordinates between
			// the new bounding rectangle and the transformed original paint rectangle.
			t, off := splitTransform(state.t)
			t, off := state.t.Split()
			// Fill the clip area, unless the material is a (bounded) image.
			// TODO: Find a tighter bound.
			inf := float32(1e6)

[gio/patches] build success

builds.sr.ht <builds@sr.ht>
Message ID
<165670411394.9481.6852430348140552717-0@git.sr.ht> (view parent)
DKIM signature
Download raw message
gio/patches: SUCCESS in 21m13s

[f32: add Affine2D.Split][0] from [~egonelbre][1]

[0]: https://lists.sr.ht/~eliasnaur/gio-patches/patches/33469
[1]: egonelbre@gmail.com

✓ #792346 SUCCESS gio/patches/linux.yml   https://builds.sr.ht/~eliasnaur/job/792346
✓ #792345 SUCCESS gio/patches/freebsd.yml https://builds.sr.ht/~eliasnaur/job/792345
✓ #792347 SUCCESS gio/patches/openbsd.yml https://builds.sr.ht/~eliasnaur/job/792347
✓ #792344 SUCCESS gio/patches/apple.yml   https://builds.sr.ht/~eliasnaur/job/792344
Message ID
<165670411394.9481.6852430348140552717-0@git.sr.ht> (view parent)
DKIM signature
Download raw message
Thanks, merged.

Reply to thread Export thread (mbox)