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

Unified Diff: third_party/WebKit/Source/platform/fonts/Font.cpp

Issue 2416603002: Add ability to compute text intercepts to Font (Closed)
Patch Set: Rebased Created 4 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
Index: third_party/WebKit/Source/platform/fonts/Font.cpp
diff --git a/third_party/WebKit/Source/platform/fonts/Font.cpp b/third_party/WebKit/Source/platform/fonts/Font.cpp
index 271ed83045017fa02b64325d4b2f92c8b443bf4d..462e43864b0bde64426180e904fc788857f91270 100644
--- a/third_party/WebKit/Source/platform/fonts/Font.cpp
+++ b/third_party/WebKit/Source/platform/fonts/Font.cpp
@@ -407,6 +407,50 @@ void Font::drawGlyphBuffer(SkCanvas* canvas,
}
}
+int Font::getTextIntercepts(SkCanvas*,
+ const TextRunPaintInfo& runInfo,
+ float deviceScaleFactor,
+ const SkPaint& paint,
+ const SkScalar* bounds,
+ SkScalar* intervals) const {
+ if (shouldSkipDrawing())
+ return false;
f(malita) 2016/10/13 18:09:19 false -> 0?
drott 2016/10/14 15:15:34 Removed the return type.
+
+ if (runInfo.cachedTextBlob && runInfo.cachedTextBlob->get()) {
+ return paint.getTextBlobIntercepts(runInfo.cachedTextBlob->get(), bounds,
+ intervals);
+ }
+
+ GlyphBuffer glyphBuffer;
+ buildGlyphBuffer(runInfo, glyphBuffer);
+
+ GlyphBufferBloberizer bloberizer(glyphBuffer, this, deviceScaleFactor);
+ std::pair<sk_sp<SkTextBlob>, BlobRotation> blob;
+
+ int numIntervals = 0;
+ while (!bloberizer.done()) {
+ blob = bloberizer.next();
+ DCHECK(blob.first);
+
+ // GlyphBufferBloberizer splits for a new blob rotation, but does not split
+ // for a change in font. A TextBlob can contain runs with differing fonts
+ // and the getTextBlobIntercepts method handles multiple fonts for us. For
+ // upright in vertical blobs we currently have to bail, see crbug.com/655154
+ if (blob.second == BlobRotation::CCWRotation)
+ continue;
+
+ SkScalar* offsetIntervals = nullptr;
+ if (intervals) {
+ // Continue writing the results for the n-th blob after the previous few.
+ offsetIntervals = &intervals[numIntervals];
+ }
+ numIntervals +=
+ paint.getTextBlobIntercepts(blob.first.get(), bounds, offsetIntervals);
+ }
+
+ return numIntervals;
+}
+
static inline FloatRect pixelSnappedSelectionRect(FloatRect rect) {
// Using roundf() rather than ceilf() for the right edge as a compromise to
// ensure correct caret positioning.

Powered by Google App Engine
This is Rietveld 408576698