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

Unified Diff: Source/platform/fonts/Font.h

Issue 1179723002: Store glyph bounds in WordMeasurement to avoid slow path width calc (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Rebase Created 5 years, 6 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 | « Source/core/layout/line/WordMeasurement.h ('k') | Source/platform/fonts/Font.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/platform/fonts/Font.h
diff --git a/Source/platform/fonts/Font.h b/Source/platform/fonts/Font.h
index 22afbdd82df688d2836cac42b3fa8eab8cf4c430..5460b6a0d2c0370a1f65f2531bc62b47f8c834e5 100644
--- a/Source/platform/fonts/Font.h
+++ b/Source/platform/fonts/Font.h
@@ -61,32 +61,6 @@ struct TextRunPaintInfo;
struct GlyphData;
-struct GlyphOverflow {
- GlyphOverflow()
- : left(0)
- , right(0)
- , top(0)
- , bottom(0)
- , computeBounds(false)
- {
- }
-
- bool isZero() const
- {
- return !left && !right && !top && !bottom;
- }
-
- // If computeBounds, top and bottom are the maximum heights of the glyphs above and below the baseline, respectively.
- // Otherwise they are the amounts of glyph overflows exceeding the font metrics' ascent and descent, respectively.
- // Left and right are the amounts of glyph overflows exceeding the left and right edge of normal layout boundary, respectively.
- // All fields are in absolute number of pixels rounded up to the nearest integer.
- int left;
- int right;
- int top;
- int bottom;
- bool computeBounds;
-};
-
class PLATFORM_EXPORT Font {
public:
Font();
@@ -108,7 +82,9 @@ public:
void drawBidiText(SkCanvas*, const TextRunPaintInfo&, const FloatPoint&, CustomFontNotReadyAction, float deviceScaleFactor, const SkPaint&) const;
void drawEmphasisMarks(SkCanvas*, const TextRunPaintInfo&, const AtomicString& mark, const FloatPoint&, float deviceScaleFactor, const SkPaint&) const;
- float width(const TextRun&, HashSet<const SimpleFontData*>* fallbackFonts = 0, GlyphOverflow* = 0) const;
+ // Glyph bounds will be the minimum rect containing all glyph strokes, in coordinates using
+ // (<text run x position>, <baseline position>) as the origin.
+ float width(const TextRun&, HashSet<const SimpleFontData*>* fallbackFonts = nullptr, FloatRect* glyphBounds = nullptr) const;
int offsetForPosition(const TextRun&, float position, bool includePartialGlyphs) const;
FloatRect selectionRectForText(const TextRun&, const FloatPoint&, int h, int from = 0, int to = -1, bool accountForGlyphBounds = false) const;
@@ -143,13 +119,13 @@ private:
const FloatPoint&, const FloatRect& textRect, float deviceScaleFactor) const;
void drawTextBlob(SkCanvas*, const SkPaint&, const SkTextBlob*, const SkPoint& origin) const;
void drawGlyphBuffer(SkCanvas*, const SkPaint&, const TextRunPaintInfo&, const GlyphBuffer&, const FloatPoint&, float deviceScaleFactor) const;
- float floatWidthForSimpleText(const TextRun&, HashSet<const SimpleFontData*>* fallbackFonts = 0, FloatRectOutsets* glyphBounds = 0) const;
+ float floatWidthForSimpleText(const TextRun&, HashSet<const SimpleFontData*>* fallbackFonts = 0, FloatRect* glyphBounds = 0) const;
int offsetForPositionForSimpleText(const TextRun&, float position, bool includePartialGlyphs) const;
FloatRect selectionRectForSimpleText(const TextRun&, const FloatPoint&, int h, int from, int to, bool accountForGlyphBounds) const;
bool getEmphasisMarkGlyphData(const AtomicString&, GlyphData&) const;
- float floatWidthForComplexText(const TextRun&, HashSet<const SimpleFontData*>* fallbackFonts, FloatRectOutsets* glyphBounds) const;
+ float floatWidthForComplexText(const TextRun&, HashSet<const SimpleFontData*>* fallbackFonts, FloatRect* glyphBounds) const;
int offsetForPositionForComplexText(const TextRun&, float position, bool includePartialGlyphs) const;
FloatRect selectionRectForComplexText(const TextRun&, const FloatPoint&, int h, int from, int to) const;
« no previous file with comments | « Source/core/layout/line/WordMeasurement.h ('k') | Source/platform/fonts/Font.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698