Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 /* | 1 /* |
| 2 * Copyright 2014 Google Inc. | 2 * Copyright 2014 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 "SkTextBlob.h" | 8 #include "SkTextBlob.h" |
| 9 | 9 |
| 10 #include "SkReadBuffer.h" | 10 #include "SkReadBuffer.h" |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 103 uint32_t fCount; | 103 uint32_t fCount; |
| 104 SkPoint fOffset; | 104 SkPoint fOffset; |
| 105 SkPaint fFont; | 105 SkPaint fFont; |
| 106 GlyphPositioning fPositioning; | 106 GlyphPositioning fPositioning; |
| 107 | 107 |
| 108 SkDEBUGCODE(unsigned fMagic;) | 108 SkDEBUGCODE(unsigned fMagic;) |
| 109 }; | 109 }; |
| 110 | 110 |
| 111 SkTextBlob::SkTextBlob(int runCount, const SkRect& bounds) | 111 SkTextBlob::SkTextBlob(int runCount, const SkRect& bounds) |
| 112 : fRunCount(runCount) | 112 : fRunCount(runCount) |
| 113 , fBounds(bounds) { | 113 , fBounds(bounds) |
| 114 , fUniqueID(SK_InvalidGenID) { | |
| 114 } | 115 } |
| 115 | 116 |
| 116 SkTextBlob::~SkTextBlob() { | 117 SkTextBlob::~SkTextBlob() { |
| 117 const RunRecord* run = RunRecord::First(this); | 118 const RunRecord* run = RunRecord::First(this); |
| 118 for (int i = 0; i < fRunCount; ++i) { | 119 for (int i = 0; i < fRunCount; ++i) { |
| 119 const RunRecord* nextRun = RunRecord::Next(run); | 120 const RunRecord* nextRun = RunRecord::Next(run); |
| 120 SkDEBUGCODE(run->validate((uint8_t*)this + fStorageSize);) | 121 SkDEBUGCODE(run->validate((uint8_t*)this + fStorageSize);) |
| 121 run->~RunRecord(); | 122 run->~RunRecord(); |
| 122 run = nextRun; | 123 run = nextRun; |
| 123 } | 124 } |
| 124 } | 125 } |
| 125 | 126 |
| 126 uint32_t SkTextBlob::uniqueID() const { | 127 uint32_t SkTextBlob::uniqueID() const { |
|
bsalomon
2015/03/24 16:27:53
Is it really worth populating this lazily? I know
joshualitt
2015/03/25 14:13:37
I have another CL out which addresses this
| |
| 127 static int32_t gTextBlobGenerationID; // = 0; | 128 static int32_t gTextBlobGenerationID; // = 0; |
| 128 | 129 |
| 129 // loop in case our global wraps around, as we never want to return SK_Inval idGenID | 130 // loop in case our global wraps around, as we never want to return SK_Inval idGenID |
| 130 while (SK_InvalidGenID == fUniqueID) { | 131 while (SK_InvalidGenID == fUniqueID) { |
| 131 fUniqueID = sk_atomic_inc(&gTextBlobGenerationID) + 1; | 132 fUniqueID = sk_atomic_inc(&gTextBlobGenerationID) + 1; |
| 132 } | 133 } |
| 133 | 134 |
| 134 return fUniqueID; | 135 return fUniqueID; |
| 135 } | 136 } |
| 136 | 137 |
| (...skipping 399 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 536 | 537 |
| 537 fStorageUsed = 0; | 538 fStorageUsed = 0; |
| 538 fStorageSize = 0; | 539 fStorageSize = 0; |
| 539 fRunCount = 0; | 540 fRunCount = 0; |
| 540 fLastRun = 0; | 541 fLastRun = 0; |
| 541 fBounds.setEmpty(); | 542 fBounds.setEmpty(); |
| 542 | 543 |
| 543 return blob; | 544 return blob; |
| 544 } | 545 } |
| 545 | 546 |
| OLD | NEW |