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 300 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
311 } | 311 } |
312 } | 312 } |
313 | 313 |
314 void SkTextBlobBuilder::updateDeferredBounds() { | 314 void SkTextBlobBuilder::updateDeferredBounds() { |
315 SkASSERT(!fDeferredBounds || fRunCount > 0); | 315 SkASSERT(!fDeferredBounds || fRunCount > 0); |
316 | 316 |
317 if (!fDeferredBounds) { | 317 if (!fDeferredBounds) { |
318 return; | 318 return; |
319 } | 319 } |
320 | 320 |
321 // FIXME: measure the current run & union bounds | 321 SkASSERT(fLastRun >= sizeof(SkTextBlob)); |
322 SkTextBlob::RunRecord* run = reinterpret_cast<SkTextBlob::RunRecord*>(fStora ge.get() + | |
323 fLastR un); | |
324 SkRect runBounds = SkRect::MakeEmpty(); | |
325 if (SkTextBlob::kDefault_Positioning == run->positioning()) { | |
326 run->font().measureText(run->glyphBuffer(), | |
327 run->glyphCount() * sizeof(uint16_t), | |
mtklein
2014/10/16 17:03:59
So we're always GlyphID encoded in SkTextBlobs?
reed1
2014/10/16 17:06:17
agreed. If blobs require glyphs, then lets at leas
f(malita)
2014/10/16 17:21:56
We already do, when allocating runs (allocInternal
reed1
2014/10/16 17:27:18
the value of an assert here is to document that *t
f(malita)
2014/10/16 17:52:43
Done.
| |
328 &runBounds); | |
329 } else { | |
330 SkTextBlob::GlyphPositioning positioning = run->positioning(); | |
331 SkASSERT(SkTextBlob::kFull_Positioning == positioning | |
332 || SkTextBlob::kHorizontal_Positioning == positioning); | |
333 | |
334 SkScalar* glyphOffset = run->posBuffer(); | |
335 for (unsigned i = 0; i < run->glyphCount(); ++i) { | |
336 SkRect glyphBounds; | |
337 run->font().measureText(run->glyphBuffer() + i, | |
338 sizeof(uint16_t), | |
339 &glyphBounds); | |
340 glyphBounds.offset(*glyphOffset, | |
mtklein
2014/10/16 17:03:59
Can't hurt to comment this up a little, or perhaps
f(malita)
2014/10/16 17:21:56
Will do.
| |
341 (SkTextBlob::kFull_Positioning == positioning) | |
342 ? *(glyphOffset + 1) : 0); | |
mtklein
2014/10/16 17:06:20
Wait a sec, are the offsets relative to each other
f(malita)
2014/10/16 17:21:56
They're relative to the start, and measureText alw
| |
343 runBounds.join(glyphBounds); | |
344 glyphOffset += SkTextBlob::ScalarsPerGlyph(positioning); | |
345 } | |
346 | |
347 SkASSERT((void*)glyphOffset <= SkTextBlob::RunRecord::Next(run)); | |
mtklein
2014/10/16 17:03:59
Can we assert == here, or is there other data stor
f(malita)
2014/10/16 17:21:56
There's padding/alignment.
| |
348 } | |
349 | |
350 runBounds.offset(run->offset()); | |
351 | |
352 fBounds.join(runBounds); | |
322 fDeferredBounds = false; | 353 fDeferredBounds = false; |
323 } | 354 } |
324 | 355 |
325 void SkTextBlobBuilder::reserve(size_t size) { | 356 void SkTextBlobBuilder::reserve(size_t size) { |
326 // We don't currently pre-allocate, but maybe someday... | 357 // We don't currently pre-allocate, but maybe someday... |
327 if (fStorageUsed + size <= fStorageSize) { | 358 if (fStorageUsed + size <= fStorageSize) { |
328 return; | 359 return; |
329 } | 360 } |
330 | 361 |
331 if (0 == fRunCount) { | 362 if (0 == fRunCount) { |
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
482 | 513 |
483 fStorageUsed = 0; | 514 fStorageUsed = 0; |
484 fStorageSize = 0; | 515 fStorageSize = 0; |
485 fRunCount = 0; | 516 fRunCount = 0; |
486 fLastRun = 0; | 517 fLastRun = 0; |
487 fBounds.setEmpty(); | 518 fBounds.setEmpty(); |
488 | 519 |
489 return blob; | 520 return blob; |
490 } | 521 } |
491 | 522 |
OLD | NEW |