aboutsummaryrefslogtreecommitdiffhomepage
path: root/samplecode
diff options
context:
space:
mode:
authorGravatar Hal Canary <halcanary@google.com>2017-05-15 13:35:35 -0400
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2017-05-16 12:59:11 +0000
commit23e474cb7331c5d2389d97dce2d9e5c93c58f39f (patch)
tree95314f82ba240a5e5f5891d78489b2f4c9364b76 /samplecode
parent03d1e59bdac65cc1dd606b60e6565eb6860419f9 (diff)
SkCanvas: Helpers for draw{Point,Line,Circle}
Change-Id: Ie9c7d3b8f01aee435563b23b7d27f098f07dd287 Reviewed-on: https://skia-review.googlesource.com/16909 Reviewed-by: Mike Reed <reed@google.com> Commit-Queue: Hal Canary <halcanary@google.com>
Diffstat (limited to 'samplecode')
-rw-r--r--samplecode/SampleAAGeometry.cpp14
-rw-r--r--samplecode/SampleAll.cpp2
-rw-r--r--samplecode/SampleFatBits.cpp2
-rw-r--r--samplecode/SampleHairline.cpp2
-rw-r--r--samplecode/SamplePathClip.cpp2
5 files changed, 11 insertions, 11 deletions
diff --git a/samplecode/SampleAAGeometry.cpp b/samplecode/SampleAAGeometry.cpp
index 69aa77fd12..08a518ca17 100644
--- a/samplecode/SampleAAGeometry.cpp
+++ b/samplecode/SampleAAGeometry.cpp
@@ -1056,15 +1056,15 @@ public:
SkVector bisect = { (lastV.fX + nextV.fX) / 2, (lastV.fY + nextV.fY) / 2 };
bisect.setLength(fWidthControl.fValLo * 2);
if (fBisectButton.enabled()) {
- canvas->drawLine(pt.fX, pt.fY, pt.fX + bisect.fX, pt.fY + bisect.fY, fSkeletonPaint);
+ canvas->drawLine(pt, pt + bisect, fSkeletonPaint);
}
lastV.setLength(fWidthControl.fValLo);
if (fBisectButton.enabled()) {
- canvas->drawLine(pt.fX, pt.fY, pt.fX - lastV.fY, pt.fY + lastV.fX, fSkeletonPaint);
+ canvas->drawLine(pt, {pt.fX - lastV.fY, pt.fY + lastV.fX}, fSkeletonPaint);
}
nextV.setLength(fWidthControl.fValLo);
if (fBisectButton.enabled()) {
- canvas->drawLine(pt.fX, pt.fY, pt.fX + nextV.fY, pt.fY - nextV.fX, fSkeletonPaint);
+ canvas->drawLine(pt, {pt.fX + nextV.fY, pt.fY - nextV.fX}, fSkeletonPaint);
}
if (fJoinButton.enabled()) {
SkScalar r = fWidthControl.fValLo;
@@ -1117,8 +1117,8 @@ public:
SkPoint maxPt = SkEvalQuadAt(pts, t);
SkVector tangent = SkEvalQuadTangentAt(pts, t);
tangent.setLength(fWidthControl.fValLo * 2);
- canvas->drawLine(maxPt.fX, maxPt.fY,
- maxPt.fX + tangent.fY, maxPt.fY - tangent.fX, fSkeletonPaint);
+ canvas->drawLine(maxPt, {maxPt.fX + tangent.fY, maxPt.fY - tangent.fX},
+ fSkeletonPaint);
}
} break;
case SkPath::kConic_Verb:
@@ -1163,8 +1163,8 @@ public:
SkVector tangent;
SkEvalCubicAt(pts, tMax[tIndex], &maxPt, &tangent, NULL);
tangent.setLength(fWidthControl.fValLo * 2);
- canvas->drawLine(maxPt.fX, maxPt.fY,
- maxPt.fX + tangent.fY, maxPt.fY - tangent.fX, fSkeletonPaint);
+ canvas->drawLine(maxPt, {maxPt.fX + tangent.fY, maxPt.fY - tangent.fX},
+ fSkeletonPaint);
}
} break;
case SkPath::kClose_Verb:
diff --git a/samplecode/SampleAll.cpp b/samplecode/SampleAll.cpp
index a8d24589ce..ecd6715a11 100644
--- a/samplecode/SampleAll.cpp
+++ b/samplecode/SampleAll.cpp
@@ -402,7 +402,7 @@ protected:
paint.setStyle(SkPaint::kStroke_Style);
paint.setBlendMode(SkBlendMode::kXor);
paint.setColorFilter(lightingFilter);
- canvas->drawLine(start.fX, start.fY, stop.fX, stop.fY, paint); // should not be green
+ canvas->drawLine(start, stop, paint); // should not be green
paint.setBlendMode(SkBlendMode::kSrcOver);
paint.setColorFilter(nullptr);
diff --git a/samplecode/SampleFatBits.cpp b/samplecode/SampleFatBits.cpp
index 1acc1afa31..4e44a7f417 100644
--- a/samplecode/SampleFatBits.cpp
+++ b/samplecode/SampleFatBits.cpp
@@ -261,7 +261,7 @@ void FatBits::drawLine(SkCanvas* canvas, SkPoint pts[]) {
r.inset(SK_Scalar1/3, SK_Scalar1/3);
fMinSurface->getCanvas()->clipRect(r, kIntersect_SkClipOp, true);
}
- fMinSurface->getCanvas()->drawLine(pts[0].fX, pts[0].fY, pts[1].fX, pts[1].fY, paint);
+ fMinSurface->getCanvas()->drawLine(pts[0], pts[1], paint);
if (fUseClip) {
fMinSurface->getCanvas()->restore();
}
diff --git a/samplecode/SampleHairline.cpp b/samplecode/SampleHairline.cpp
index 169804ddfa..fe9e07cb1c 100644
--- a/samplecode/SampleHairline.cpp
+++ b/samplecode/SampleHairline.cpp
@@ -77,7 +77,7 @@ static void line_proc(SkCanvas* canvas, const SkPaint& paint,
for (int i = 0; i < 400; i++) {
generate_pts(pts, N, WIDTH, HEIGHT);
- canvas->drawLine(pts[0].fX, pts[0].fY, pts[1].fX, pts[1].fY, paint);
+ canvas->drawLine(pts[0], pts[1], paint);
if (!check_bitmap_margin(bm, MARGIN)) {
SkDebugf("---- hairline failure (%g %g) (%g %g)\n",
pts[0].fX, pts[0].fY, pts[1].fX, pts[1].fY);
diff --git a/samplecode/SamplePathClip.cpp b/samplecode/SamplePathClip.cpp
index b425884ebe..5fdaeedb55 100644
--- a/samplecode/SamplePathClip.cpp
+++ b/samplecode/SamplePathClip.cpp
@@ -202,7 +202,7 @@ protected:
const int j = (i + 1) % N;
p.setColor(fEdgeColor[i]);
p.setAlpha(0x88);
- canvas->drawLine(fPoly[i].x(), fPoly[i].y(), fPoly[j].x(), fPoly[j].y(), p);
+ canvas->drawLine(fPoly[i], fPoly[j], p);
}
p.setStyle(SkPaint::kFill_Style);