skia2/gm/bug530095.cpp
robertphillips 7f229ed827 Revert of don't create zero length intervals (patchset #1 id:1 of https://codereview.chromium.org/1766243004/ )
Reason for revert:
This may, or may not, be blocking the DEPS roll with:

svg/W3C-SVG-1.1/painting-stroke-04-t.svg

-      LayoutSVGPath {path} at (50,127) size 380x26 [stroke={[type=SOLID] [color=#000000] [stroke width=25.00] [dash offset=10.00] [dash array={10.00, 10.00}]}] [data="M 50 140 L 430 140"]
+      LayoutSVGPath {path} at (60,127) size 370x26 [stroke={[type=SOLID] [color=#000000] [stroke width=25.00] [dash offset=10.00] [dash array={10.00, 10.00}]}] [data="M 50 140 L 430 140"]

Original issue's description:
> don't create zero length intervals
>
> Dashing a pattern without zero-length intervals should
> not create them if the end of the on interval coincides
> with the beginning of the initial dash offset.
>
> R=reed@google.com
> BUG=591993
> GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1766243004
>
> Committed: https://skia.googlesource.com/skia/+/18bbd00190623fb6cdb119df4a118ac3c1aed52a

TBR=reed@google.com,fmalita@chromium.org,caryclark@google.com
# Skipping CQ checks because original CL landed less than 1 days ago.
NOPRESUBMIT=true
NOTREECHECKS=true
NOTRY=true
BUG=591993

Review URL: https://codereview.chromium.org/1779803002
2016-03-09 08:37:23 -08:00

49 lines
1.5 KiB
C++

/*
* Copyright 2016 Google Inc.
*
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
#include "gm.h"
#include "SkPath.h"
#include "SkDashPathEffect.h"
DEF_SIMPLE_GM(bug530095, canvas, 900, 1200) {
SkPath path1, path2;
path1.addCircle(200, 200, 124);
path2.addCircle(2, 2, 1.24f);
SkPaint paint;
paint.setAntiAlias(true);
paint.setStyle(SkPaint::kStroke_Style);
paint.setStrokeWidth(26);
SkScalar intervals[] = {700, 700 };
int intervalCount = (int) SK_ARRAY_COUNT(intervals);
paint.setPathEffect(SkDashPathEffect::Create(intervals, intervalCount, -40))->unref();
canvas->drawPath(path1, paint);
paint.setStrokeWidth(0.26f);
SkScalar smIntervals[] = {7, 7 };
int smIntervalCount = (int) SK_ARRAY_COUNT(smIntervals);
paint.setPathEffect(SkDashPathEffect::Create(smIntervals, smIntervalCount, -0.40f))->unref();
canvas->save();
canvas->scale(100, 100);
canvas->translate(4, 0);
canvas->drawPath(path2, paint);
canvas->restore();
paint.setStrokeWidth(26);
paint.setPathEffect(SkDashPathEffect::Create(intervals, intervalCount, 0))->unref();
canvas->save();
canvas->translate(0, 400);
canvas->drawPath(path1, paint);
canvas->restore();
paint.setStrokeWidth(0.26f);
paint.setPathEffect(SkDashPathEffect::Create(smIntervals, smIntervalCount, 0))->unref();
canvas->scale(100, 100);
canvas->translate(4, 4);
canvas->drawPath(path2, paint);
}