diff --git a/experimental/svg/model/SkSVGLine.cpp b/experimental/svg/model/SkSVGLine.cpp index 9c8f5aa02b..2719a9bbc2 100644 --- a/experimental/svg/model/SkSVGLine.cpp +++ b/experimental/svg/model/SkSVGLine.cpp @@ -68,7 +68,7 @@ void SkSVGLine::onDraw(SkCanvas* canvas, const SkSVGLengthContext& lctx, SkPoint p0, p1; std::tie(p0, p1) = this->resolve(lctx); - canvas->drawLine(p0.x(), p0.y(), p1.x(), p1.y(), paint); + canvas->drawLine(p0, p1, paint); } SkPath SkSVGLine::onAsPath(const SkSVGRenderContext& ctx) const { diff --git a/gm/addarc.cpp b/gm/addarc.cpp index 96ac666d28..763135fac5 100644 --- a/gm/addarc.cpp +++ b/gm/addarc.cpp @@ -103,7 +103,7 @@ protected: SkScalar arcLen = rad * R; SkPoint pos; if (meas.getPosTan(arcLen, &pos, nullptr)) { - canvas->drawLine(0, 0, pos.x(), pos.y(), measPaint); + canvas->drawLine({0, 0}, pos, measPaint); } } } diff --git a/gm/beziereffects.cpp b/gm/beziereffects.cpp index c67018d2af..d3f1965d4f 100644 --- a/gm/beziereffects.cpp +++ b/gm/beziereffects.cpp @@ -160,9 +160,9 @@ protected: SkPaint ctrlPtPaint; ctrlPtPaint.setColor(rand.nextU() | 0xFF000000); - canvas->drawCircle(controlPts[0].fX, controlPts[0].fY, 8.f, ctrlPtPaint); + canvas->drawCircle(controlPts[0], 8.f, ctrlPtPaint); for (int i = 1; i < 4; ++i) { - canvas->drawCircle(controlPts[i].fX, controlPts[i].fY, 6.f, ctrlPtPaint); + canvas->drawCircle(controlPts[i], 6.f, ctrlPtPaint); } SkPaint polyPaint; @@ -178,7 +178,7 @@ protected: SkPoint* pts = chopped + 3 * c; for (int i = 0; i < 4; ++i) { - canvas->drawCircle(pts[i].fX, pts[i].fY, 3.f, choppedPtPaint); + canvas->drawCircle(pts[i], 3.f, choppedPtPaint); } SkRect bounds; @@ -299,7 +299,7 @@ protected: SkPaint ctrlPtPaint; ctrlPtPaint.setColor(rand.nextU() | 0xFF000000); for (int i = 0; i < 3; ++i) { - canvas->drawCircle(controlPts[i].fX, controlPts[i].fY, 6.f, ctrlPtPaint); + canvas->drawCircle(controlPts[i], 6.f, ctrlPtPaint); } SkPaint polyPaint; @@ -314,7 +314,7 @@ protected: for (int c = 0; c < cnt; ++c) { SkPoint* pts = dst[c].fPts; for (int i = 0; i < 3; ++i) { - canvas->drawCircle(pts[i].fX, pts[i].fY, 3.f, choppedPtPaint); + canvas->drawCircle(pts[i], 3.f, choppedPtPaint); } SkRect bounds; @@ -516,7 +516,7 @@ protected: SkPaint ctrlPtPaint; ctrlPtPaint.setColor(rand.nextU() | 0xFF000000); for (int i = 0; i < 3; ++i) { - canvas->drawCircle(controlPts[i].fX, controlPts[i].fY, 6.f, ctrlPtPaint); + canvas->drawCircle(controlPts[i], 6.f, ctrlPtPaint); } SkPaint polyPaint; @@ -532,7 +532,7 @@ protected: SkPoint* pts = chopped + 2 * c; for (int i = 0; i < 3; ++i) { - canvas->drawCircle(pts[i].fX, pts[i].fY, 3.f, choppedPtPaint); + canvas->drawCircle(pts[i], 3.f, choppedPtPaint); } SkRect bounds; diff --git a/gm/circles.cpp b/gm/circles.cpp index 5c53fe2b0e..9d2eca5ba7 100644 --- a/gm/circles.cpp +++ b/gm/circles.cpp @@ -150,7 +150,7 @@ protected: SkPaint giantPaint; giantPaint.setAntiAlias(true); giantPaint.setColor(0x80808080); - canvas->drawCircle(giantCenter.fX, giantCenter.fY, giantRadius, giantPaint); + canvas->drawCircle(giantCenter, giantRadius, giantPaint); SkRandom rand; canvas->translate(20 * SK_Scalar1, 20 * SK_Scalar1); diff --git a/gm/conicpaths.cpp b/gm/conicpaths.cpp index d0c6a9fc5d..e0a775a9dd 100644 --- a/gm/conicpaths.cpp +++ b/gm/conicpaths.cpp @@ -140,7 +140,7 @@ DEF_SIMPLE_GM(arccirclegap, canvas, 250, 250) { SkPaint paint; paint.setAntiAlias(true); paint.setStyle(SkPaint::kStroke_Style); - canvas->drawCircle(c.fX, c.fY, radius, paint); + canvas->drawCircle(c, radius, paint); SkPath path; path.moveTo(288.88884710654133f, -280.26680862609f); path.arcTo(0, 0, -39.00216443306411f, 400.6058925796476f, radius); @@ -156,7 +156,7 @@ DEF_SIMPLE_GM(largecircle, canvas, 250, 250) { SkPaint paint; paint.setAntiAlias(true); paint.setStyle(SkPaint::kStroke_Style); - canvas->drawCircle(c.fX, c.fY, radius, paint); + canvas->drawCircle(c, radius, paint); } DEF_SIMPLE_GM(crbug_640176, canvas, 250, 250) { diff --git a/gm/dstreadshuffle.cpp b/gm/dstreadshuffle.cpp index 3385ae4a69..aaef61d63c 100644 --- a/gm/dstreadshuffle.cpp +++ b/gm/dstreadshuffle.cpp @@ -115,7 +115,7 @@ protected: rot.postTranslate(3.f, 0); for (int i = 0; i < 12; ++i) { hairPaint.setColor(GetColor(&colorRandom)); - canvas->drawLine(pts[0].fX, pts[0].fY, pts[1].fX, pts[1].fY, hairPaint); + canvas->drawLine(pts[0], pts[1], hairPaint); rot.mapPoints(pts, 2); } } diff --git a/gm/imagescalealigned.cpp b/gm/imagescalealigned.cpp index 3d74f0edf8..a1f67410f1 100644 --- a/gm/imagescalealigned.cpp +++ b/gm/imagescalealigned.cpp @@ -84,7 +84,7 @@ private: surface->getCanvas()->drawRect(border, paint); paint.setColor(SK_ColorBLACK); - surface->getCanvas()->drawLine(start.x(), start.y(), end.x(), end.y(), paint); + surface->getCanvas()->drawLine(start, end, paint); paint.reset(); paint.setColor(color); diff --git a/include/core/SkCanvas.h b/include/core/SkCanvas.h index e7bee7f93d..e03b4f3daf 100644 --- a/include/core/SkCanvas.h +++ b/include/core/SkCanvas.h @@ -614,6 +614,9 @@ public: /** Helper method for drawing a single point. See drawPoints() for more details. */ void drawPoint(SkScalar x, SkScalar y, const SkPaint& paint); + void drawPoint(SkPoint p, const SkPaint& paint) { + this->drawPoint(p.x(), p.y(), paint); + } /** Draw a line segment with the specified start and stop x,y coordinates, using the specified paint. NOTE: since a line is always "framed", the @@ -625,6 +628,9 @@ public: @param paint The paint used to draw the line */ void drawLine(SkScalar x0, SkScalar y0, SkScalar x1, SkScalar y1, const SkPaint& paint); + void drawLine(SkPoint p0, SkPoint p1, const SkPaint& paint) { + this->drawLine(p0.x(), p0.y(), p1.x(), p1.y(), paint); + } /** Draw the specified rectangle using the specified paint. The rectangle will be filled or stroked based on the Style in the paint. @@ -681,6 +687,9 @@ public: @param paint The paint used to draw the circle */ void drawCircle(SkScalar cx, SkScalar cy, SkScalar radius, const SkPaint& paint); + void drawCircle(SkPoint center, SkScalar radius, const SkPaint& paint) { + this->drawCircle(center.x(), center.y(), radius, paint); + } /** Draw the specified arc, which will be scaled to fit inside the specified oval. Sweep angles are not treated as modulo 360 and thus can 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);