aboutsummaryrefslogtreecommitdiffhomepage
path: root/gm
diff options
context:
space:
mode:
authorGravatar reed <reed@google.com>2016-03-18 11:22:57 -0700
committerGravatar Commit bot <commit-bot@chromium.org>2016-03-18 11:22:57 -0700
commita439334b6e758d38501e225e2e5d0ab73e2fb6eb (patch)
tree8f2919ed2f6dcae5c4d5dbaaf608b5c6d248f2fc /gm
parent0be9e806af72b3e029e691eef5c891c90d3fd320 (diff)
Reland of "switch patheffects over to sk_sp (patchset #5 id:80001 of https://codereview.chromium.org/1813553005/ )"
Diffstat (limited to 'gm')
-rw-r--r--gm/arcto.cpp2
-rw-r--r--gm/bug530095.cpp13
-rw-r--r--gm/dashcircle.cpp2
-rw-r--r--gm/dashcubics.cpp34
-rw-r--r--gm/dashing.cpp13
-rw-r--r--gm/pathcontourstart.cpp5
-rw-r--r--gm/patheffects.cpp24
-rw-r--r--gm/strokes.cpp2
-rw-r--r--gm/stroketext.cpp2
-rw-r--r--gm/textbloblooper.cpp6
-rw-r--r--gm/texteffects.cpp12
11 files changed, 53 insertions, 62 deletions
diff --git a/gm/arcto.cpp b/gm/arcto.cpp
index 584fca3c4f..fcbc3d5926 100644
--- a/gm/arcto.cpp
+++ b/gm/arcto.cpp
@@ -223,6 +223,6 @@ DEF_SIMPLE_GM(bug583299, canvas, 300, 300) {
SkScalar length = meas.getLength();
SkScalar intervals[] = {0, length };
int intervalCount = (int) SK_ARRAY_COUNT(intervals);
- p.setPathEffect(SkDashPathEffect::Create(intervals, intervalCount, 0))->unref();
+ p.setPathEffect(SkDashPathEffect::Make(intervals, intervalCount, 0));
canvas->drawPath(path, p);
}
diff --git a/gm/bug530095.cpp b/gm/bug530095.cpp
index 76f6bc8f2e..fa88c01b8f 100644
--- a/gm/bug530095.cpp
+++ b/gm/bug530095.cpp
@@ -20,13 +20,13 @@ DEF_SIMPLE_GM(bug530095, canvas, 900, 1200) {
paint.setStrokeWidth(26);
SkScalar intervals[] = {700, 700 };
int intervalCount = (int) SK_ARRAY_COUNT(intervals);
- paint.setPathEffect(SkDashPathEffect::Create(intervals, intervalCount, -40))->unref();
+ paint.setPathEffect(SkDashPathEffect::Make(intervals, intervalCount, -40));
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();
+ paint.setPathEffect(SkDashPathEffect::Make(smIntervals, smIntervalCount, -0.40f));
canvas->save();
canvas->scale(100, 100);
canvas->translate(4, 0);
@@ -34,14 +34,14 @@ DEF_SIMPLE_GM(bug530095, canvas, 900, 1200) {
canvas->restore();
paint.setStrokeWidth(26);
- paint.setPathEffect(SkDashPathEffect::Create(intervals, intervalCount, 0))->unref();
+ paint.setPathEffect(SkDashPathEffect::Make(intervals, intervalCount, 0));
canvas->save();
canvas->translate(0, 400);
canvas->drawPath(path1, paint);
canvas->restore();
paint.setStrokeWidth(0.26f);
- paint.setPathEffect(SkDashPathEffect::Create(smIntervals, smIntervalCount, 0))->unref();
+ paint.setPathEffect(SkDashPathEffect::Make(smIntervals, smIntervalCount, 0));
canvas->scale(100, 100);
canvas->translate(4, 4);
canvas->drawPath(path2, paint);
@@ -54,8 +54,7 @@ DEF_SIMPLE_GM(bug591993, canvas, 40, 140) {
p.setStyle(SkPaint::kStroke_Style);
p.setStrokeCap(SkPaint::kRound_Cap);
p.setStrokeWidth(10);
- SkScalar intervals[] = { 100, 100 };
- SkPathEffect* dash = SkDashPathEffect::Create(intervals, SK_ARRAY_COUNT(intervals), 100);
- p.setPathEffect(dash)->unref();
+ const SkScalar intervals[] = { 100, 100 };
+ p.setPathEffect(SkDashPathEffect::Make(intervals, SK_ARRAY_COUNT(intervals), 100));
canvas->drawLine(20, 20, 120, 20, p);
}
diff --git a/gm/dashcircle.cpp b/gm/dashcircle.cpp
index cddd913723..a02c7d0f7b 100644
--- a/gm/dashcircle.cpp
+++ b/gm/dashcircle.cpp
@@ -68,7 +68,7 @@ DEF_SIMPLE_GM(dashcircle, canvas, 900, 1200) {
for (int index = 0; index < dashExample.length; ++index) {
intervals[index] = dashExample.pattern[index] * dashLength;
}
- p.setPathEffect(SkDashPathEffect::Create(intervals, intervalCount, 0))->unref();
+ p.setPathEffect(SkDashPathEffect::Make(intervals, intervalCount, 0));
canvas->drawPath(circle, p);
canvas->translate(0, radius * 2 + 50);
}
diff --git a/gm/dashcubics.cpp b/gm/dashcubics.cpp
index 1773303f0c..7736f2b47c 100644
--- a/gm/dashcubics.cpp
+++ b/gm/dashcubics.cpp
@@ -14,26 +14,24 @@
/*
* Inspired by http://code.google.com/p/chromium/issues/detail?id=112145
*/
-static void flower(SkCanvas* canvas, const SkPath& path,
- SkScalar intervals[2], SkPaint::Join join) {
- SkPathEffect* pe = SkDashPathEffect::Create(intervals, 2, 0);
+static void flower(SkCanvas* canvas, const SkPath& path, SkScalar intervals[2],
+ SkPaint::Join join) {
+ SkPaint paint;
+ paint.setAntiAlias(true);
+ paint.setStyle(SkPaint::kStroke_Style);
+ paint.setStrokeJoin(join);
+ paint.setStrokeWidth(42);
+ canvas->drawPath(path, paint);
- SkPaint paint;
- paint.setAntiAlias(true);
- paint.setStyle(SkPaint::kStroke_Style);
- paint.setStrokeJoin(join);
- paint.setStrokeWidth(42);
- canvas->drawPath(path, paint);
+ paint.setColor(SK_ColorRED);
+ paint.setStrokeWidth(21);
+ paint.setPathEffect(SkDashPathEffect::Make(intervals, 2, 0));
+ canvas->drawPath(path, paint);
- paint.setColor(SK_ColorRED);
- paint.setStrokeWidth(21);
- paint.setPathEffect(pe)->unref();
- canvas->drawPath(path, paint);
-
- paint.setColor(SK_ColorGREEN);
- paint.setPathEffect(nullptr);
- paint.setStrokeWidth(0);
- canvas->drawPath(path, paint);
+ paint.setColor(SK_ColorGREEN);
+ paint.setPathEffect(nullptr);
+ paint.setStrokeWidth(0);
+ canvas->drawPath(path, paint);
}
DEF_SIMPLE_GM(dashcubics, canvas, 860, 700) {
diff --git a/gm/dashing.cpp b/gm/dashing.cpp
index c728d15a1a..6cb1dea66c 100644
--- a/gm/dashing.cpp
+++ b/gm/dashing.cpp
@@ -21,8 +21,7 @@ static void drawline(SkCanvas* canvas, int on, int off, const SkPaint& paint,
SkIntToScalar(off),
};
- SkAutoTUnref<SkPathEffect> effect(SkDashPathEffect::Create(intervals, 2, phase));
- p.setPathEffect(effect);
+ p.setPathEffect(SkDashPathEffect::Make(intervals, 2, phase));
canvas->drawLine(startX, startY, finalX, finalY, p);
}
@@ -175,7 +174,7 @@ protected:
vals[i] = SkIntToScalar(*intervals++);
}
SkScalar phase = vals[0] / 2;
- paint.setPathEffect(SkDashPathEffect::Create(vals, count, phase))->unref();
+ paint.setPathEffect(SkDashPathEffect::Make(vals, count, phase));
for (size_t x = 0; x < SK_ARRAY_COUNT(gProc); ++x) {
SkPath path;
@@ -223,7 +222,7 @@ protected:
SkScalar intervals[2] = { dashLength, dashLength };
- p.setPathEffect(SkDashPathEffect::Create(intervals, 2, phase))->unref();
+ p.setPathEffect(SkDashPathEffect::Make(intervals, 2, phase));
SkPoint pts[2];
@@ -499,7 +498,7 @@ DEF_SIMPLE_GM(longpathdash, canvas, 512, 512) {
p.setStyle(SkPaint::kStroke_Style);
p.setStrokeWidth(1);
const SkScalar intervals[] = { 1, 1 };
- p.setPathEffect(SkDashPathEffect::Create(intervals, SK_ARRAY_COUNT(intervals), 0))->unref();
+ p.setPathEffect(SkDashPathEffect::Make(intervals, SK_ARRAY_COUNT(intervals), 0));
canvas->drawPath(lines, p);
}
@@ -510,7 +509,7 @@ DEF_SIMPLE_GM(longlinedash, canvas, 512, 512) {
p.setStrokeWidth(80);
const SkScalar intervals[] = { 2, 2 };
- p.setPathEffect(SkDashPathEffect::Create(intervals, SK_ARRAY_COUNT(intervals), 0))->unref();
+ p.setPathEffect(SkDashPathEffect::Make(intervals, SK_ARRAY_COUNT(intervals), 0));
canvas->drawRect(SkRect::MakeXYWH(-10000, 100, 20000, 20), p);
}
@@ -540,7 +539,7 @@ DEF_SIMPLE_GM(dashtextcaps, canvas, 512, 512) {
p.setARGB(0xff, 0xbb, 0x00, 0x00);
sk_tool_utils::set_portable_typeface(&p);
const SkScalar intervals[] = { 12, 12 };
- p.setPathEffect(SkDashPathEffect::Create(intervals, SK_ARRAY_COUNT(intervals), 0))->unref();
+ p.setPathEffect(SkDashPathEffect::Make(intervals, SK_ARRAY_COUNT(intervals), 0));
canvas->drawText("Sausages", 8, 10, 90, p);
canvas->drawLine(8, 120, 456, 120, p);
}
diff --git a/gm/pathcontourstart.cpp b/gm/pathcontourstart.cpp
index de3644c9f1..dbda7c3cae 100644
--- a/gm/pathcontourstart.cpp
+++ b/gm/pathcontourstart.cpp
@@ -26,14 +26,11 @@ public:
intervals.push_back(len);
}
- SkAutoTUnref<SkPathEffect> effect(
- SkDashPathEffect::Create(intervals.begin(), intervals.count(), 0));
-
fDashPaint.setAntiAlias(true);
fDashPaint.setStyle(SkPaint::kStroke_Style);
fDashPaint.setStrokeWidth(6);
fDashPaint.setColor(0xff008000);
- fDashPaint.setPathEffect(effect);
+ fDashPaint.setPathEffect(SkDashPathEffect::Make(intervals.begin(), intervals.count(), 0));
fPointsPaint.setColor(0xff800000);
fPointsPaint.setStrokeWidth(3);
diff --git a/gm/patheffects.cpp b/gm/patheffects.cpp
index 517d02e547..9821b3a35d 100644
--- a/gm/patheffects.cpp
+++ b/gm/patheffects.cpp
@@ -17,15 +17,14 @@ namespace skiagm {
static void compose_pe(SkPaint* paint) {
SkPathEffect* pe = paint->getPathEffect();
- SkPathEffect* corner = SkCornerPathEffect::Create(25);
- SkPathEffect* compose;
+ sk_sp<SkPathEffect> corner = SkCornerPathEffect::Make(25);
+ sk_sp<SkPathEffect> compose;
if (pe) {
- compose = SkComposePathEffect::Create(pe, corner);
- corner->unref();
+ compose = SkComposePathEffect::Make(sk_ref_sp(pe), corner);
} else {
compose = corner;
}
- paint->setPathEffect(compose)->unref();
+ paint->setPathEffect(compose);
}
static void hair_pe(SkPaint* paint) {
@@ -45,8 +44,7 @@ static void stroke_pe(SkPaint* paint) {
static void dash_pe(SkPaint* paint) {
SkScalar inter[] = { 20, 10, 10, 10 };
paint->setStrokeWidth(12);
- paint->setPathEffect(SkDashPathEffect::Create(inter, SK_ARRAY_COUNT(inter),
- 0))->unref();
+ paint->setPathEffect(SkDashPathEffect::Make(inter, SK_ARRAY_COUNT(inter), 0));
compose_pe(paint);
}
@@ -69,8 +67,8 @@ static void one_d_pe(SkPaint* paint) {
path.offset(SkIntToScalar(-6), 0);
scale(&path, 1.5f);
- paint->setPathEffect(SkPath1DPathEffect::Create(path, SkIntToScalar(21), 0,
- SkPath1DPathEffect::kRotate_Style))->unref();
+ paint->setPathEffect(SkPath1DPathEffect::Make(path, SkIntToScalar(21), 0,
+ SkPath1DPathEffect::kRotate_Style));
compose_pe(paint);
}
@@ -83,21 +81,21 @@ static void fill_pe(SkPaint* paint) {
}
static void discrete_pe(SkPaint* paint) {
- paint->setPathEffect(SkDiscretePathEffect::Create(10, 4))->unref();
+ paint->setPathEffect(SkDiscretePathEffect::Make(10, 4));
}
-static SkPathEffect* MakeTileEffect() {
+static sk_sp<SkPathEffect> MakeTileEffect() {
SkMatrix m;
m.setScale(SkIntToScalar(12), SkIntToScalar(12));
SkPath path;
path.addCircle(0, 0, SkIntToScalar(5));
- return SkPath2DPathEffect::Create(m, path);
+ return SkPath2DPathEffect::Make(m, path);
}
static void tile_pe(SkPaint* paint) {
- paint->setPathEffect(MakeTileEffect())->unref();
+ paint->setPathEffect(MakeTileEffect());
}
static const PE_Proc gPE2[] = { fill_pe, discrete_pe, tile_pe };
diff --git a/gm/strokes.cpp b/gm/strokes.cpp
index 261db9c69d..f64a87640c 100644
--- a/gm/strokes.cpp
+++ b/gm/strokes.cpp
@@ -128,7 +128,7 @@ protected:
canvas->drawPath(fMoveZfPath, strokePaint);
dashPaint = strokePaint;
const SkScalar intervals[] = { 0, 10 };
- dashPaint.setPathEffect(SkDashPathEffect::Create(intervals, 2, 0))->unref();
+ dashPaint.setPathEffect(SkDashPathEffect::Make(intervals, 2, 0));
SkPath fillPath;
dashPaint.getFillPath(fDashedfPath, &fillPath);
canvas->translate(0, 20);
diff --git a/gm/stroketext.cpp b/gm/stroketext.cpp
index d0a9882256..b247d8a711 100644
--- a/gm/stroketext.cpp
+++ b/gm/stroketext.cpp
@@ -55,7 +55,7 @@ static void draw_text_set(SkCanvas* canvas, const SkPaint& paint) {
canvas->translate(200, 0);
SkPaint p(paint);
- p.setPathEffect(SkDashPathEffect::Create(intervals, SK_ARRAY_COUNT(intervals), phase))->unref();
+ p.setPathEffect(SkDashPathEffect::Make(intervals, SK_ARRAY_COUNT(intervals), phase));
draw_text_stroked(canvas, p, 10);
}
diff --git a/gm/textbloblooper.cpp b/gm/textbloblooper.cpp
index 8d462c9b09..d54490272c 100644
--- a/gm/textbloblooper.cpp
+++ b/gm/textbloblooper.cpp
@@ -66,18 +66,18 @@ static void mask_filter(SkPaint* paint) {
paint->setMaskFilter(mf)->unref();
}
-static SkPathEffect* make_tile_effect() {
+static sk_sp<SkPathEffect> make_tile_effect() {
SkMatrix m;
m.setScale(1.f, 1.f);
SkPath path;
path.addCircle(0, 0, SkIntToScalar(5));
- return SkPath2DPathEffect::Create(m, path);
+ return SkPath2DPathEffect::Make(m, path);
}
static void path_effect(SkPaint* paint) {
- paint->setPathEffect(make_tile_effect())->unref();
+ paint->setPathEffect(make_tile_effect());
}
static sk_sp<SkShader> make_shader(const SkRect& bounds) {
diff --git a/gm/texteffects.cpp b/gm/texteffects.cpp
index 6ad3d23bf2..aa3d3758ab 100644
--- a/gm/texteffects.cpp
+++ b/gm/texteffects.cpp
@@ -77,7 +77,7 @@ static void r4(SkLayerRasterizer::Builder* rastBuilder, SkPaint& p) {
static void r5(SkLayerRasterizer::Builder* rastBuilder, SkPaint& p) {
rastBuilder->addLayer(p);
- p.setPathEffect(SkDiscretePathEffect::Create(SK_Scalar1*4, SK_Scalar1*3))->unref();
+ p.setPathEffect(SkDiscretePathEffect::Make(SK_Scalar1*4, SK_Scalar1*3));
p.setXfermodeMode(SkXfermode::kSrcOut_Mode);
rastBuilder->addLayer(p);
}
@@ -95,17 +95,17 @@ static void r6(SkLayerRasterizer::Builder* rastBuilder, SkPaint& p) {
#include "Sk2DPathEffect.h"
-static SkPathEffect* MakeDotEffect(SkScalar radius, const SkMatrix& matrix) {
+static sk_sp<SkPathEffect> MakeDotEffect(SkScalar radius, const SkMatrix& matrix) {
SkPath path;
path.addCircle(0, 0, radius);
- return SkPath2DPathEffect::Create(matrix, path);
+ return SkPath2DPathEffect::Make(matrix, path);
}
static void r7(SkLayerRasterizer::Builder* rastBuilder, SkPaint& p) {
SkMatrix lattice;
lattice.setScale(SK_Scalar1*6, SK_Scalar1*6, 0, 0);
lattice.postSkew(SK_Scalar1/3, 0, 0, 0);
- p.setPathEffect(MakeDotEffect(SK_Scalar1*4, lattice))->unref();
+ p.setPathEffect(MakeDotEffect(SK_Scalar1*4, lattice));
rastBuilder->addLayer(p);
}
@@ -115,7 +115,7 @@ static void r8(SkLayerRasterizer::Builder* rastBuilder, SkPaint& p) {
SkMatrix lattice;
lattice.setScale(SK_Scalar1*6, SK_Scalar1*6, 0, 0);
lattice.postSkew(SK_Scalar1/3, 0, 0, 0);
- p.setPathEffect(MakeDotEffect(SK_Scalar1*2, lattice))->unref();
+ p.setPathEffect(MakeDotEffect(SK_Scalar1*2, lattice));
p.setXfermodeMode(SkXfermode::kClear_Mode);
rastBuilder->addLayer(p);
@@ -132,7 +132,7 @@ static void r9(SkLayerRasterizer::Builder* rastBuilder, SkPaint& p) {
SkMatrix lattice;
lattice.setScale(SK_Scalar1, SK_Scalar1*6, 0, 0);
lattice.postRotate(SkIntToScalar(30), 0, 0);
- p.setPathEffect(SkLine2DPathEffect::Create(SK_Scalar1*2, lattice))->unref();
+ p.setPathEffect(SkLine2DPathEffect::Make(SK_Scalar1*2, lattice));
p.setXfermodeMode(SkXfermode::kClear_Mode);
rastBuilder->addLayer(p);