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

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: Addressing Dominiks comments 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
« no previous file with comments | « Source/platform/fonts/Font.cpp ('k') | no next file » | 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) 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)
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.
128 if (hasWordSpacingOrLetterSpacing)
129 return 0;
130 // Since this is just a width cache, we don't have enough information to satisfy glyph queries.
131 if (glyphOverflow)
132 return 0;
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.
134 if (run.allowTabs())
135 return 0;
136 if (static_cast<unsigned>(run.length()) > SmallStringKey::capacity()) 124 if (static_cast<unsigned>(run.length()) > SmallStringKey::capacity())
137 return 0; 125 return 0;
138 126
139 if (m_countdown > 0) { 127 if (m_countdown > 0) {
140 --m_countdown; 128 --m_countdown;
141 return 0; 129 return 0;
142 } 130 }
143 131
144 return addSlowCase(run, entry); 132 return addSlowCase(run, entry);
145 } 133 }
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
207 inline bool operator==(const WidthCache::SmallStringKey& a, const WidthCache::Sm allStringKey& b) 195 inline bool operator==(const WidthCache::SmallStringKey& a, const WidthCache::Sm allStringKey& b)
208 { 196 {
209 if (a.length() != b.length()) 197 if (a.length() != b.length())
210 return false; 198 return false;
211 return WTF::equal(a.characters(), b.characters(), a.length()); 199 return WTF::equal(a.characters(), b.characters(), a.length());
212 } 200 }
213 201
214 } // namespace WebCore 202 } // namespace WebCore
215 203
216 #endif // WidthCache_h 204 #endif // WidthCache_h
OLDNEW
« no previous file with comments | « Source/platform/fonts/Font.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698