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

Unified Diff: src/core/SkTextBlob.cpp

Issue 654873003: Implicit SkTextBlob bounds (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: minor cleanup Created 6 years, 2 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/core/SkRecordDraw.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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;
}
« no previous file with comments | « src/core/SkRecordDraw.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698