From 7bad76ad759e64e8b5d9cdbcfb9eedcd71f33ff0 Mon Sep 17 00:00:00 2001 From: Egon Elbre Date: Tue, 24 Nov 2020 14:38:01 +0100 Subject: [PATCH] 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 corners. Signed-off-by: Egon Elbre --- op/clip/clip.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/op/clip/clip.go b/op/clip/clip.go index 2cd9caf1..405a4600 100644 --- a/op/clip/clip.go +++ b/op/clip/clip.go @@ -251,6 +251,9 @@ func (p *Path) arc(alpha float64, c f32.Point, rx, ry, beg, delta float64) { // Cube records a cubic Bézier from the pen through // two control points ending in to. func (p *Path) Cube(ctrl0, ctrl1, to f32.Point) { + if ctrl0 == (f32.Point{}) && ctrl1 == (f32.Point{}) && to == (f32.Point{}) { + return + } ctrl0 = ctrl0.Add(p.pen) ctrl1 = ctrl1.Add(p.pen) to = to.Add(p.pen)