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

Side by Side Diff: Source/core/platform/graphics/Font.h

Issue 14160005: Track the region where text is painted. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: implemented TextRun wrapper Created 7 years, 7 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/platform/chromium/PopupListBox.cpp ('k') | Source/core/platform/graphics/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 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
47 class FloatRect; 47 class FloatRect;
48 class FontData; 48 class FontData;
49 class FontMetrics; 49 class FontMetrics;
50 class FontPlatformData; 50 class FontPlatformData;
51 class FontSelector; 51 class FontSelector;
52 class GlyphBuffer; 52 class GlyphBuffer;
53 class GraphicsContext; 53 class GraphicsContext;
54 class RenderText; 54 class RenderText;
55 class TextLayout; 55 class TextLayout;
56 class TextRun; 56 class TextRun;
57 struct TextRunPaintInfo;
57 58
58 struct GlyphData; 59 struct GlyphData;
59 60
60 struct GlyphOverflow { 61 struct GlyphOverflow {
61 GlyphOverflow() 62 GlyphOverflow()
62 : left(0) 63 : left(0)
63 , right(0) 64 , right(0)
64 , top(0) 65 , top(0)
65 , bottom(0) 66 , bottom(0)
66 , computeBounds(false) 67 , computeBounds(false)
(...skipping 23 matching lines...) Expand all
90 bool operator!=(const Font& other) const { return !(*this == other); } 91 bool operator!=(const Font& other) const { return !(*this == other); }
91 92
92 const FontDescription& fontDescription() const { return m_fontDescription; } 93 const FontDescription& fontDescription() const { return m_fontDescription; }
93 94
94 int pixelSize() const { return fontDescription().computedPixelSize(); } 95 int pixelSize() const { return fontDescription().computedPixelSize(); }
95 float size() const { return fontDescription().computedSize(); } 96 float size() const { return fontDescription().computedSize(); }
96 97
97 void update(PassRefPtr<FontSelector>) const; 98 void update(PassRefPtr<FontSelector>) const;
98 99
99 enum CustomFontNotReadyAction { DoNotPaintIfFontNotReady, UseFallbackIfFontN otReady }; 100 enum CustomFontNotReadyAction { DoNotPaintIfFontNotReady, UseFallbackIfFontN otReady };
100 void drawText(GraphicsContext*, const TextRun&, const FloatPoint&, int from = 0, int to = -1, CustomFontNotReadyAction = DoNotPaintIfFontNotReady) const; 101 void drawText(GraphicsContext*, const TextRunPaintInfo&, const FloatPoint&, CustomFontNotReadyAction = DoNotPaintIfFontNotReady) const;
101 void drawEmphasisMarks(GraphicsContext*, const TextRun&, const AtomicString& mark, const FloatPoint&, int from = 0, int to = -1) const; 102 void drawEmphasisMarks(GraphicsContext*, const TextRunPaintInfo&, const Atom icString& mark, const FloatPoint&) const;
102 103
103 float width(const TextRun&, HashSet<const SimpleFontData*>* fallbackFonts = 0, GlyphOverflow* = 0) const; 104 float width(const TextRun&, HashSet<const SimpleFontData*>* fallbackFonts = 0, GlyphOverflow* = 0) const;
104 float width(const TextRun&, int& charsConsumed, String& glyphName) const; 105 float width(const TextRun&, int& charsConsumed, String& glyphName) const;
105 106
106 PassOwnPtr<TextLayout> createLayout(RenderText*, float xPos, bool collapseWh iteSpace) const; 107 PassOwnPtr<TextLayout> createLayout(RenderText*, float xPos, bool collapseWh iteSpace) const;
107 static void deleteLayout(TextLayout*); 108 static void deleteLayout(TextLayout*);
108 static float width(TextLayout&, unsigned from, unsigned len, HashSet<const S impleFontData*>* fallbackFonts = 0); 109 static float width(TextLayout&, unsigned from, unsigned len, HashSet<const S impleFontData*>* fallbackFonts = 0);
109 110
110 int offsetForPosition(const TextRun&, float position, bool includePartialGly phs) const; 111 int offsetForPosition(const TextRun&, float position, bool includePartialGly phs) const;
111 FloatRect selectionRectForText(const TextRun&, const FloatPoint&, int h, int from = 0, int to = -1) const; 112 FloatRect selectionRectForText(const TextRun&, const FloatPoint&, int h, int from = 0, int to = -1) const;
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
166 enum CodePath { Auto, Simple, Complex, SimpleWithGlyphOverflow }; 167 enum CodePath { Auto, Simple, Complex, SimpleWithGlyphOverflow };
167 CodePath codePath(const TextRun&) const; 168 CodePath codePath(const TextRun&) const;
168 static CodePath characterRangeCodePath(const LChar*, unsigned) { return Simp le; } 169 static CodePath characterRangeCodePath(const LChar*, unsigned) { return Simp le; }
169 static CodePath characterRangeCodePath(const UChar*, unsigned len); 170 static CodePath characterRangeCodePath(const UChar*, unsigned len);
170 171
171 private: 172 private:
172 enum ForTextEmphasisOrNot { NotForTextEmphasis, ForTextEmphasis }; 173 enum ForTextEmphasisOrNot { NotForTextEmphasis, ForTextEmphasis };
173 174
174 // Returns the initial in-stream advance. 175 // Returns the initial in-stream advance.
175 float getGlyphsAndAdvancesForSimpleText(const TextRun&, int from, int to, Gl yphBuffer&, ForTextEmphasisOrNot = NotForTextEmphasis) const; 176 float getGlyphsAndAdvancesForSimpleText(const TextRun&, int from, int to, Gl yphBuffer&, ForTextEmphasisOrNot = NotForTextEmphasis) const;
176 void drawSimpleText(GraphicsContext*, const TextRun&, const FloatPoint&, int from, int to) const; 177 void drawSimpleText(GraphicsContext*, const TextRunPaintInfo&, const FloatPo int&) const;
177 void drawEmphasisMarksForSimpleText(GraphicsContext*, const TextRun&, const AtomicString& mark, const FloatPoint&, int from, int to) const; 178 void drawEmphasisMarksForSimpleText(GraphicsContext*, const TextRunPaintInfo &, const AtomicString& mark, const FloatPoint&) const;
178 void drawGlyphs(GraphicsContext*, const SimpleFontData*, const GlyphBuffer&, int from, int to, const FloatPoint&) const; 179 void drawGlyphs(GraphicsContext*, const SimpleFontData*, const GlyphBuffer&, int from, int to, const FloatPoint&, const FloatRect& textRect) const;
bungeman-chromium 2013/05/06 19:30:43 Any reason why this is just a FloatRect?
alokp 2013/05/06 20:39:54 I do not understand. If you mean why drawGlyphs do
bungeman-chromium 2013/05/06 21:02:31 Hmmm... I see. The use case I had in mind meant pa
alokp 2013/05/06 22:12:34 Yes. Extra information could either be added direc
179 void drawGlyphBuffer(GraphicsContext*, const TextRun&, const GlyphBuffer&, c onst FloatPoint&) const; 180 void drawGlyphBuffer(GraphicsContext*, const TextRunPaintInfo&, const GlyphB uffer&, const FloatPoint&) const;
180 void drawEmphasisMarks(GraphicsContext*, const TextRun&, const GlyphBuffer&, const AtomicString&, const FloatPoint&) const; 181 void drawEmphasisMarks(GraphicsContext*, const TextRunPaintInfo&, const Glyp hBuffer&, const AtomicString&, const FloatPoint&) const;
181 float floatWidthForSimpleText(const TextRun&, HashSet<const SimpleFontData*> * fallbackFonts = 0, GlyphOverflow* = 0) const; 182 float floatWidthForSimpleText(const TextRun&, HashSet<const SimpleFontData*> * fallbackFonts = 0, GlyphOverflow* = 0) const;
182 int offsetForPositionForSimpleText(const TextRun&, float position, bool incl udePartialGlyphs) const; 183 int offsetForPositionForSimpleText(const TextRun&, float position, bool incl udePartialGlyphs) const;
183 FloatRect selectionRectForSimpleText(const TextRun&, const FloatPoint&, int h, int from, int to) const; 184 FloatRect selectionRectForSimpleText(const TextRun&, const FloatPoint&, int h, int from, int to) const;
184 185
185 bool getEmphasisMarkGlyphData(const AtomicString&, GlyphData&) const; 186 bool getEmphasisMarkGlyphData(const AtomicString&, GlyphData&) const;
186 187
187 static bool canReturnFallbackFontsForComplexText(); 188 static bool canReturnFallbackFontsForComplexText();
188 static bool canExpandAroundIdeographsInComplexText(); 189 static bool canExpandAroundIdeographsInComplexText();
189 190
190 // Returns the initial in-stream advance. 191 // Returns the initial in-stream advance.
191 float getGlyphsAndAdvancesForComplexText(const TextRun&, int from, int to, G lyphBuffer&, ForTextEmphasisOrNot = NotForTextEmphasis) const; 192 float getGlyphsAndAdvancesForComplexText(const TextRun&, int from, int to, G lyphBuffer&, ForTextEmphasisOrNot = NotForTextEmphasis) const;
192 void drawComplexText(GraphicsContext*, const TextRun&, const FloatPoint&, in t from, int to) const; 193 void drawComplexText(GraphicsContext*, const TextRunPaintInfo&, const FloatP oint&) const;
193 void drawEmphasisMarksForComplexText(GraphicsContext*, const TextRun&, const AtomicString& mark, const FloatPoint&, int from, int to) const; 194 void drawEmphasisMarksForComplexText(GraphicsContext*, const TextRunPaintInf o&, const AtomicString& mark, const FloatPoint&) const;
194 float floatWidthForComplexText(const TextRun&, HashSet<const SimpleFontData* >* fallbackFonts = 0, GlyphOverflow* = 0) const; 195 float floatWidthForComplexText(const TextRun&, HashSet<const SimpleFontData* >* fallbackFonts = 0, GlyphOverflow* = 0) const;
195 int offsetForPositionForComplexText(const TextRun&, float position, bool inc ludePartialGlyphs) const; 196 int offsetForPositionForComplexText(const TextRun&, float position, bool inc ludePartialGlyphs) const;
196 FloatRect selectionRectForComplexText(const TextRun&, const FloatPoint&, int h, int from, int to) const; 197 FloatRect selectionRectForComplexText(const TextRun&, const FloatPoint&, int h, int from, int to) const;
197 198
198 friend struct WidthIterator; 199 friend struct WidthIterator;
199 friend class SVGTextRunRenderingContext; 200 friend class SVGTextRunRenderingContext;
200 201
201 public: 202 public:
202 // Useful for debugging the different font rendering code paths. 203 // Useful for debugging the different font rendering code paths.
203 static void setCodePath(CodePath); 204 static void setCodePath(CodePath);
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after
332 333
333 } 334 }
334 335
335 namespace WTF { 336 namespace WTF {
336 337
337 template <> void deleteOwnedPtr<WebCore::TextLayout>(WebCore::TextLayout*); 338 template <> void deleteOwnedPtr<WebCore::TextLayout>(WebCore::TextLayout*);
338 339
339 } 340 }
340 341
341 #endif 342 #endif
OLDNEW
« no previous file with comments | « Source/core/platform/chromium/PopupListBox.cpp ('k') | Source/core/platform/graphics/Font.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698