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

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

Issue 1036613002: simple patch to always init SkTextBlob uniqueID (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 5 years, 9 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
« include/core/SkTextBlob.h ('K') | « include/core/SkTextBlob.h ('k') | no next file » | 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 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
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) {
mtklein 2015/03/24 20:45:08 let's do static int32_t gNextID = 1; static int32
115 static int32_t gTextBlobGenerationID; // = 0;
116
117 // loop in case our global wraps around, as we never want SK_InvalidGenID un iqueID
118 while (SK_InvalidGenID == fUniqueID) {
119 fUniqueID = sk_atomic_inc(&gTextBlobGenerationID) + 1;
120 }
114 } 121 }
115 122
116 SkTextBlob::~SkTextBlob() { 123 SkTextBlob::~SkTextBlob() {
117 const RunRecord* run = RunRecord::First(this); 124 const RunRecord* run = RunRecord::First(this);
118 for (int i = 0; i < fRunCount; ++i) { 125 for (int i = 0; i < fRunCount; ++i) {
119 const RunRecord* nextRun = RunRecord::Next(run); 126 const RunRecord* nextRun = RunRecord::Next(run);
120 SkDEBUGCODE(run->validate((uint8_t*)this + fStorageSize);) 127 SkDEBUGCODE(run->validate((uint8_t*)this + fStorageSize);)
121 run->~RunRecord(); 128 run->~RunRecord();
122 run = nextRun; 129 run = nextRun;
123 } 130 }
124 } 131 }
125 132
126 uint32_t SkTextBlob::uniqueID() const {
127 static int32_t gTextBlobGenerationID; // = 0;
128
129 // loop in case our global wraps around, as we never want to return SK_Inval idGenID
130 while (SK_InvalidGenID == fUniqueID) {
131 fUniqueID = sk_atomic_inc(&gTextBlobGenerationID) + 1;
132 }
133
134 return fUniqueID;
135 }
136
137 void SkTextBlob::flatten(SkWriteBuffer& buffer) const { 133 void SkTextBlob::flatten(SkWriteBuffer& buffer) const {
138 int runCount = fRunCount; 134 int runCount = fRunCount;
139 135
140 buffer.write32(runCount); 136 buffer.write32(runCount);
141 buffer.writeRect(fBounds); 137 buffer.writeRect(fBounds);
142 138
143 SkPaint runPaint; 139 SkPaint runPaint;
144 RunIterator it(this); 140 RunIterator it(this);
145 while (!it.done()) { 141 while (!it.done()) {
146 SkASSERT(it.glyphCount() > 0); 142 SkASSERT(it.glyphCount() > 0);
(...skipping 389 matching lines...) Expand 10 before | Expand all | Expand 10 after
536 532
537 fStorageUsed = 0; 533 fStorageUsed = 0;
538 fStorageSize = 0; 534 fStorageSize = 0;
539 fRunCount = 0; 535 fRunCount = 0;
540 fLastRun = 0; 536 fLastRun = 0;
541 fBounds.setEmpty(); 537 fBounds.setEmpty();
542 538
543 return blob; 539 return blob;
544 } 540 }
545 541
OLDNEW
« include/core/SkTextBlob.h ('K') | « include/core/SkTextBlob.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698