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

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

Issue 206793005: Expand WidthCache for complex text width queries (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 9 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
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2012 Apple Inc. All rights reserved. 2 * Copyright (C) 2012 Apple Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 1. Redistributions of source code must retain the above copyright 7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer. 8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright 9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the 10 * notice, this list of conditions and the following disclaimer in the
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
112 112
113 friend bool operator==(const SmallStringKey&, const SmallStringKey&); 113 friend bool operator==(const SmallStringKey&, const SmallStringKey&);
114 114
115 public: 115 public:
116 WidthCache() 116 WidthCache()
117 : m_interval(s_maxInterval) 117 : m_interval(s_maxInterval)
118 , m_countdown(m_interval) 118 , m_countdown(m_interval)
119 { 119 {
120 } 120 }
121 121
122 float* add(const TextRun& run, float entry, bool hasKerningOrLigatures, bool hasWordSpacingOrLetterSpacing, GlyphOverflow* glyphOverflow) 122 float* add(const TextRun& run, float entry, bool hasWordSpacingOrLetterSpaci ng, GlyphOverflow* glyphOverflow)
123 { 123 {
124 // The width cache is not really profitable unless we're doing expensive glyph transformations.
125 if (!hasKerningOrLigatures)
126 return 0;
127 // Word spacing and letter spacing can change the width of a word. 124 // Word spacing and letter spacing can change the width of a word.
128 if (hasWordSpacingOrLetterSpacing) 125 if (hasWordSpacingOrLetterSpacing)
129 return 0; 126 return 0;
130 // Since this is just a width cache, we don't have enough information to satisfy glyph queries. 127 // Since this is just a width cache, we don't have enough information to satisfy glyph queries.
131 if (glyphOverflow) 128 if (glyphOverflow) {
132 return 0; 129 return 0;
130 }
133 // If we allow tabs and a tab occurs inside a word, the width of the wor d varies based on its position on the line. 131 // If we allow tabs and a tab occurs inside a word, the width of the wor d varies based on its position on the line.
134 if (run.allowTabs()) 132 if (run.allowTabs())
135 return 0; 133 return 0;
136 if (static_cast<unsigned>(run.length()) > SmallStringKey::capacity()) 134 if (static_cast<unsigned>(run.length()) > SmallStringKey::capacity())
137 return 0; 135 return 0;
138 136
139 if (m_countdown > 0) { 137 if (m_countdown > 0) {
140 --m_countdown; 138 --m_countdown;
141 return 0; 139 return 0;
142 } 140 }
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
207 inline bool operator==(const WidthCache::SmallStringKey& a, const WidthCache::Sm allStringKey& b) 205 inline bool operator==(const WidthCache::SmallStringKey& a, const WidthCache::Sm allStringKey& b)
208 { 206 {
209 if (a.length() != b.length()) 207 if (a.length() != b.length())
210 return false; 208 return false;
211 return WTF::equal(a.characters(), b.characters(), a.length()); 209 return WTF::equal(a.characters(), b.characters(), a.length());
212 } 210 }
213 211
214 } // namespace WebCore 212 } // namespace WebCore
215 213
216 #endif // WidthCache_h 214 #endif // WidthCache_h
OLDNEW
« Source/platform/fonts/Font.cpp ('K') | « Source/platform/fonts/Font.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698