diff options
author | robertphillips@google.com <robertphillips@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2012-11-28 17:18:11 +0000 |
---|---|---|
committer | robertphillips@google.com <robertphillips@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2012-11-28 17:18:11 +0000 |
commit | 629ab540667422d3edcb97c51e9628b7051e1ba4 (patch) | |
tree | 39db471013b5abcdbfd9267aed41984c2aab6e9d /src/core | |
parent | edb26fdb8349a727b226e90cbeab06cd25f5cac0 (diff) |
Added dashing fast path
https://codereview.appspot.com/6844067/
git-svn-id: http://skia.googlecode.com/svn/trunk@6585 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'src/core')
-rw-r--r-- | src/core/SkDraw.cpp | 33 | ||||
-rw-r--r-- | src/core/SkPathEffect.cpp | 5 |
2 files changed, 38 insertions, 0 deletions
diff --git a/src/core/SkDraw.cpp b/src/core/SkDraw.cpp index 3c1b72dde4..f4487af9c8 100644 --- a/src/core/SkDraw.cpp +++ b/src/core/SkDraw.cpp @@ -635,6 +635,39 @@ void SkDraw::drawPoints(SkCanvas::PointMode mode, size_t count, break; } case SkCanvas::kLines_PointMode: +#ifndef SK_DISABLE_DASHING_OPTIMIZATION + if (2 == count && NULL != paint.getPathEffect()) { + // most likely a dashed line - see if it is one of the ones + // we can accelerate + SkStrokeRec rec(paint); + SkPathEffect::PointData dst; + + SkPath path; + path.moveTo(pts[0]); + path.lineTo(pts[1]); + + if (paint.getPathEffect()->asPoints(&dst, path, rec, *fMatrix) && + SK_Scalar1 == dst.fSize.fX && SK_Scalar1 == dst.fSize.fY && + !(SkPathEffect::PointData::kUsePath_PointFlag & dst.fFlags)) { + SkPaint newP(paint); + newP.setPathEffect(NULL); + + if (SkPathEffect::PointData::kCircles_PointFlag & dst.fFlags) { + newP.setStrokeCap(SkPaint::kRound_Cap); + } else { + newP.setStrokeCap(SkPaint::kButt_Cap); + } + + this->drawPoints(SkCanvas::kPoints_PointMode, + dst.fPoints.count(), + dst.fPoints.begin(), + newP, + forceUseDevice); + break; + } + } +#endif // DISABLE_DASHING_OPTIMIZATION + // couldn't take fast path so fall through! case SkCanvas::kPolygon_PointMode: { count -= 1; SkPath path; diff --git a/src/core/SkPathEffect.cpp b/src/core/SkPathEffect.cpp index d706e8dabe..a64ebc77a6 100644 --- a/src/core/SkPathEffect.cpp +++ b/src/core/SkPathEffect.cpp @@ -116,6 +116,11 @@ void SkPathEffect::computeFastBounds(SkRect* dst, const SkRect& src) { *dst = src; } +bool SkPathEffect::asPoints(PointData* results, const SkPath& src, + const SkStrokeRec&, const SkMatrix&) const { + return false; +} + /////////////////////////////////////////////////////////////////////////////// SkPairPathEffect::SkPairPathEffect(SkPathEffect* pe0, SkPathEffect* pe1) |