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

Side by Side Diff: src/core/SkPathRef.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/SkPathMeasure.cpp ('k') | src/core/SkPictureContentInfo.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 2013 Google Inc. 2 * Copyright 2013 Google Inc.
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 "SkBuffer.h" 8 #include "SkBuffer.h"
9 #include "SkLazyPtr.h" 9 #include "SkLazyPtr.h"
10 #include "SkPath.h" 10 #include "SkPath.h"
(...skipping 17 matching lines...) Expand all
28 SkDEBUGCODE(sk_atomic_inc(&fPathRef->fEditorsAttached);) 28 SkDEBUGCODE(sk_atomic_inc(&fPathRef->fEditorsAttached);)
29 } 29 }
30 30
31 ////////////////////////////////////////////////////////////////////////////// 31 //////////////////////////////////////////////////////////////////////////////
32 32
33 SkPathRef::~SkPathRef() { 33 SkPathRef::~SkPathRef() {
34 this->callGenIDChangeListeners(); 34 this->callGenIDChangeListeners();
35 SkDEBUGCODE(this->validate();) 35 SkDEBUGCODE(this->validate();)
36 sk_free(fPoints); 36 sk_free(fPoints);
37 37
38 SkDEBUGCODE(fPoints = NULL;) 38 SkDEBUGCODE(fPoints = nullptr;)
39 SkDEBUGCODE(fVerbs = NULL;) 39 SkDEBUGCODE(fVerbs = nullptr;)
40 SkDEBUGCODE(fVerbCnt = 0x9999999;) 40 SkDEBUGCODE(fVerbCnt = 0x9999999;)
41 SkDEBUGCODE(fPointCnt = 0xAAAAAAA;) 41 SkDEBUGCODE(fPointCnt = 0xAAAAAAA;)
42 SkDEBUGCODE(fPointCnt = 0xBBBBBBB;) 42 SkDEBUGCODE(fPointCnt = 0xBBBBBBB;)
43 SkDEBUGCODE(fGenerationID = 0xEEEEEEEE;) 43 SkDEBUGCODE(fGenerationID = 0xEEEEEEEE;)
44 SkDEBUGCODE(fEditorsAttached = 0x7777777;) 44 SkDEBUGCODE(fEditorsAttached = 0x7777777;)
45 } 45 }
46 46
47 // As a template argument, this must have external linkage. 47 // As a template argument, this must have external linkage.
48 SkPathRef* sk_create_empty_pathref() { 48 SkPathRef* sk_create_empty_pathref() {
49 SkPathRef* empty = new SkPathRef; 49 SkPathRef* empty = new SkPathRef;
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
123 } 123 }
124 124
125 SkPathRef* SkPathRef::CreateFromBuffer(SkRBuffer* buffer) { 125 SkPathRef* SkPathRef::CreateFromBuffer(SkRBuffer* buffer) {
126 SkPathRef* ref = new SkPathRef; 126 SkPathRef* ref = new SkPathRef;
127 bool isOval; 127 bool isOval;
128 uint8_t segmentMask; 128 uint8_t segmentMask;
129 129
130 int32_t packed; 130 int32_t packed;
131 if (!buffer->readS32(&packed)) { 131 if (!buffer->readS32(&packed)) {
132 delete ref; 132 delete ref;
133 return NULL; 133 return nullptr;
134 } 134 }
135 135
136 ref->fIsFinite = (packed >> kIsFinite_SerializationShift) & 1; 136 ref->fIsFinite = (packed >> kIsFinite_SerializationShift) & 1;
137 segmentMask = (packed >> kSegmentMask_SerializationShift) & 0xF; 137 segmentMask = (packed >> kSegmentMask_SerializationShift) & 0xF;
138 isOval = (packed >> kIsOval_SerializationShift) & 1; 138 isOval = (packed >> kIsOval_SerializationShift) & 1;
139 139
140 int32_t verbCount, pointCount, conicCount; 140 int32_t verbCount, pointCount, conicCount;
141 if (!buffer->readU32(&(ref->fGenerationID)) || 141 if (!buffer->readU32(&(ref->fGenerationID)) ||
142 !buffer->readS32(&verbCount) || 142 !buffer->readS32(&verbCount) ||
143 !buffer->readS32(&pointCount) || 143 !buffer->readS32(&pointCount) ||
144 !buffer->readS32(&conicCount)) { 144 !buffer->readS32(&conicCount)) {
145 delete ref; 145 delete ref;
146 return NULL; 146 return nullptr;
147 } 147 }
148 148
149 ref->resetToSize(verbCount, pointCount, conicCount); 149 ref->resetToSize(verbCount, pointCount, conicCount);
150 SkASSERT(verbCount == ref->countVerbs()); 150 SkASSERT(verbCount == ref->countVerbs());
151 SkASSERT(pointCount == ref->countPoints()); 151 SkASSERT(pointCount == ref->countPoints());
152 SkASSERT(conicCount == ref->fConicWeights.count()); 152 SkASSERT(conicCount == ref->fConicWeights.count());
153 153
154 if (!buffer->read(ref->verbsMemWritable(), verbCount * sizeof(uint8_t)) || 154 if (!buffer->read(ref->verbsMemWritable(), verbCount * sizeof(uint8_t)) ||
155 !buffer->read(ref->fPoints, pointCount * sizeof(SkPoint)) || 155 !buffer->read(ref->fPoints, pointCount * sizeof(SkPoint)) ||
156 !buffer->read(ref->fConicWeights.begin(), conicCount * sizeof(SkScalar)) || 156 !buffer->read(ref->fConicWeights.begin(), conicCount * sizeof(SkScalar)) ||
157 !buffer->read(&ref->fBounds, sizeof(SkRect))) { 157 !buffer->read(&ref->fBounds, sizeof(SkRect))) {
158 delete ref; 158 delete ref;
159 return NULL; 159 return nullptr;
160 } 160 }
161 ref->fBoundsIsDirty = false; 161 ref->fBoundsIsDirty = false;
162 162
163 // resetToSize clears fSegmentMask and fIsOval 163 // resetToSize clears fSegmentMask and fIsOval
164 ref->fSegmentMask = segmentMask; 164 ref->fSegmentMask = segmentMask;
165 ref->fIsOval = isOval; 165 ref->fIsOval = isOval;
166 return ref; 166 return ref;
167 } 167 }
168 168
169 void SkPathRef::Rewind(SkAutoTUnref<SkPathRef>* pathRef) { 169 void SkPathRef::Rewind(SkAutoTUnref<SkPathRef>* pathRef) {
(...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after
436 // empty ID 436 // empty ID
437 do { 437 do {
438 fGenerationID = (sk_atomic_inc(&gPathRefGenerationID) + 1) & kMa sk; 438 fGenerationID = (sk_atomic_inc(&gPathRefGenerationID) + 1) & kMa sk;
439 } while (fGenerationID <= kEmptyGenID); 439 } while (fGenerationID <= kEmptyGenID);
440 } 440 }
441 } 441 }
442 return fGenerationID; 442 return fGenerationID;
443 } 443 }
444 444
445 void SkPathRef::addGenIDChangeListener(GenIDChangeListener* listener) { 445 void SkPathRef::addGenIDChangeListener(GenIDChangeListener* listener) {
446 if (NULL == listener || this == empty.get()) { 446 if (nullptr == listener || this == empty.get()) {
447 delete listener; 447 delete listener;
448 return; 448 return;
449 } 449 }
450 *fGenIDChangeListeners.append() = listener; 450 *fGenIDChangeListeners.append() = listener;
451 } 451 }
452 452
453 // we need to be called *before* the genID gets changed or zerod 453 // we need to be called *before* the genID gets changed or zerod
454 void SkPathRef::callGenIDChangeListeners() { 454 void SkPathRef::callGenIDChangeListeners() {
455 for (int i = 0; i < fGenIDChangeListeners.count(); i++) { 455 for (int i = 0; i < fGenIDChangeListeners.count(); i++) {
456 fGenIDChangeListeners[i]->onChange(); 456 fGenIDChangeListeners[i]->onChange();
457 } 457 }
458 458
459 // Listeners get at most one shot, so whether these triggered or not, blow t hem away. 459 // Listeners get at most one shot, so whether these triggered or not, blow t hem away.
460 fGenIDChangeListeners.deleteAll(); 460 fGenIDChangeListeners.deleteAll();
461 } 461 }
462 462
463 #ifdef SK_DEBUG 463 #ifdef SK_DEBUG
464 void SkPathRef::validate() const { 464 void SkPathRef::validate() const {
465 this->INHERITED::validate(); 465 this->INHERITED::validate();
466 SkASSERT(static_cast<ptrdiff_t>(fFreeSpace) >= 0); 466 SkASSERT(static_cast<ptrdiff_t>(fFreeSpace) >= 0);
467 SkASSERT(reinterpret_cast<intptr_t>(fVerbs) - reinterpret_cast<intptr_t>(fPo ints) >= 0); 467 SkASSERT(reinterpret_cast<intptr_t>(fVerbs) - reinterpret_cast<intptr_t>(fPo ints) >= 0);
468 SkASSERT((NULL == fPoints) == (NULL == fVerbs)); 468 SkASSERT((nullptr == fPoints) == (nullptr == fVerbs));
469 SkASSERT(!(NULL == fPoints && 0 != fFreeSpace)); 469 SkASSERT(!(nullptr == fPoints && 0 != fFreeSpace));
470 SkASSERT(!(NULL == fPoints && 0 != fFreeSpace)); 470 SkASSERT(!(nullptr == fPoints && 0 != fFreeSpace));
471 SkASSERT(!(NULL == fPoints && fPointCnt)); 471 SkASSERT(!(nullptr == fPoints && fPointCnt));
472 SkASSERT(!(NULL == fVerbs && fVerbCnt)); 472 SkASSERT(!(nullptr == fVerbs && fVerbCnt));
473 SkASSERT(this->currSize() == 473 SkASSERT(this->currSize() ==
474 fFreeSpace + sizeof(SkPoint) * fPointCnt + sizeof(uint8_t) * fVe rbCnt); 474 fFreeSpace + sizeof(SkPoint) * fPointCnt + sizeof(uint8_t) * fVe rbCnt);
475 475
476 if (!fBoundsIsDirty && !fBounds.isEmpty()) { 476 if (!fBoundsIsDirty && !fBounds.isEmpty()) {
477 bool isFinite = true; 477 bool isFinite = true;
478 for (int i = 0; i < fPointCnt; ++i) { 478 for (int i = 0; i < fPointCnt; ++i) {
479 #ifdef SK_DEBUG 479 #ifdef SK_DEBUG
480 if (fPoints[i].isFinite() && 480 if (fPoints[i].isFinite() &&
481 (fPoints[i].fX < fBounds.fLeft || fPoints[i].fX > fBounds.fRight || 481 (fPoints[i].fX < fBounds.fLeft || fPoints[i].fX > fBounds.fRight ||
482 fPoints[i].fY < fBounds.fTop || fPoints[i].fY > fBounds.fBottom )) { 482 fPoints[i].fY < fBounds.fTop || fPoints[i].fY > fBounds.fBottom )) {
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
526 break; 526 break;
527 default: 527 default:
528 SkDEBUGFAIL("Unknown Verb"); 528 SkDEBUGFAIL("Unknown Verb");
529 break; 529 break;
530 } 530 }
531 } 531 }
532 SkASSERT(mask == fSegmentMask); 532 SkASSERT(mask == fSegmentMask);
533 #endif // SK_DEBUG_PATH 533 #endif // SK_DEBUG_PATH
534 } 534 }
535 #endif 535 #endif
OLDNEW
« no previous file with comments | « src/core/SkPathMeasure.cpp ('k') | src/core/SkPictureContentInfo.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698