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

Side by Side Diff: src/core/SkStroke.cpp

Issue 1301763006: fix override (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: experiment with zero-length round capped line segments Created 5 years, 4 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 unified diff | Download patch
« no previous file with comments | « src/core/SkPathMeasure.cpp ('k') | src/utils/SkDashPath.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2008 The Android Open Source Project 2 * Copyright 2008 The Android Open Source Project
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 7
8 #include "SkStrokerPriv.h" 8 #include "SkStrokerPriv.h"
9 #include "SkGeometry.h" 9 #include "SkGeometry.h"
10 #include "SkPathPriv.h" 10 #include "SkPathPriv.h"
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
114 return true; 114 return true;
115 } 115 }
116 }; 116 };
117 117
118 class SkPathStroker { 118 class SkPathStroker {
119 public: 119 public:
120 SkPathStroker(const SkPath& src, 120 SkPathStroker(const SkPath& src,
121 SkScalar radius, SkScalar miterLimit, SkPaint::Cap, 121 SkScalar radius, SkScalar miterLimit, SkPaint::Cap,
122 SkPaint::Join, SkScalar resScale); 122 SkPaint::Join, SkScalar resScale);
123 123
124 bool hasOnlyMoveTo() const { return 0 == fSegmentCount; }
125 SkPoint moveToPt() const { return fFirstPt; }
126
124 void moveTo(const SkPoint&); 127 void moveTo(const SkPoint&);
125 void lineTo(const SkPoint&); 128 void lineTo(const SkPoint&);
126 void quadTo(const SkPoint&, const SkPoint&); 129 void quadTo(const SkPoint&, const SkPoint&);
127 void conicTo(const SkPoint&, const SkPoint&, SkScalar weight); 130 void conicTo(const SkPoint&, const SkPoint&, SkScalar weight);
128 void cubicTo(const SkPoint&, const SkPoint&, const SkPoint&); 131 void cubicTo(const SkPoint&, const SkPoint&, const SkPoint&);
129 void close(bool isLine) { this->finishContour(true, isLine); } 132 void close(bool isLine) { this->finishContour(true, isLine); }
130 133
131 void done(SkPath* dst, bool isLine) { 134 void done(SkPath* dst, bool isLine) {
132 this->finishContour(false, isLine); 135 this->finishContour(false, isLine);
133 fOuter.addPath(fExtra); 136 fOuter.addPath(fExtra);
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
235 /////////////////////////////////////////////////////////////////////////////// 238 ///////////////////////////////////////////////////////////////////////////////
236 239
237 bool SkPathStroker::preJoinTo(const SkPoint& currPt, SkVector* normal, 240 bool SkPathStroker::preJoinTo(const SkPoint& currPt, SkVector* normal,
238 SkVector* unitNormal, bool currIsLine) { 241 SkVector* unitNormal, bool currIsLine) {
239 SkASSERT(fSegmentCount >= 0); 242 SkASSERT(fSegmentCount >= 0);
240 243
241 SkScalar prevX = fPrevPt.fX; 244 SkScalar prevX = fPrevPt.fX;
242 SkScalar prevY = fPrevPt.fY; 245 SkScalar prevY = fPrevPt.fY;
243 246
244 if (!set_normal_unitnormal(fPrevPt, currPt, fRadius, normal, unitNormal)) { 247 if (!set_normal_unitnormal(fPrevPt, currPt, fRadius, normal, unitNormal)) {
245 return false; 248 if (SkStrokerPriv::CapFactory(SkPaint::kButt_Cap) == fCapper) {
249 return false;
250 }
251 normal->set(fRadius, 0);
252 unitNormal->set(1, 0);
246 } 253 }
247 254
248 if (fSegmentCount == 0) { 255 if (fSegmentCount == 0) {
249 fFirstNormal = *normal; 256 fFirstNormal = *normal;
250 fFirstUnitNormal = *unitNormal; 257 fFirstUnitNormal = *unitNormal;
251 fFirstOuterPt.set(prevX + normal->fX, prevY + normal->fY); 258 fFirstOuterPt.set(prevX + normal->fX, prevY + normal->fY);
252 259
253 fOuter.moveTo(fFirstOuterPt.fX, fFirstOuterPt.fY); 260 fOuter.moveTo(fFirstOuterPt.fX, fFirstOuterPt.fY);
254 fInner.moveTo(prevX - normal->fX, prevY - normal->fY); 261 fInner.moveTo(prevX - normal->fX, prevY - normal->fY);
255 } else { // we have a previous segment 262 } else { // we have a previous segment
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
349 fSegmentCount = 0; 356 fSegmentCount = 0;
350 fFirstPt = fPrevPt = pt; 357 fFirstPt = fPrevPt = pt;
351 } 358 }
352 359
353 void SkPathStroker::line_to(const SkPoint& currPt, const SkVector& normal) { 360 void SkPathStroker::line_to(const SkPoint& currPt, const SkVector& normal) {
354 fOuter.lineTo(currPt.fX + normal.fX, currPt.fY + normal.fY); 361 fOuter.lineTo(currPt.fX + normal.fX, currPt.fY + normal.fY);
355 fInner.lineTo(currPt.fX - normal.fX, currPt.fY - normal.fY); 362 fInner.lineTo(currPt.fX - normal.fX, currPt.fY - normal.fY);
356 } 363 }
357 364
358 void SkPathStroker::lineTo(const SkPoint& currPt) { 365 void SkPathStroker::lineTo(const SkPoint& currPt) {
359 if (SkPath::IsLineDegenerate(fPrevPt, currPt, false)) { 366 if (SkStrokerPriv::CapFactory(SkPaint::kButt_Cap) == fCapper
367 && SkPath::IsLineDegenerate(fPrevPt, currPt, false)) {
360 return; 368 return;
361 } 369 }
362 SkVector normal, unitNormal; 370 SkVector normal, unitNormal;
363 371
364 if (!this->preJoinTo(currPt, &normal, &unitNormal, true)) { 372 if (!this->preJoinTo(currPt, &normal, &unitNormal, true)) {
365 return; 373 return;
366 } 374 }
367 this->line_to(currPt, normal); 375 this->line_to(currPt, normal);
368 this->postJoinTo(currPt, normal, unitNormal); 376 this->postJoinTo(currPt, normal, unitNormal);
369 } 377 }
(...skipping 957 matching lines...) Expand 10 before | Expand all | Expand 10 after
1327 case SkPath::kConic_Verb: { 1335 case SkPath::kConic_Verb: {
1328 stroker.conicTo(pts[1], pts[2], iter.conicWeight()); 1336 stroker.conicTo(pts[1], pts[2], iter.conicWeight());
1329 lastSegment = SkPath::kConic_Verb; 1337 lastSegment = SkPath::kConic_Verb;
1330 break; 1338 break;
1331 } break; 1339 } break;
1332 case SkPath::kCubic_Verb: 1340 case SkPath::kCubic_Verb:
1333 stroker.cubicTo(pts[1], pts[2], pts[3]); 1341 stroker.cubicTo(pts[1], pts[2], pts[3]);
1334 lastSegment = SkPath::kCubic_Verb; 1342 lastSegment = SkPath::kCubic_Verb;
1335 break; 1343 break;
1336 case SkPath::kClose_Verb: 1344 case SkPath::kClose_Verb:
1345 if (stroker.hasOnlyMoveTo() && SkPaint::kButt_Cap != this->getCa p()) {
1346 stroker.lineTo(stroker.moveToPt());
1347 lastSegment = SkPath::kLine_Verb;
1348 break;
1349 }
1337 stroker.close(lastSegment == SkPath::kLine_Verb); 1350 stroker.close(lastSegment == SkPath::kLine_Verb);
1338 break; 1351 break;
1339 case SkPath::kDone_Verb: 1352 case SkPath::kDone_Verb:
1340 goto DONE; 1353 goto DONE;
1341 } 1354 }
1342 } 1355 }
1343 DONE: 1356 DONE:
1344 stroker.done(dst, lastSegment == SkPath::kLine_Verb); 1357 stroker.done(dst, lastSegment == SkPath::kLine_Verb);
1345 1358
1346 if (fDoFill) { 1359 if (fDoFill) {
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
1450 default: 1463 default:
1451 break; 1464 break;
1452 } 1465 }
1453 1466
1454 if (fWidth < SkMinScalar(rw, rh) && !fDoFill) { 1467 if (fWidth < SkMinScalar(rw, rh) && !fDoFill) {
1455 r = rect; 1468 r = rect;
1456 r.inset(radius, radius); 1469 r.inset(radius, radius);
1457 dst->addRect(r, reverse_direction(dir)); 1470 dst->addRect(r, reverse_direction(dir));
1458 } 1471 }
1459 } 1472 }
OLDNEW
« no previous file with comments | « src/core/SkPathMeasure.cpp ('k') | src/utils/SkDashPath.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698