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

Side by Side Diff: src/effects/SkDashPathEffect.cpp

Issue 15080010: Add special handling of rectori case for gpu (Closed) Base URL: http://skia.googlecode.com/svn/trunk/
Patch Set: Added unit test Created 7 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/core/SkPath.cpp ('k') | src/gpu/GrAARectRenderer.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 /* 2 /*
3 * Copyright 2006 The Android Open Source Project 3 * Copyright 2006 The Android Open Source Project
4 * 4 *
5 * Use of this source code is governed by a BSD-style license that can be 5 * Use of this source code is governed by a BSD-style license that can be
6 * found in the LICENSE file. 6 * found in the LICENSE file.
7 */ 7 */
8 8
9 9
10 #include "SkDashPathEffect.h" 10 #include "SkDashPathEffect.h"
(...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after
230 230
231 bool SkDashPathEffect::filterPath(SkPath* dst, const SkPath& src, 231 bool SkDashPathEffect::filterPath(SkPath* dst, const SkPath& src,
232 SkStrokeRec* rec, const SkRect* cullRect) const { 232 SkStrokeRec* rec, const SkRect* cullRect) const {
233 // we do nothing if the src wants to be filled, or if our dashlength is 0 233 // we do nothing if the src wants to be filled, or if our dashlength is 0
234 if (rec->isFillStyle() || fInitialDashLength < 0) { 234 if (rec->isFillStyle() || fInitialDashLength < 0) {
235 return false; 235 return false;
236 } 236 }
237 237
238 const SkScalar* intervals = fIntervals; 238 const SkScalar* intervals = fIntervals;
239 SkScalar dashCount = 0; 239 SkScalar dashCount = 0;
240 int segCount = 0;
240 241
241 SkPath cullPathStorage; 242 SkPath cullPathStorage;
242 const SkPath* srcPtr = &src; 243 const SkPath* srcPtr = &src;
243 if (cull_path(src, *rec, cullRect, fIntervalLength, &cullPathStorage)) { 244 if (cull_path(src, *rec, cullRect, fIntervalLength, &cullPathStorage)) {
244 srcPtr = &cullPathStorage; 245 srcPtr = &cullPathStorage;
245 } 246 }
246 247
247 SpecialLineRec lineRec; 248 SpecialLineRec lineRec;
248 bool specialLine = lineRec.init(*srcPtr, dst, rec, fCount >> 1, fIntervalLen gth); 249 bool specialLine = lineRec.init(*srcPtr, dst, rec, fCount >> 1, fIntervalLen gth);
249 250
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
284 // Using double precision to avoid looping indefinitely due to single pr ecision rounding 285 // Using double precision to avoid looping indefinitely due to single pr ecision rounding
285 // (for extreme path_length/dash_length ratios). See test_infinite_dash( ) unittest. 286 // (for extreme path_length/dash_length ratios). See test_infinite_dash( ) unittest.
286 double distance = 0; 287 double distance = 0;
287 double dlen = SkScalarMul(fInitialDashLength, scale); 288 double dlen = SkScalarMul(fInitialDashLength, scale);
288 289
289 while (distance < length) { 290 while (distance < length) {
290 SkASSERT(dlen >= 0); 291 SkASSERT(dlen >= 0);
291 addedSegment = false; 292 addedSegment = false;
292 if (is_even(index) && dlen > 0 && !skipFirstSegment) { 293 if (is_even(index) && dlen > 0 && !skipFirstSegment) {
293 addedSegment = true; 294 addedSegment = true;
295 ++segCount;
294 296
295 if (specialLine) { 297 if (specialLine) {
296 lineRec.addSegment(SkDoubleToScalar(distance), 298 lineRec.addSegment(SkDoubleToScalar(distance),
297 SkDoubleToScalar(distance + dlen), 299 SkDoubleToScalar(distance + dlen),
298 dst); 300 dst);
299 } else { 301 } else {
300 meas.getSegment(SkDoubleToScalar(distance), 302 meas.getSegment(SkDoubleToScalar(distance),
301 SkDoubleToScalar(distance + dlen), 303 SkDoubleToScalar(distance + dlen),
302 dst, true); 304 dst, true);
303 } 305 }
(...skipping 11 matching lines...) Expand all
315 } 317 }
316 318
317 // fetch our next dlen 319 // fetch our next dlen
318 dlen = SkScalarMul(intervals[index], scale); 320 dlen = SkScalarMul(intervals[index], scale);
319 } 321 }
320 322
321 // extend if we ended on a segment and we need to join up with the (skip ped) initial segment 323 // extend if we ended on a segment and we need to join up with the (skip ped) initial segment
322 if (meas.isClosed() && is_even(fInitialDashIndex) && 324 if (meas.isClosed() && is_even(fInitialDashIndex) &&
323 fInitialDashLength > 0) { 325 fInitialDashLength > 0) {
324 meas.getSegment(0, SkScalarMul(fInitialDashLength, scale), dst, !add edSegment); 326 meas.getSegment(0, SkScalarMul(fInitialDashLength, scale), dst, !add edSegment);
327 ++segCount;
325 } 328 }
326 } while (meas.nextContour()); 329 } while (meas.nextContour());
327 330
331 if (segCount > 1) {
332 dst->setConvexity(SkPath::kConcave_Convexity);
333 }
334
328 return true; 335 return true;
329 } 336 }
330 337
331 // Currently asPoints is more restrictive then it needs to be. In the future 338 // Currently asPoints is more restrictive then it needs to be. In the future
332 // we need to: 339 // we need to:
333 // allow kRound_Cap capping (could allow rotations in the matrix with this) 340 // allow kRound_Cap capping (could allow rotations in the matrix with this)
334 // allow paths to be returned 341 // allow paths to be returned
335 bool SkDashPathEffect::asPoints(PointData* results, 342 bool SkDashPathEffect::asPoints(PointData* results,
336 const SkPath& src, 343 const SkPath& src,
337 const SkStrokeRec& rec, 344 const SkStrokeRec& rec,
(...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after
543 SkDashPathEffect::SkDashPathEffect(SkFlattenableReadBuffer& buffer) : INHERITED( buffer) { 550 SkDashPathEffect::SkDashPathEffect(SkFlattenableReadBuffer& buffer) : INHERITED( buffer) {
544 fInitialDashIndex = buffer.readInt(); 551 fInitialDashIndex = buffer.readInt();
545 fInitialDashLength = buffer.readScalar(); 552 fInitialDashLength = buffer.readScalar();
546 fIntervalLength = buffer.readScalar(); 553 fIntervalLength = buffer.readScalar();
547 fScaleToFit = buffer.readBool(); 554 fScaleToFit = buffer.readBool();
548 555
549 fCount = buffer.getArrayCount(); 556 fCount = buffer.getArrayCount();
550 fIntervals = (SkScalar*)sk_malloc_throw(sizeof(SkScalar) * fCount); 557 fIntervals = (SkScalar*)sk_malloc_throw(sizeof(SkScalar) * fCount);
551 buffer.readScalarArray(fIntervals); 558 buffer.readScalarArray(fIntervals);
552 } 559 }
OLDNEW
« no previous file with comments | « src/core/SkPath.cpp ('k') | src/gpu/GrAARectRenderer.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698