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

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

Issue 911053005: optional res-scale parameter to getFillPath (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 5 years, 10 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/SkStroke.h ('k') | src/core/SkStrokeRec.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 "SkPath.h" 10 #include "SkPath.h"
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
151 fEndSet = true; 151 fEndSet = true;
152 return true; 152 return true;
153 } 153 }
154 }; 154 };
155 #endif 155 #endif
156 156
157 class SkPathStroker { 157 class SkPathStroker {
158 public: 158 public:
159 #if QUAD_STROKE_APPROXIMATION 159 #if QUAD_STROKE_APPROXIMATION
160 SkPathStroker(const SkPath& src, 160 SkPathStroker(const SkPath& src,
161 SkScalar radius, SkScalar miterLimit, SkScalar error, SkPaint: :Cap cap, 161 SkScalar radius, SkScalar miterLimit, SkScalar error, SkPaint: :Cap,
162 SkPaint::Join join); 162 SkPaint::Join, SkScalar resScale);
163 #else 163 #else
164 SkPathStroker(const SkPath& src, 164 SkPathStroker(const SkPath& src,
165 SkScalar radius, SkScalar miterLimit, SkPaint::Cap cap, 165 SkScalar radius, SkScalar miterLimit, SkPaint::Cap,
166 SkPaint::Join join); 166 SkPaint::Join, SkScalar resScale);
167 #endif 167 #endif
168 168
169 void moveTo(const SkPoint&); 169 void moveTo(const SkPoint&);
170 void lineTo(const SkPoint&); 170 void lineTo(const SkPoint&);
171 void quadTo(const SkPoint&, const SkPoint&); 171 void quadTo(const SkPoint&, const SkPoint&);
172 void cubicTo(const SkPoint&, const SkPoint&, const SkPoint&); 172 void cubicTo(const SkPoint&, const SkPoint&, const SkPoint&);
173 void close(bool isLine) { this->finishContour(true, isLine); } 173 void close(bool isLine) { this->finishContour(true, isLine); }
174 174
175 void done(SkPath* dst, bool isLine) { 175 void done(SkPath* dst, bool isLine) {
176 this->finishContour(false, isLine); 176 this->finishContour(false, isLine);
177 fOuter.addPath(fExtra); 177 fOuter.addPath(fExtra);
178 dst->swap(fOuter); 178 dst->swap(fOuter);
179 } 179 }
180 180
181 SkScalar getResScale() const { return fResScale; }
182
181 private: 183 private:
182 #if QUAD_STROKE_APPROXIMATION 184 #if QUAD_STROKE_APPROXIMATION
183 SkScalar fError; 185 SkScalar fError;
184 #endif 186 #endif
185 SkScalar fRadius; 187 SkScalar fRadius;
186 SkScalar fInvMiterLimit; 188 SkScalar fInvMiterLimit;
189 SkScalar fResScale;
187 190
188 SkVector fFirstNormal, fPrevNormal, fFirstUnitNormal, fPrevUnitNormal; 191 SkVector fFirstNormal, fPrevNormal, fFirstUnitNormal, fPrevUnitNormal;
189 SkPoint fFirstPt, fPrevPt; // on original path 192 SkPoint fFirstPt, fPrevPt; // on original path
190 SkPoint fFirstOuterPt; 193 SkPoint fFirstOuterPt;
191 int fSegmentCount; 194 int fSegmentCount;
192 bool fPrevIsLine; 195 bool fPrevIsLine;
193 196
194 SkStrokerPriv::CapProc fCapper; 197 SkStrokerPriv::CapProc fCapper;
195 SkStrokerPriv::JoinProc fJoiner; 198 SkStrokerPriv::JoinProc fJoiner;
196 199
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after
341 // reallocating its internal storage. 344 // reallocating its internal storage.
342 fInner.rewind(); 345 fInner.rewind();
343 fSegmentCount = -1; 346 fSegmentCount = -1;
344 } 347 }
345 348
346 /////////////////////////////////////////////////////////////////////////////// 349 ///////////////////////////////////////////////////////////////////////////////
347 350
348 #if QUAD_STROKE_APPROXIMATION 351 #if QUAD_STROKE_APPROXIMATION
349 SkPathStroker::SkPathStroker(const SkPath& src, 352 SkPathStroker::SkPathStroker(const SkPath& src,
350 SkScalar radius, SkScalar miterLimit, SkScalar erro r, 353 SkScalar radius, SkScalar miterLimit, SkScalar erro r,
351 SkPaint::Cap cap, SkPaint::Join join) 354 SkPaint::Cap cap, SkPaint::Join join, SkScalar resS cale)
352 #else 355 #else
353 SkPathStroker::SkPathStroker(const SkPath& src, 356 SkPathStroker::SkPathStroker(const SkPath& src,
354 SkScalar radius, SkScalar miterLimit, 357 SkScalar radius, SkScalar miterLimit,
355 SkPaint::Cap cap, SkPaint::Join join) 358 SkPaint::Cap cap, SkPaint::Join join, SkScalar resS cale)
356 #endif 359 #endif
357 : fRadius(radius) { 360 : fRadius(radius), fResScale(resScale) {
358 361
359 /* This is only used when join is miter_join, but we initialize it here 362 /* This is only used when join is miter_join, but we initialize it here
360 so that it is always defined, to fis valgrind warnings. 363 so that it is always defined, to fis valgrind warnings.
361 */ 364 */
362 fInvMiterLimit = 0; 365 fInvMiterLimit = 0;
363 366
364 if (join == SkPaint::kMiter_Join) { 367 if (join == SkPaint::kMiter_Join) {
365 if (miterLimit <= SK_Scalar1) { 368 if (miterLimit <= SK_Scalar1) {
366 join = SkPaint::kBevel_Join; 369 join = SkPaint::kBevel_Join;
367 } else { 370 } else {
(...skipping 1054 matching lines...) Expand 10 before | Expand all | Expand 10 after
1422 // our answer should preserve the inverseness of the src 1425 // our answer should preserve the inverseness of the src
1423 if (src.isInverseFillType()) { 1426 if (src.isInverseFillType()) {
1424 SkASSERT(!dst->isInverseFillType()); 1427 SkASSERT(!dst->isInverseFillType());
1425 dst->toggleInverseFillType(); 1428 dst->toggleInverseFillType();
1426 } 1429 }
1427 return; 1430 return;
1428 } 1431 }
1429 } 1432 }
1430 1433
1431 SkAutoConicToQuads converter; 1434 SkAutoConicToQuads converter;
1432 const SkScalar conicTol = SK_Scalar1 / 4; 1435 const SkScalar conicTol = SK_Scalar1 / 4 / fResScale;
1433 1436
1434 #if QUAD_STROKE_APPROXIMATION 1437 #if QUAD_STROKE_APPROXIMATION
1435 SkPathStroker stroker(src, radius, fMiterLimit, fError, this->getCap(), 1438 SkPathStroker stroker(src, radius, fMiterLimit, fError, this->getCap(),
1436 this->getJoin()); 1439 this->getJoin(), fResScale);
1437 #else 1440 #else
1438 SkPathStroker stroker(src, radius, fMiterLimit, this->getCap(), 1441 SkPathStroker stroker(src, radius, fMiterLimit, this->getCap(), this->getJ oin(), fResScale);
1439 this->getJoin());
1440 #endif 1442 #endif
1441 SkPath::Iter iter(src, false); 1443 SkPath::Iter iter(src, false);
1442 SkPath::Verb lastSegment = SkPath::kMove_Verb; 1444 SkPath::Verb lastSegment = SkPath::kMove_Verb;
1443 1445
1444 for (;;) { 1446 for (;;) {
1445 SkPoint pts[4]; 1447 SkPoint pts[4];
1446 switch (iter.next(pts, false)) { 1448 switch (iter.next(pts, false)) {
1447 case SkPath::kMove_Verb: 1449 case SkPath::kMove_Verb:
1448 stroker.moveTo(pts[0]); 1450 stroker.moveTo(pts[0]);
1449 break; 1451 break;
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
1587 default: 1589 default:
1588 break; 1590 break;
1589 } 1591 }
1590 1592
1591 if (fWidth < SkMinScalar(rw, rh) && !fDoFill) { 1593 if (fWidth < SkMinScalar(rw, rh) && !fDoFill) {
1592 r = rect; 1594 r = rect;
1593 r.inset(radius, radius); 1595 r.inset(radius, radius);
1594 dst->addRect(r, reverse_direction(dir)); 1596 dst->addRect(r, reverse_direction(dir));
1595 } 1597 }
1596 } 1598 }
OLDNEW
« no previous file with comments | « src/core/SkStroke.h ('k') | src/core/SkStrokeRec.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698