Index: src/core/SkTextBlob.cpp |
diff --git a/src/core/SkTextBlob.cpp b/src/core/SkTextBlob.cpp |
index b815c263a8ddfcf659bc868d2b52d187cb946f10..4f1df970982f75c619cbb212b2bb47c326e4843f 100644 |
--- a/src/core/SkTextBlob.cpp |
+++ b/src/core/SkTextBlob.cpp |
@@ -318,7 +318,38 @@ void SkTextBlobBuilder::updateDeferredBounds() { |
return; |
} |
- // FIXME: measure the current run & union bounds |
+ SkASSERT(fLastRun >= sizeof(SkTextBlob)); |
+ SkTextBlob::RunRecord* run = reinterpret_cast<SkTextBlob::RunRecord*>(fStorage.get() + |
+ fLastRun); |
+ SkRect runBounds = SkRect::MakeEmpty(); |
+ if (SkTextBlob::kDefault_Positioning == run->positioning()) { |
+ run->font().measureText(run->glyphBuffer(), |
+ 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.
|
+ &runBounds); |
+ } else { |
+ SkTextBlob::GlyphPositioning positioning = run->positioning(); |
+ SkASSERT(SkTextBlob::kFull_Positioning == positioning |
+ || SkTextBlob::kHorizontal_Positioning == positioning); |
+ |
+ SkScalar* glyphOffset = run->posBuffer(); |
+ for (unsigned i = 0; i < run->glyphCount(); ++i) { |
+ SkRect glyphBounds; |
+ run->font().measureText(run->glyphBuffer() + i, |
+ sizeof(uint16_t), |
+ &glyphBounds); |
+ 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.
|
+ (SkTextBlob::kFull_Positioning == positioning) |
+ ? *(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
|
+ runBounds.join(glyphBounds); |
+ glyphOffset += SkTextBlob::ScalarsPerGlyph(positioning); |
+ } |
+ |
+ 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.
|
+ } |
+ |
+ runBounds.offset(run->offset()); |
+ |
+ fBounds.join(runBounds); |
fDeferredBounds = false; |
} |