Reland of ix zero-length tangent (patchset #1 id:1 of https://codereview.chromium.org/1312243002/ )
Reason for revert:
Layout suppression has landed, and verified that Skia gm test changes are correct.
Original issue's description:
> Revert of fix zero-length tangent (patchset #2 id:20001 of https://codereview.chromium.org/1311273002/ )
>
> Reason for revert:
> causes layout test to draw differently -- new drawing is more correct. Reverting until layout test ignore is landed.
>
> Original issue's description:
> > fix zero-length tangent
> >
> > If the end point and the control point are the same, computing
> > the tangent will result in (0, 0). In this case, use the prior
> > control point instead.
> >
> > R=reed@google.com
> >
> > BUG=skia:4191
> >
> > Committed: https://skia.googlesource.com/skia/+/7544124fb8ee744f68f549a353f8a9163cd7432d
>
> TBR=reed@google.com
> NOPRESUBMIT=true
> NOTREECHECKS=true
> NOTRY=true
> BUG=skia:4191
>
> Committed: https://skia.googlesource.com/skia/+/91298b47c547b2ab4697038c04685af957bd1416
TBR=reed@google.com
NOPRESUBMIT=true
NOTREECHECKS=true
NOTRY=true
BUG=skia:4191
Review URL: https://codereview.chromium.org/1320473002
diff --git a/gm/strokes.cpp b/gm/strokes.cpp
index 7382390..0bcb039 100644
--- a/gm/strokes.cpp
+++ b/gm/strokes.cpp
@@ -266,6 +266,60 @@
typedef skiagm::GM INHERITED;
};
+// Test stroking for curves that produce degenerate tangents when t is 0 or 1 (see bug 4191)
+class Strokes5GM : public skiagm::GM {
+public:
+ Strokes5GM() {}
+
+protected:
+
+ SkString onShortName() override {
+ return SkString("zero_control_stroke");
+ }
+
+ SkISize onISize() override {
+ return SkISize::Make(W, H*2);
+ }
+
+ void onDraw(SkCanvas* canvas) override {
+ SkPaint p;
+ p.setColor(SK_ColorRED);
+ p.setAntiAlias(true);
+ p.setStyle(SkPaint::kStroke_Style);
+ p.setStrokeWidth(40);
+ p.setStrokeCap(SkPaint::kButt_Cap);
+
+ SkPath path;
+ path.moveTo(157.474f,111.753f);
+ path.cubicTo(128.5f,111.5f,35.5f,29.5f,35.5f,29.5f);
+ canvas->drawPath(path, p);
+ path.reset();
+ path.moveTo(250, 50);
+ path.quadTo(280, 80, 280, 80);
+ canvas->drawPath(path, p);
+ path.reset();
+ path.moveTo(150, 50);
+ path.conicTo(180, 80, 180, 80, 0.707f);
+ canvas->drawPath(path, p);
+
+ path.reset();
+ path.moveTo(157.474f,311.753f);
+ path.cubicTo(157.474f,311.753f,85.5f,229.5f,35.5f,229.5f);
+ canvas->drawPath(path, p);
+ path.reset();
+ path.moveTo(280, 250);
+ path.quadTo(280, 250, 310, 280);
+ canvas->drawPath(path, p);
+ path.reset();
+ path.moveTo(180, 250);
+ path.conicTo(180, 250, 210, 280, 0.707f);
+ canvas->drawPath(path, p);
+ }
+
+private:
+ typedef skiagm::GM INHERITED;
+};
+
//////////////////////////////////////////////////////////////////////////////
@@ -273,8 +327,10 @@
static skiagm::GM* F1(void*) { return new Strokes2GM; }
static skiagm::GM* F2(void*) { return new Strokes3GM; }
static skiagm::GM* F3(void*) { return new Strokes4GM; }
+static skiagm::GM* F4(void*) { return new Strokes5GM; }
static skiagm::GMRegistry R0(F0);
static skiagm::GMRegistry R1(F1);
static skiagm::GMRegistry R2(F2);
static skiagm::GMRegistry R3(F3);
+static skiagm::GMRegistry R4(F4);