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

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

Issue 1411723005: Make SkTextBlob::RunIterator public. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: 2015-10-27 (Tuesday) 16:20:53 EDT Created 5 years, 1 month 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/SkDevice.cpp ('k') | src/core/SkTextBlobRunIterator.h » ('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 "SkTextBlobRunIterator.h"
9 9
10 #include "SkReadBuffer.h" 10 #include "SkReadBuffer.h"
11 #include "SkTypeface.h" 11 #include "SkTypeface.h"
12 #include "SkWriteBuffer.h" 12 #include "SkWriteBuffer.h"
13 13
14 namespace { 14 namespace {
15 15
16 // TODO(fmalita): replace with SkFont. 16 // TODO(fmalita): replace with SkFont.
17 class RunFont : SkNoncopyable { 17 class RunFont : SkNoncopyable {
18 public: 18 public:
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after
213 } 213 }
214 } 214 }
215 215
216 void SkTextBlob::flatten(SkWriteBuffer& buffer) const { 216 void SkTextBlob::flatten(SkWriteBuffer& buffer) const {
217 int runCount = fRunCount; 217 int runCount = fRunCount;
218 218
219 buffer.write32(runCount); 219 buffer.write32(runCount);
220 buffer.writeRect(fBounds); 220 buffer.writeRect(fBounds);
221 221
222 SkPaint runPaint; 222 SkPaint runPaint;
223 RunIterator it(this); 223 SkTextBlobRunIterator it(this);
224 while (!it.done()) { 224 while (!it.done()) {
225 SkASSERT(it.glyphCount() > 0); 225 SkASSERT(it.glyphCount() > 0);
226 226
227 buffer.write32(it.glyphCount()); 227 buffer.write32(it.glyphCount());
228 buffer.write32(it.positioning()); 228 buffer.write32(it.positioning());
229 buffer.writePoint(it.offset()); 229 buffer.writePoint(it.offset());
230 // This should go away when switching to SkFont 230 // This should go away when switching to SkFont
231 it.applyFontToPaint(&runPaint); 231 it.applyFontToPaint(&runPaint);
232 buffer.writePaint(runPaint); 232 buffer.writePaint(runPaint);
233 233
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
287 287
288 return blobBuilder.build(); 288 return blobBuilder.build();
289 } 289 }
290 290
291 unsigned SkTextBlob::ScalarsPerGlyph(GlyphPositioning pos) { 291 unsigned SkTextBlob::ScalarsPerGlyph(GlyphPositioning pos) {
292 // GlyphPositioning values are directly mapped to scalars-per-glyph. 292 // GlyphPositioning values are directly mapped to scalars-per-glyph.
293 SkASSERT(pos <= 2); 293 SkASSERT(pos <= 2);
294 return pos; 294 return pos;
295 } 295 }
296 296
297 SkTextBlob::RunIterator::RunIterator(const SkTextBlob* blob) 297 SkTextBlobRunIterator::SkTextBlobRunIterator(const SkTextBlob* blob)
298 : fCurrentRun(RunRecord::First(blob)) 298 : fCurrentRun(SkTextBlob::RunRecord::First(blob))
299 , fRemainingRuns(blob->fRunCount) { 299 , fRemainingRuns(blob->fRunCount) {
300 SkDEBUGCODE(fStorageTop = (uint8_t*)blob + blob->fStorageSize;) 300 SkDEBUGCODE(fStorageTop = (uint8_t*)blob + blob->fStorageSize;)
301 } 301 }
302 302
303 bool SkTextBlob::RunIterator::done() const { 303 bool SkTextBlobRunIterator::done() const {
304 return fRemainingRuns <= 0; 304 return fRemainingRuns <= 0;
305 } 305 }
306 306
307 void SkTextBlob::RunIterator::next() { 307 void SkTextBlobRunIterator::next() {
308 SkASSERT(!this->done()); 308 SkASSERT(!this->done());
309 309
310 if (!this->done()) { 310 if (!this->done()) {
311 SkDEBUGCODE(fCurrentRun->validate(fStorageTop);) 311 SkDEBUGCODE(fCurrentRun->validate(fStorageTop);)
312 fCurrentRun = RunRecord::Next(fCurrentRun); 312 fCurrentRun = SkTextBlob::RunRecord::Next(fCurrentRun);
313 fRemainingRuns--; 313 fRemainingRuns--;
314 } 314 }
315 } 315 }
316 316
317 uint32_t SkTextBlob::RunIterator::glyphCount() const { 317 uint32_t SkTextBlobRunIterator::glyphCount() const {
318 SkASSERT(!this->done()); 318 SkASSERT(!this->done());
319 return fCurrentRun->glyphCount(); 319 return fCurrentRun->glyphCount();
320 } 320 }
321 321
322 const uint16_t* SkTextBlob::RunIterator::glyphs() const { 322 const uint16_t* SkTextBlobRunIterator::glyphs() const {
323 SkASSERT(!this->done()); 323 SkASSERT(!this->done());
324 return fCurrentRun->glyphBuffer(); 324 return fCurrentRun->glyphBuffer();
325 } 325 }
326 326
327 const SkScalar* SkTextBlob::RunIterator::pos() const { 327 const SkScalar* SkTextBlobRunIterator::pos() const {
328 SkASSERT(!this->done()); 328 SkASSERT(!this->done());
329 return fCurrentRun->posBuffer(); 329 return fCurrentRun->posBuffer();
330 } 330 }
331 331
332 const SkPoint& SkTextBlob::RunIterator::offset() const { 332 const SkPoint& SkTextBlobRunIterator::offset() const {
333 SkASSERT(!this->done()); 333 SkASSERT(!this->done());
334 return fCurrentRun->offset(); 334 return fCurrentRun->offset();
335 } 335 }
336 336
337 SkTextBlob::GlyphPositioning SkTextBlob::RunIterator::positioning() const { 337 SkTextBlob::GlyphPositioning SkTextBlobRunIterator::positioning() const {
338 SkASSERT(!this->done()); 338 SkASSERT(!this->done());
339 return fCurrentRun->positioning(); 339 return fCurrentRun->positioning();
340 } 340 }
341 341
342 void SkTextBlob::RunIterator::applyFontToPaint(SkPaint* paint) const { 342 void SkTextBlobRunIterator::applyFontToPaint(SkPaint* paint) const {
343 SkASSERT(!this->done()); 343 SkASSERT(!this->done());
344 344
345 fCurrentRun->font().applyToPaint(paint); 345 fCurrentRun->font().applyToPaint(paint);
346 } 346 }
347 347
348 bool SkTextBlob::RunIterator::isLCD() const { 348 bool SkTextBlobRunIterator::isLCD() const {
349 return SkToBool(fCurrentRun->font().flags() & SkPaint::kLCDRenderText_Flag); 349 return SkToBool(fCurrentRun->font().flags() & SkPaint::kLCDRenderText_Flag);
350 } 350 }
351 351
352 SkTextBlobBuilder::SkTextBlobBuilder() 352 SkTextBlobBuilder::SkTextBlobBuilder()
353 : fStorageSize(0) 353 : fStorageSize(0)
354 , fStorageUsed(0) 354 , fStorageUsed(0)
355 , fRunCount(0) 355 , fRunCount(0)
356 , fDeferredBounds(false) 356 , fDeferredBounds(false)
357 , fLastRun(0) { 357 , fLastRun(0) {
358 fBounds.setEmpty(); 358 fBounds.setEmpty();
(...skipping 276 matching lines...) Expand 10 before | Expand all | Expand 10 after
635 635
636 fStorageUsed = 0; 636 fStorageUsed = 0;
637 fStorageSize = 0; 637 fStorageSize = 0;
638 fRunCount = 0; 638 fRunCount = 0;
639 fLastRun = 0; 639 fLastRun = 0;
640 fBounds.setEmpty(); 640 fBounds.setEmpty();
641 641
642 return blob; 642 return blob;
643 } 643 }
644 644
OLDNEW
« no previous file with comments | « src/core/SkDevice.cpp ('k') | src/core/SkTextBlobRunIterator.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698