From 9cb9e67a8e0851a8634e8eb47c42791e6e275b55 Mon Sep 17 00:00:00 2001 From: Egon Elbre Date: Sun, 14 Mar 2021 12:17:04 +0200 Subject: [PATCH] op/clip: remove Border Border can be expressed in-terms of clip.Stroke: clip.Stroke{ Path: clip.UniformRRect(r, rr).Ops(ops), Style: clip.StrokeStyle{Width: width}, }.Add(ops) Signed-off-by: Egon Elbre --- gpu/internal/rendertest/clip_test.go | 23 -------------------- op/clip/shapes.go | 32 ---------------------------- 2 files changed, 55 deletions(-) diff --git a/gpu/internal/rendertest/clip_test.go b/gpu/internal/rendertest/clip_test.go index a4298445..a2fcb768 100644 --- a/gpu/internal/rendertest/clip_test.go +++ b/gpu/internal/rendertest/clip_test.go @@ -37,29 +37,6 @@ func TestPaintClippedRect(t *testing.T) { }) } -func TestPaintClippedBorder(t *testing.T) { - t.Skipf("doesn't render round-capped, round-joined dashes correctly") - run(t, func(o *op.Ops) { - var dashes clip.Dash - dashes.Begin(o) - dashes.Phase(1) - dashes.Dash(2) - dashes.Dash(1) - - clip.Border{ - Rect: f32.Rect(25, 25, 60, 60), - Width: 4, - Dashes: dashes.End(), - }.Add(o) - paint.FillShape(o, red, clip.Rect(image.Rect(0, 0, 50, 50)).Op()) - }, func(r result) { - r.expect(0, 0, colornames.White) - r.expect(25, 25, colornames.Red) - r.expect(50, 0, colornames.White) - r.expect(10, 50, colornames.White) - }) -} - func TestPaintClippedCircle(t *testing.T) { run(t, func(o *op.Ops) { r := float32(10) diff --git a/op/clip/shapes.go b/op/clip/shapes.go index 53b8fd55..c1a1d599 100644 --- a/op/clip/shapes.go +++ b/op/clip/shapes.go @@ -96,38 +96,6 @@ func (rr RRect) Path(ops *op.Ops) PathSpec { return p.End() } -// Border represents a rectangular border. -type Border struct { - // Rect is the bounds of the border. - Rect f32.Rectangle - // Width of the line tracing Rect. - Width float32 - Dashes DashSpec - // The corner radii. - SE, SW, NW, NE float32 -} - -// Op returns the clip operation for the border. Its area corresponds to a -// stroked line that traces the border rectangle, optionally with rounded -// corners and dashes. -func (b Border) Op(ops *op.Ops) Op { - return Stroke{ - Path: RRect{ - Rect: b.Rect, - SE: b.SE, SW: b.SW, NW: b.NW, NE: b.NE, - }.Path(ops), - Style: StrokeStyle{ - Width: b.Width, - }, - Dashes: b.Dashes, - }.Op() -} - -// Add the border clip. -func (rr Border) Add(ops *op.Ops) { - rr.Op(ops).Add(ops) -} - // Circle represents the clip area of a circle. type Circle struct { Center f32.Point