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

Side by Side Diff: third_party/WebKit/Source/platform/fonts/Font.cpp

Issue 1525963002: (CANCELED) Improve performance of large option list with CJK text (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Revert to PS2 Created 5 years 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
OLDNEW
1 /* 1 /*
2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org)
3 * (C) 1999 Antti Koivisto (koivisto@kde.org) 3 * (C) 1999 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, 2010, 2011 Apple Inc. All rights reserved. 5 * Copyright (C) 2003, 2006, 2010, 2011 Apple Inc. All rights reserved.
6 * Copyright (c) 2007, 2008, 2010 Google Inc. All rights reserved. 6 * Copyright (c) 2007, 2008, 2010 Google Inc. All rights reserved.
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 221 matching lines...) Expand 10 before | Expand all | Expand 10 after
232 232
233 float Font::width(const TextRun& run, HashSet<const SimpleFontData*>* fallbackFo nts, FloatRect* glyphBounds) const 233 float Font::width(const TextRun& run, HashSet<const SimpleFontData*>* fallbackFo nts, FloatRect* glyphBounds) const
234 { 234 {
235 FontCachePurgePreventer purgePreventer; 235 FontCachePurgePreventer purgePreventer;
236 236
237 if (codePath(TextRunPaintInfo(run)) == ComplexPath) 237 if (codePath(TextRunPaintInfo(run)) == ComplexPath)
238 return floatWidthForComplexText(run, fallbackFonts, glyphBounds); 238 return floatWidthForComplexText(run, fallbackFonts, glyphBounds);
239 return floatWidthForSimpleText(run, fallbackFonts, glyphBounds); 239 return floatWidthForSimpleText(run, fallbackFonts, glyphBounds);
240 } 240 }
241 241
242 float Font::widthForUnbrokenRun(const TextRun& run) const
243 {
244 if (run.length() <= 1 || run.is8Bit())
245 return width(run);
246
247 float totalWidth = 0;
248 const unsigned length = run.length();
249 for (unsigned startIndex = 0; startIndex < length; ) {
250 UChar32 ch;
251 unsigned endIndex = startIndex;
252 U16_NEXT(run.characters16(), endIndex, length, ch);
253 if (Character::isCJKIdeographOrSymbol(ch)) {
254 // For scripts that do not delimit words by spaces, split each
255 // character so that input text matches to what the line breaker
256 // requests. This improves the cache efficiency in
257 // CachingWordShaper.
258 for (unsigned i = endIndex; i < length; endIndex = i) {
259 U16_NEXT(run.characters16(), i, length, ch);
260 if (!(U_GET_GC_MASK(ch) & U_GC_M_MASK))
261 break;
262 }
263 } else {
264 // For scripts that delimit words by spaces, let CachingWordShaper
265 // handle words.
266 for (unsigned i = endIndex; i < length; endIndex = i) {
267 U16_NEXT(run.characters16(), i, length, ch);
268 if (Character::isCJKIdeographOrSymbol(ch))
269 break;
270 }
271 }
272 if (!startIndex && endIndex == length)
273 return width(run);
274 TextRun subRun = run.subRun(startIndex, endIndex - startIndex);
275 totalWidth += width(subRun);
276 startIndex = endIndex;
277 }
278 return totalWidth;
279 }
280
242 PassTextBlobPtr Font::buildTextBlob(const GlyphBuffer& glyphBuffer) const 281 PassTextBlobPtr Font::buildTextBlob(const GlyphBuffer& glyphBuffer) const
243 { 282 {
244 SkTextBlobBuilder builder; 283 SkTextBlobBuilder builder;
245 bool hasVerticalOffsets = glyphBuffer.hasVerticalOffsets(); 284 bool hasVerticalOffsets = glyphBuffer.hasVerticalOffsets();
246 285
247 unsigned i = 0; 286 unsigned i = 0;
248 while (i < glyphBuffer.size()) { 287 while (i < glyphBuffer.size()) {
249 const SimpleFontData* fontData = glyphBuffer.fontDataAt(i); 288 const SimpleFontData* fontData = glyphBuffer.fontDataAt(i);
250 289
251 // FIXME: Handle vertical text. 290 // FIXME: Handle vertical text.
(...skipping 582 matching lines...) Expand 10 before | Expand all | Expand 10 after
834 { 873 {
835 return m_fontFallbackList && m_fontFallbackList->loadingCustomFonts(); 874 return m_fontFallbackList && m_fontFallbackList->loadingCustomFonts();
836 } 875 }
837 876
838 bool Font::isFallbackValid() const 877 bool Font::isFallbackValid() const
839 { 878 {
840 return !m_fontFallbackList || m_fontFallbackList->isValid(); 879 return !m_fontFallbackList || m_fontFallbackList->isValid();
841 } 880 }
842 881
843 } // namespace blink 882 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698