Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(157)

Unified Diff: src/core/SkDraw.cpp

Issue 1957263003: refactor drawPath to have drawDevPath (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « include/core/SkDraw.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/core/SkDraw.cpp
diff --git a/src/core/SkDraw.cpp b/src/core/SkDraw.cpp
index d2c6bb131e382ede6b10841023f645d3492dc288..884794261dcad45130cb345e5325075109aa30f2 100644
--- a/src/core/SkDraw.cpp
+++ b/src/core/SkDraw.cpp
@@ -1016,6 +1016,68 @@ SkScalar SkDraw::ComputeResScaleForStroking(const SkMatrix& matrix) {
return 1;
}
+void SkDraw::drawDevPath(const SkPath& devPath, const SkPaint& paint, bool drawCoverage,
+ SkBlitter* customBlitter, bool doFill) const {
+ SkBlitter* blitter = nullptr;
+ SkAutoBlitterChoose blitterStorage;
+ if (nullptr == customBlitter) {
+ blitterStorage.choose(fDst, *fMatrix, paint, drawCoverage);
+ blitter = blitterStorage.get();
+ } else {
+ blitter = customBlitter;
+ }
+
+ if (paint.getMaskFilter()) {
+ SkStrokeRec::InitStyle style = doFill ? SkStrokeRec::kFill_InitStyle
+ : SkStrokeRec::kHairline_InitStyle;
+ if (paint.getMaskFilter()->filterPath(devPath, *fMatrix, *fRC, blitter, style)) {
+ return; // filterPath() called the blitter, so we're done
+ }
+ }
+
+ void (*proc)(const SkPath&, const SkRasterClip&, SkBlitter*);
+ if (doFill) {
+ if (paint.isAntiAlias()) {
+ proc = SkScan::AntiFillPath;
+ } else {
+ proc = SkScan::FillPath;
+ }
+ } else { // hairline
+ if (paint.isAntiAlias()) {
+ switch (paint.getStrokeCap()) {
+ case SkPaint::kButt_Cap:
+ proc = SkScan::AntiHairPath;
+ break;
+ case SkPaint::kSquare_Cap:
+ proc = SkScan::AntiHairSquarePath;
+ break;
+ case SkPaint::kRound_Cap:
+ proc = SkScan::AntiHairRoundPath;
+ break;
+ default:
+ proc SK_INIT_TO_AVOID_WARNING;
+ SkDEBUGFAIL("unknown paint cap type");
+ }
+ } else {
+ switch (paint.getStrokeCap()) {
+ case SkPaint::kButt_Cap:
+ proc = SkScan::HairPath;
+ break;
+ case SkPaint::kSquare_Cap:
+ proc = SkScan::HairSquarePath;
+ break;
+ case SkPaint::kRound_Cap:
+ proc = SkScan::HairRoundPath;
+ break;
+ default:
+ proc SK_INIT_TO_AVOID_WARNING;
+ SkDEBUGFAIL("unknown paint cap type");
+ }
+ }
+ }
+ proc(devPath, *fRC, blitter);
+}
+
void SkDraw::drawPath(const SkPath& origSrcPath, const SkPaint& origPaint,
const SkMatrix* prePathMatrix, bool pathIsMutable,
bool drawCoverage, SkBlitter* customBlitter) const {
@@ -1106,68 +1168,10 @@ void SkDraw::drawPath(const SkPath& origSrcPath, const SkPaint& origPaint,
// transform the path into device space
pathPtr->transform(*matrix, devPathPtr);
- SkBlitter* blitter = nullptr;
- SkAutoBlitterChoose blitterStorage;
- if (nullptr == customBlitter) {
- blitterStorage.choose(fDst, *fMatrix, *paint, drawCoverage);
- blitter = blitterStorage.get();
- } else {
- blitter = customBlitter;
- }
-
- if (paint->getMaskFilter()) {
- SkStrokeRec::InitStyle style = doFill ? SkStrokeRec::kFill_InitStyle
- : SkStrokeRec::kHairline_InitStyle;
- if (paint->getMaskFilter()->filterPath(*devPathPtr, *fMatrix, *fRC, blitter, style)) {
- return; // filterPath() called the blitter, so we're done
- }
- }
-
- void (*proc)(const SkPath&, const SkRasterClip&, SkBlitter*);
- if (doFill) {
- if (paint->isAntiAlias()) {
- proc = SkScan::AntiFillPath;
- } else {
- proc = SkScan::FillPath;
- }
- } else { // hairline
- if (paint->isAntiAlias()) {
- switch (paint->getStrokeCap()) {
- case SkPaint::kButt_Cap:
- proc = SkScan::AntiHairPath;
- break;
- case SkPaint::kSquare_Cap:
- proc = SkScan::AntiHairSquarePath;
- break;
- case SkPaint::kRound_Cap:
- proc = SkScan::AntiHairRoundPath;
- break;
- default:
- proc SK_INIT_TO_AVOID_WARNING;
- SkDEBUGFAIL("unknown paint cap type");
- }
- } else {
- switch (paint->getStrokeCap()) {
- case SkPaint::kButt_Cap:
- proc = SkScan::HairPath;
- break;
- case SkPaint::kSquare_Cap:
- proc = SkScan::HairSquarePath;
- break;
- case SkPaint::kRound_Cap:
- proc = SkScan::HairRoundPath;
- break;
- default:
- proc SK_INIT_TO_AVOID_WARNING;
- SkDEBUGFAIL("unknown paint cap type");
- }
- }
- }
- proc(*devPathPtr, *fRC, blitter);
+ this->drawDevPath(*devPathPtr, *paint, drawCoverage, customBlitter, doFill);
}
-void SkDraw::drawBitmapAsMask(const SkBitmap& bitmap,
- const SkPaint& paint) const {
+void SkDraw::drawBitmapAsMask(const SkBitmap& bitmap, const SkPaint& paint) const {
SkASSERT(bitmap.colorType() == kAlpha_8_SkColorType);
if (SkTreatAsSprite(*fMatrix, bitmap.dimensions(), paint)) {
« no previous file with comments | « include/core/SkDraw.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698