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

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

Issue 1316233002: Style Change: NULL->nullptr (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: 2015-08-27 (Thursday) 10:25:06 EDT Created 5 years, 3 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/SkPath.cpp ('k') | src/core/SkPathRef.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 2008 The Android Open Source Project 3 * Copyright 2008 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 "SkPathMeasure.h" 10 #include "SkPathMeasure.h"
(...skipping 279 matching lines...) Expand 10 before | Expand all | Expand 10 after
290 tangent->normalize(); 290 tangent->normalize();
291 } 291 }
292 break; 292 break;
293 case kConic_SegType: { 293 case kConic_SegType: {
294 SkConic(pts[0], pts[2], pts[3], pts[1].fX).evalAt(t, pos, tangent); 294 SkConic(pts[0], pts[2], pts[3], pts[1].fX).evalAt(t, pos, tangent);
295 if (tangent) { 295 if (tangent) {
296 tangent->normalize(); 296 tangent->normalize();
297 } 297 }
298 } break; 298 } break;
299 case kCubic_SegType: 299 case kCubic_SegType:
300 SkEvalCubicAt(pts, t, pos, tangent, NULL); 300 SkEvalCubicAt(pts, t, pos, tangent, nullptr);
301 if (tangent) { 301 if (tangent) {
302 tangent->normalize(); 302 tangent->normalize();
303 } 303 }
304 break; 304 break;
305 default: 305 default:
306 SkDEBUGFAIL("unknown segType"); 306 SkDEBUGFAIL("unknown segType");
307 } 307 }
308 } 308 }
309 309
310 static void seg_to(const SkPoint pts[], int segType, 310 static void seg_to(const SkPoint pts[], int segType,
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
395 default: 395 default:
396 SkDEBUGFAIL("unknown segType"); 396 SkDEBUGFAIL("unknown segType");
397 sk_throw(); 397 sk_throw();
398 } 398 }
399 } 399 }
400 400
401 //////////////////////////////////////////////////////////////////////////////// 401 ////////////////////////////////////////////////////////////////////////////////
402 //////////////////////////////////////////////////////////////////////////////// 402 ////////////////////////////////////////////////////////////////////////////////
403 403
404 SkPathMeasure::SkPathMeasure() { 404 SkPathMeasure::SkPathMeasure() {
405 fPath = NULL; 405 fPath = nullptr;
406 fLength = -1; // signal we need to compute it 406 fLength = -1; // signal we need to compute it
407 fForceClosed = false; 407 fForceClosed = false;
408 fFirstPtIndex = -1; 408 fFirstPtIndex = -1;
409 } 409 }
410 410
411 SkPathMeasure::SkPathMeasure(const SkPath& path, bool forceClosed) { 411 SkPathMeasure::SkPathMeasure(const SkPath& path, bool forceClosed) {
412 fPath = &path; 412 fPath = &path;
413 fLength = -1; // signal we need to compute it 413 fLength = -1; // signal we need to compute it
414 fForceClosed = forceClosed; 414 fForceClosed = forceClosed;
415 fFirstPtIndex = -1; 415 fFirstPtIndex = -1;
(...skipping 12 matching lines...) Expand all
428 fFirstPtIndex = -1; 428 fFirstPtIndex = -1;
429 429
430 if (path) { 430 if (path) {
431 fIter.setPath(*path, forceClosed); 431 fIter.setPath(*path, forceClosed);
432 } 432 }
433 fSegments.reset(); 433 fSegments.reset();
434 fPts.reset(); 434 fPts.reset();
435 } 435 }
436 436
437 SkScalar SkPathMeasure::getLength() { 437 SkScalar SkPathMeasure::getLength() {
438 if (fPath == NULL) { 438 if (fPath == nullptr) {
439 return 0; 439 return 0;
440 } 440 }
441 if (fLength < 0) { 441 if (fLength < 0) {
442 this->buildSegments(); 442 this->buildSegments();
443 } 443 }
444 SkASSERT(fLength >= 0); 444 SkASSERT(fLength >= 0);
445 return fLength; 445 return fLength;
446 } 446 }
447 447
448 template <typename T, typename K> 448 template <typename T, typename K>
449 int SkTKSearch(const T base[], int count, const K& key) { 449 int SkTKSearch(const T base[], int count, const K& key) {
450 SkASSERT(count >= 0); 450 SkASSERT(count >= 0);
451 if (count <= 0) { 451 if (count <= 0) {
452 return ~0; 452 return ~0;
453 } 453 }
454 454
455 SkASSERT(base != NULL); // base may be NULL if count is zero 455 SkASSERT(base != nullptr); // base may be nullptr if count is zero
456 456
457 int lo = 0; 457 int lo = 0;
458 int hi = count - 1; 458 int hi = count - 1;
459 459
460 while (lo < hi) { 460 while (lo < hi) {
461 int mid = (hi + lo) >> 1; 461 int mid = (hi + lo) >> 1;
462 if (base[mid].fDistance < key) { 462 if (base[mid].fDistance < key) {
463 lo = mid + 1; 463 lo = mid + 1;
464 } else { 464 } else {
465 hi = mid; 465 hi = mid;
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
504 SkASSERT(seg->fDistance > startD); 504 SkASSERT(seg->fDistance > startD);
505 505
506 *t = startT + SkScalarMulDiv(seg->getScalarT() - startT, 506 *t = startT + SkScalarMulDiv(seg->getScalarT() - startT,
507 distance - startD, 507 distance - startD,
508 seg->fDistance - startD); 508 seg->fDistance - startD);
509 return seg; 509 return seg;
510 } 510 }
511 511
512 bool SkPathMeasure::getPosTan(SkScalar distance, SkPoint* pos, 512 bool SkPathMeasure::getPosTan(SkScalar distance, SkPoint* pos,
513 SkVector* tangent) { 513 SkVector* tangent) {
514 if (NULL == fPath) { 514 if (nullptr == fPath) {
515 return false; 515 return false;
516 } 516 }
517 517
518 SkScalar length = this->getLength(); // call this to force computing it 518 SkScalar length = this->getLength(); // call this to force computing it
519 int count = fSegments.count(); 519 int count = fSegments.count();
520 520
521 if (count == 0 || length == 0) { 521 if (count == 0 || length == 0) {
522 return false; 522 return false;
523 } 523 }
524 524
525 // pin the distance to a legal range 525 // pin the distance to a legal range
526 if (distance < 0) { 526 if (distance < 0) {
527 distance = 0; 527 distance = 0;
528 } else if (distance > length) { 528 } else if (distance > length) {
529 distance = length; 529 distance = length;
530 } 530 }
531 531
532 SkScalar t; 532 SkScalar t;
533 const Segment* seg = this->distanceToSegment(distance, &t); 533 const Segment* seg = this->distanceToSegment(distance, &t);
534 534
535 compute_pos_tan(&fPts[seg->fPtIndex], seg->fType, t, pos, tangent); 535 compute_pos_tan(&fPts[seg->fPtIndex], seg->fType, t, pos, tangent);
536 return true; 536 return true;
537 } 537 }
538 538
539 bool SkPathMeasure::getMatrix(SkScalar distance, SkMatrix* matrix, 539 bool SkPathMeasure::getMatrix(SkScalar distance, SkMatrix* matrix,
540 MatrixFlags flags) { 540 MatrixFlags flags) {
541 if (NULL == fPath) { 541 if (nullptr == fPath) {
542 return false; 542 return false;
543 } 543 }
544 544
545 SkPoint position; 545 SkPoint position;
546 SkVector tangent; 546 SkVector tangent;
547 547
548 if (this->getPosTan(distance, &position, &tangent)) { 548 if (this->getPosTan(distance, &position, &tangent)) {
549 if (matrix) { 549 if (matrix) {
550 if (flags & kGetTangent_MatrixFlag) { 550 if (flags & kGetTangent_MatrixFlag) {
551 matrix->setSinCos(tangent.fY, tangent.fX, 0, 0); 551 matrix->setSinCos(tangent.fY, tangent.fX, 0, 0);
(...skipping 25 matching lines...) Expand all
577 return false; 577 return false;
578 } 578 }
579 579
580 SkPoint p; 580 SkPoint p;
581 SkScalar startT, stopT; 581 SkScalar startT, stopT;
582 const Segment* seg = this->distanceToSegment(startD, &startT); 582 const Segment* seg = this->distanceToSegment(startD, &startT);
583 const Segment* stopSeg = this->distanceToSegment(stopD, &stopT); 583 const Segment* stopSeg = this->distanceToSegment(stopD, &stopT);
584 SkASSERT(seg <= stopSeg); 584 SkASSERT(seg <= stopSeg);
585 585
586 if (startWithMoveTo) { 586 if (startWithMoveTo) {
587 compute_pos_tan(&fPts[seg->fPtIndex], seg->fType, startT, &p, NULL); 587 compute_pos_tan(&fPts[seg->fPtIndex], seg->fType, startT, &p, nullptr);
588 dst->moveTo(p); 588 dst->moveTo(p);
589 } 589 }
590 590
591 if (seg->fPtIndex == stopSeg->fPtIndex) { 591 if (seg->fPtIndex == stopSeg->fPtIndex) {
592 seg_to(&fPts[seg->fPtIndex], seg->fType, startT, stopT, dst); 592 seg_to(&fPts[seg->fPtIndex], seg->fType, startT, stopT, dst);
593 } else { 593 } else {
594 do { 594 do {
595 seg_to(&fPts[seg->fPtIndex], seg->fType, startT, SK_Scalar1, dst); 595 seg_to(&fPts[seg->fPtIndex], seg->fType, startT, SK_Scalar1, dst);
596 seg = SkPathMeasure::NextSegment(seg); 596 seg = SkPathMeasure::NextSegment(seg);
597 startT = 0; 597 startT = 0;
(...skipping 26 matching lines...) Expand all
624 624
625 for (int i = 0; i < fSegments.count(); i++) { 625 for (int i = 0; i < fSegments.count(); i++) {
626 const Segment* seg = &fSegments[i]; 626 const Segment* seg = &fSegments[i];
627 SkDebugf("pathmeas: seg[%d] distance=%g, point=%d, t=%g, type=%d\n", 627 SkDebugf("pathmeas: seg[%d] distance=%g, point=%d, t=%g, type=%d\n",
628 i, seg->fDistance, seg->fPtIndex, seg->getScalarT(), 628 i, seg->fDistance, seg->fPtIndex, seg->getScalarT(),
629 seg->fType); 629 seg->fType);
630 } 630 }
631 } 631 }
632 632
633 #endif 633 #endif
OLDNEW
« no previous file with comments | « src/core/SkPath.cpp ('k') | src/core/SkPathRef.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698