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

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

Issue 544233002: "NULL !=" = NULL (Closed) Base URL: https://skia.googlesource.com/skia.git@are
Patch Set: rebase Created 6 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/SkTMultiMap.h ('k') | src/core/SkUtils.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 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 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
105 return NULL; 105 return NULL;
106 } 106 }
107 } 107 }
108 108
109 return blobBuilder.build(); 109 return blobBuilder.build();
110 } 110 }
111 111
112 SkTextBlob::RunIterator::RunIterator(const SkTextBlob* blob) 112 SkTextBlob::RunIterator::RunIterator(const SkTextBlob* blob)
113 : fBlob(blob) 113 : fBlob(blob)
114 , fIndex(0) { 114 , fIndex(0) {
115 SkASSERT(NULL != blob); 115 SkASSERT(blob);
116 } 116 }
117 117
118 bool SkTextBlob::RunIterator::done() const { 118 bool SkTextBlob::RunIterator::done() const {
119 return NULL == fBlob->fRuns.get() || fIndex >= fBlob->fRuns->count(); 119 return NULL == fBlob->fRuns.get() || fIndex >= fBlob->fRuns->count();
120 } 120 }
121 121
122 void SkTextBlob::RunIterator::next() { 122 void SkTextBlob::RunIterator::next() {
123 SkASSERT(!this->done()); 123 SkASSERT(!this->done());
124 fIndex++; 124 fIndex++;
125 } 125 }
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
187 } 187 }
188 fBounds.setEmpty(); 188 fBounds.setEmpty();
189 } 189 }
190 190
191 SkTextBlobBuilder::~SkTextBlobBuilder() { 191 SkTextBlobBuilder::~SkTextBlobBuilder() {
192 // unused runs 192 // unused runs
193 SkDELETE(fRuns); 193 SkDELETE(fRuns);
194 } 194 }
195 195
196 void SkTextBlobBuilder::updateDeferredBounds() { 196 void SkTextBlobBuilder::updateDeferredBounds() {
197 SkASSERT(!fDeferredBounds || (NULL != fRuns && !fRuns->empty())); 197 SkASSERT(!fDeferredBounds || (fRuns && !fRuns->empty()));
198 198
199 if (!fDeferredBounds) { 199 if (!fDeferredBounds) {
200 return; 200 return;
201 } 201 }
202 202
203 // FIXME: measure the current run & union bounds 203 // FIXME: measure the current run & union bounds
204 fDeferredBounds = false; 204 fDeferredBounds = false;
205 } 205 }
206 206
207 void SkTextBlobBuilder::ensureRun(const SkPaint& font, SkTextBlob::GlyphPosition ing pos, 207 void SkTextBlobBuilder::ensureRun(const SkPaint& font, SkTextBlob::GlyphPosition ing pos,
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
242 int count, SkPoint offset, const SkRect* b ounds) { 242 int count, SkPoint offset, const SkRect* b ounds) {
243 SkASSERT(count > 0); 243 SkASSERT(count > 0);
244 244
245 this->ensureRun(font, positioning, offset); 245 this->ensureRun(font, positioning, offset);
246 246
247 unsigned posScalarsPerGlyph = SkTextBlob::ScalarsPerGlyph(positioning); 247 unsigned posScalarsPerGlyph = SkTextBlob::ScalarsPerGlyph(positioning);
248 248
249 fGlyphBuffer.append(count); 249 fGlyphBuffer.append(count);
250 fPosBuffer.append(count * posScalarsPerGlyph); 250 fPosBuffer.append(count * posScalarsPerGlyph);
251 251
252 SkASSERT(NULL != fRuns && !fRuns->empty()); 252 SkASSERT(fRuns && !fRuns->empty());
253 SkTextBlob::Run& run = fRuns->back(); 253 SkTextBlob::Run& run = fRuns->back();
254 254
255 run.count += count; 255 run.count += count;
256 256
257 // The current run might have been merged, so the start offset may point to prev run data. 257 // The current run might have been merged, so the start offset may point to prev run data.
258 // Start from the back (which always points to the end of the current run bu ffers) instead. 258 // Start from the back (which always points to the end of the current run bu ffers) instead.
259 fCurrentRunBuffer.glyphs = fGlyphBuffer.isEmpty() 259 fCurrentRunBuffer.glyphs = fGlyphBuffer.isEmpty()
260 ? NULL : fGlyphBuffer.end() - count; 260 ? NULL : fGlyphBuffer.end() - count;
261 SkASSERT(NULL == fCurrentRunBuffer.glyphs || fCurrentRunBuffer.glyphs >= fGl yphBuffer.begin()); 261 SkASSERT(NULL == fCurrentRunBuffer.glyphs || fCurrentRunBuffer.glyphs >= fGl yphBuffer.begin());
262 fCurrentRunBuffer.pos = fPosBuffer.isEmpty() 262 fCurrentRunBuffer.pos = fPosBuffer.isEmpty()
263 ? NULL : fPosBuffer.end() - count * posScalarsPerGlyph; 263 ? NULL : fPosBuffer.end() - count * posScalarsPerGlyph;
264 SkASSERT(NULL == fCurrentRunBuffer.pos || fCurrentRunBuffer.pos >= fPosBuffe r.begin()); 264 SkASSERT(NULL == fCurrentRunBuffer.pos || fCurrentRunBuffer.pos >= fPosBuffe r.begin());
265 265
266 if (!fDeferredBounds) { 266 if (!fDeferredBounds) {
267 if (NULL != bounds) { 267 if (bounds) {
268 fBounds.join(*bounds); 268 fBounds.join(*bounds);
269 } else { 269 } else {
270 fDeferredBounds = true; 270 fDeferredBounds = true;
271 } 271 }
272 } 272 }
273 } 273 }
274 274
275 const SkTextBlobBuilder::RunBuffer& SkTextBlobBuilder::allocRun(const SkPaint& f ont, int count, 275 const SkTextBlobBuilder::RunBuffer& SkTextBlobBuilder::allocRun(const SkPaint& f ont, int count,
276 SkScalar x, SkSc alar y, 276 SkScalar x, SkSc alar y,
277 const SkRect* bo unds) { 277 const SkRect* bo unds) {
(...skipping 16 matching lines...) Expand all
294 this->allocInternal(font, SkTextBlob::kFull_Positioning, count, SkPoint::Mak e(0, 0), bounds); 294 this->allocInternal(font, SkTextBlob::kFull_Positioning, count, SkPoint::Mak e(0, 0), bounds);
295 295
296 return fCurrentRunBuffer; 296 return fCurrentRunBuffer;
297 } 297 }
298 298
299 const SkTextBlob* SkTextBlobBuilder::build() { 299 const SkTextBlob* SkTextBlobBuilder::build() {
300 const SkTextBlob* blob; 300 const SkTextBlob* blob;
301 301
302 if (fGlyphBuffer.count() > 0) { 302 if (fGlyphBuffer.count() > 0) {
303 // we have some glyphs, construct a real blob 303 // we have some glyphs, construct a real blob
304 SkASSERT(NULL != fRuns && !fRuns->empty()); 304 SkASSERT(fRuns && !fRuns->empty());
305 305
306 this->updateDeferredBounds(); 306 this->updateDeferredBounds();
307 307
308 // ownership of all buffers is transferred to the blob 308 // ownership of all buffers is transferred to the blob
309 blob = SkNEW_ARGS(SkTextBlob, (fGlyphBuffer.detach(), 309 blob = SkNEW_ARGS(SkTextBlob, (fGlyphBuffer.detach(),
310 fPosBuffer.detach(), 310 fPosBuffer.detach(),
311 fRuns, 311 fRuns,
312 fBounds)); 312 fBounds));
313 fRuns = NULL; 313 fRuns = NULL;
314 fBounds.setEmpty(); 314 fBounds.setEmpty();
315 } else { 315 } else {
316 // empty blob 316 // empty blob
317 SkASSERT(NULL == fRuns || fRuns->empty()); 317 SkASSERT(NULL == fRuns || fRuns->empty());
318 SkASSERT(fBounds.isEmpty()); 318 SkASSERT(fBounds.isEmpty());
319 319
320 blob = SkNEW_ARGS(SkTextBlob, (NULL, NULL, NULL, SkRect::MakeEmpty())); 320 blob = SkNEW_ARGS(SkTextBlob, (NULL, NULL, NULL, SkRect::MakeEmpty()));
321 } 321 }
322 322
323 return blob; 323 return blob;
324 } 324 }
325 325
OLDNEW
« no previous file with comments | « src/core/SkTMultiMap.h ('k') | src/core/SkUtils.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698