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

Side by Side Diff: Source/platform/fonts/Font.h

Issue 645363003: Consolidate most simple vs. complex Font methods (Closed) Base URL: svn://svn.chromium.org/blink/trunk
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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « Source/core/rendering/TextPainter.cpp ('k') | Source/platform/fonts/Font.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2000 Lars Knoll (knoll@kde.org) 2 * Copyright (C) 2000 Lars Knoll (knoll@kde.org)
3 * (C) 2000 Antti Koivisto (koivisto@kde.org) 3 * (C) 2000 Antti Koivisto (koivisto@kde.org)
4 * (C) 2000 Dirk Mueller (mueller@kde.org) 4 * (C) 2000 Dirk Mueller (mueller@kde.org)
5 * Copyright (C) 2003, 2006, 2007, 2010, 2011 Apple Inc. All rights reserved. 5 * Copyright (C) 2003, 2006, 2007, 2010, 2011 Apple Inc. All rights reserved.
6 * Copyright (C) 2008 Holger Hans Peter Freyther 6 * Copyright (C) 2008 Holger Hans Peter Freyther
7 * 7 *
8 * This library is free software; you can redistribute it and/or 8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Library General Public 9 * modify it under the terms of the GNU Library General Public
10 * License as published by the Free Software Foundation; either 10 * License as published by the Free Software Foundation; either
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
93 Font& operator=(const Font&); 93 Font& operator=(const Font&);
94 94
95 bool operator==(const Font& other) const; 95 bool operator==(const Font& other) const;
96 bool operator!=(const Font& other) const { return !(*this == other); } 96 bool operator!=(const Font& other) const { return !(*this == other); }
97 97
98 const FontDescription& fontDescription() const { return m_fontDescription; } 98 const FontDescription& fontDescription() const { return m_fontDescription; }
99 99
100 void update(PassRefPtrWillBeRawPtr<FontSelector>) const; 100 void update(PassRefPtrWillBeRawPtr<FontSelector>) const;
101 101
102 enum CustomFontNotReadyAction { DoNotPaintIfFontNotReady, UseFallbackIfFontN otReady }; 102 enum CustomFontNotReadyAction { DoNotPaintIfFontNotReady, UseFallbackIfFontN otReady };
103 float drawText(GraphicsContext*, const TextRunPaintInfo&, const FloatPoint&, CustomFontNotReadyAction = DoNotPaintIfFontNotReady) const; 103 void drawText(GraphicsContext*, const TextRunPaintInfo&, const FloatPoint&) const;
104 float drawUncachedText(GraphicsContext*, const TextRunPaintInfo&, const Floa tPoint&,
105 CustomFontNotReadyAction) const;
104 void drawEmphasisMarks(GraphicsContext*, const TextRunPaintInfo&, const Atom icString& mark, const FloatPoint&) const; 106 void drawEmphasisMarks(GraphicsContext*, const TextRunPaintInfo&, const Atom icString& mark, const FloatPoint&) const;
105 107
106 float width(const TextRun&, HashSet<const SimpleFontData*>* fallbackFonts = 0, GlyphOverflow* = 0) const; 108 float width(const TextRun&, HashSet<const SimpleFontData*>* fallbackFonts = 0, GlyphOverflow* = 0) const;
107 float width(const TextRun&, int& charsConsumed, Glyph& glyphId) const; 109 float width(const TextRun&, int& charsConsumed, Glyph& glyphId) const;
108 110
109 int offsetForPosition(const TextRun&, float position, bool includePartialGly phs) const; 111 int offsetForPosition(const TextRun&, float position, bool includePartialGly phs) const;
110 FloatRect selectionRectForText(const TextRun&, const FloatPoint&, int h, int from = 0, int to = -1, bool accountForGlyphBounds = false) const; 112 FloatRect selectionRectForText(const TextRun&, const FloatPoint&, int h, int from = 0, int to = -1, bool accountForGlyphBounds = false) const;
111 113
112 bool isFixedPitch() const; 114 bool isFixedPitch() const;
113 115
(...skipping 12 matching lines...) Expand all
126 inline GlyphData glyphDataForCharacter(UChar32& c, bool mirror, bool spaceNo rmalize = false, FontDataVariant variant = AutoVariant) const 128 inline GlyphData glyphDataForCharacter(UChar32& c, bool mirror, bool spaceNo rmalize = false, FontDataVariant variant = AutoVariant) const
127 { 129 {
128 return glyphDataAndPageForCharacter(c, mirror, spaceNormalize, variant). first; 130 return glyphDataAndPageForCharacter(c, mirror, spaceNormalize, variant). first;
129 } 131 }
130 132
131 std::pair<GlyphData, GlyphPage*> glyphDataAndPageForCharacter(UChar32&, bool mirror, bool normalizeSpace = false, FontDataVariant = AutoVariant) const; 133 std::pair<GlyphData, GlyphPage*> glyphDataAndPageForCharacter(UChar32&, bool mirror, bool normalizeSpace = false, FontDataVariant = AutoVariant) const;
132 bool primaryFontHasGlyphForCharacter(UChar32) const; 134 bool primaryFontHasGlyphForCharacter(UChar32) const;
133 135
134 CodePath codePath(const TextRunPaintInfo&) const; 136 CodePath codePath(const TextRunPaintInfo&) const;
135 137
136 PassTextBlobPtr buildTextBlob(const TextRunPaintInfo&, const FloatPoint& tex tOrigin, bool couldUseLCDRenderedText, CustomFontNotReadyAction = DoNotPaintIfFo ntNotReady) const;
137 void drawTextBlob(GraphicsContext*, const SkTextBlob*, const SkPoint& origin ) const;
138
139 private: 138 private:
140 enum ForTextEmphasisOrNot { NotForTextEmphasis, ForTextEmphasis }; 139 enum ForTextEmphasisOrNot { NotForTextEmphasis, ForTextEmphasis };
141 140
142 // Returns the initial in-stream advance. 141 // Returns the initial in-stream advance.
143 float getGlyphsAndAdvancesForSimpleText(const TextRunPaintInfo&, GlyphBuffer &, ForTextEmphasisOrNot = NotForTextEmphasis) const; 142 float buildGlyphBuffer(const TextRunPaintInfo&, GlyphBuffer&, ForTextEmphasi sOrNot = NotForTextEmphasis) const;
144 float drawSimpleText(GraphicsContext*, const TextRunPaintInfo&, const FloatP oint&) const; 143 PassTextBlobPtr buildTextBlob(const GlyphBuffer&, float initialAdvance, cons t FloatRect& bounds,
145 void drawEmphasisMarksForSimpleText(GraphicsContext*, const TextRunPaintInfo &, const AtomicString& mark, const FloatPoint&) const; 144 bool couldUseLCD) const;
146 void drawGlyphs(GraphicsContext*, const SimpleFontData*, const GlyphBuffer&, unsigned from, unsigned numGlyphs, const FloatPoint&, const FloatRect& textRect ) const; 145 void drawGlyphs(GraphicsContext*, const SimpleFontData*, const GlyphBuffer&, unsigned from, unsigned numGlyphs, const FloatPoint&, const FloatRect& textRect ) const;
146 void drawTextBlob(GraphicsContext*, const SkTextBlob*, const SkPoint& origin ) const;
147 float drawGlyphBuffer(GraphicsContext*, const TextRunPaintInfo&, const Glyph Buffer&, const FloatPoint&) const; 147 float drawGlyphBuffer(GraphicsContext*, const TextRunPaintInfo&, const Glyph Buffer&, const FloatPoint&) const;
148 void drawEmphasisMarks(GraphicsContext*, const TextRunPaintInfo&, const Glyp hBuffer&, const AtomicString&, const FloatPoint&) const; 148 void drawEmphasisMarks(GraphicsContext*, const TextRunPaintInfo&, const Glyp hBuffer&, const AtomicString&, const FloatPoint&) const;
149 float floatWidthForSimpleText(const TextRun&, HashSet<const SimpleFontData*> * fallbackFonts = 0, IntRectExtent* glyphBounds = 0) const; 149 float floatWidthForSimpleText(const TextRun&, HashSet<const SimpleFontData*> * fallbackFonts = 0, IntRectExtent* glyphBounds = 0) const;
150 int offsetForPositionForSimpleText(const TextRun&, float position, bool incl udePartialGlyphs) const; 150 int offsetForPositionForSimpleText(const TextRun&, float position, bool incl udePartialGlyphs) const;
151 FloatRect selectionRectForSimpleText(const TextRun&, const FloatPoint&, int h, int from, int to, bool accountForGlyphBounds) const; 151 FloatRect selectionRectForSimpleText(const TextRun&, const FloatPoint&, int h, int from, int to, bool accountForGlyphBounds) const;
152 152
153 bool getEmphasisMarkGlyphData(const AtomicString&, GlyphData&) const; 153 bool getEmphasisMarkGlyphData(const AtomicString&, GlyphData&) const;
154 154
155 // Returns the initial in-stream advance.
156 float getGlyphsAndAdvancesForComplexText(const TextRunPaintInfo&, GlyphBuffe r&, ForTextEmphasisOrNot = NotForTextEmphasis) const;
157 float drawComplexText(GraphicsContext*, const TextRunPaintInfo&, const Float Point&) const;
158 void drawEmphasisMarksForComplexText(GraphicsContext*, const TextRunPaintInf o&, const AtomicString& mark, const FloatPoint&) const;
159 float floatWidthForComplexText(const TextRun&, HashSet<const SimpleFontData* >* fallbackFonts, IntRectExtent* glyphBounds) const; 155 float floatWidthForComplexText(const TextRun&, HashSet<const SimpleFontData* >* fallbackFonts, IntRectExtent* glyphBounds) const;
160 int offsetForPositionForComplexText(const TextRun&, float position, bool inc ludePartialGlyphs) const; 156 int offsetForPositionForComplexText(const TextRun&, float position, bool inc ludePartialGlyphs) const;
161 FloatRect selectionRectForComplexText(const TextRun&, const FloatPoint&, int h, int from, int to) const; 157 FloatRect selectionRectForComplexText(const TextRun&, const FloatPoint&, int h, int from, int to) const;
162 158
163 PassTextBlobPtr buildTextBlobForSimpleText(const TextRunPaintInfo&, const Fl oatPoint& textOrigin, bool couldUseLCDRenderedText) const;
164 PassTextBlobPtr buildTextBlob(const GlyphBuffer&, float initialAdvance, cons t FloatRect& bounds, float& advance, bool couldUseLCD) const;
165
166 friend struct SimpleShaper; 159 friend struct SimpleShaper;
167 friend class SVGTextRunRenderingContext; 160 friend class SVGTextRunRenderingContext;
168 161
169 public: 162 public:
170 FontSelector* fontSelector() const; 163 FontSelector* fontSelector() const;
171 164
172 FontFallbackList* fontList() const { return m_fontFallbackList.get(); } 165 FontFallbackList* fontList() const { return m_fontFallbackList.get(); }
173 166
174 void willUseFontData(UChar32) const; 167 void willUseFontData(UChar32) const;
175 168
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
220 { 213 {
221 if (!tabSize) 214 if (!tabSize)
222 return fontDescription().letterSpacing(); 215 return fontDescription().letterSpacing();
223 float tabWidth = tabSize * fontData.spaceWidth() + fontDescription().letterS pacing(); 216 float tabWidth = tabSize * fontData.spaceWidth() + fontDescription().letterS pacing();
224 return tabWidth - fmodf(position, tabWidth); 217 return tabWidth - fmodf(position, tabWidth);
225 } 218 }
226 219
227 } // namespace blink 220 } // namespace blink
228 221
229 #endif 222 #endif
OLDNEW
« no previous file with comments | « Source/core/rendering/TextPainter.cpp ('k') | Source/platform/fonts/Font.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698