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

Side by Side Diff: Source/platform/fonts/FontFallbackList.cpp

Issue 1314843009: Add DocumentTiming metrics for "time to first text paint" (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Paint time metrics Created 5 years, 3 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
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2006 Apple Computer, Inc. All rights reserved. 2 * Copyright (C) 2006 Apple Computer, 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 * 7 *
8 * 1. Redistributions of source code must retain the above copyright 8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright 10 * 2. Redistributions in binary form must reproduce the above copyright
(...skipping 28 matching lines...) Expand all
39 namespace blink { 39 namespace blink {
40 40
41 FontFallbackList::FontFallbackList() 41 FontFallbackList::FontFallbackList()
42 : m_pageZero(0) 42 : m_pageZero(0)
43 , m_cachedPrimarySimpleFontData(0) 43 , m_cachedPrimarySimpleFontData(0)
44 , m_fontSelector(nullptr) 44 , m_fontSelector(nullptr)
45 , m_fontSelectorVersion(0) 45 , m_fontSelectorVersion(0)
46 , m_familyIndex(0) 46 , m_familyIndex(0)
47 , m_generation(FontCache::fontCache()->generation()) 47 , m_generation(FontCache::fontCache()->generation())
48 , m_hasLoadingFallback(false) 48 , m_hasLoadingFallback(false)
49 , m_hasCustomFont(false)
49 { 50 {
50 } 51 }
51 52
52 void FontFallbackList::invalidate(PassRefPtrWillBeRawPtr<FontSelector> fontSelec tor) 53 void FontFallbackList::invalidate(PassRefPtrWillBeRawPtr<FontSelector> fontSelec tor)
53 { 54 {
54 releaseFontData(); 55 releaseFontData();
55 m_fontList.clear(); 56 m_fontList.clear();
56 m_pageZero = 0; 57 m_pageZero = 0;
57 m_pages.clear(); 58 m_pages.clear();
58 m_cachedPrimarySimpleFontData = 0; 59 m_cachedPrimarySimpleFontData = 0;
59 m_familyIndex = 0; 60 m_familyIndex = 0;
60 m_hasLoadingFallback = false; 61 m_hasLoadingFallback = false;
62 m_hasCustomFont = false;
61 m_fontSelector = fontSelector; 63 m_fontSelector = fontSelector;
62 m_fontSelectorVersion = m_fontSelector ? m_fontSelector->version() : 0; 64 m_fontSelectorVersion = m_fontSelector ? m_fontSelector->version() : 0;
63 m_generation = FontCache::fontCache()->generation(); 65 m_generation = FontCache::fontCache()->generation();
64 m_cachingWordShaper.clear(); 66 m_cachingWordShaper.clear();
65 } 67 }
66 68
67 void FontFallbackList::releaseFontData() 69 void FontFallbackList::releaseFontData()
68 { 70 {
69 unsigned numFonts = m_fontList.size(); 71 unsigned numFonts = m_fontList.size();
70 for (unsigned i = 0; i < numFonts; ++i) { 72 for (unsigned i = 0; i < numFonts; ++i) {
(...skipping 12 matching lines...) Expand all
83 unsigned numFonts = m_fontList.size(); 85 unsigned numFonts = m_fontList.size();
84 for (unsigned i = 0; i < numFonts; ++i) { 86 for (unsigned i = 0; i < numFonts; ++i) {
85 if (m_fontList[i]->isLoading()) 87 if (m_fontList[i]->isLoading())
86 return true; 88 return true;
87 } 89 }
88 return false; 90 return false;
89 } 91 }
90 92
91 bool FontFallbackList::shouldSkipDrawing() const 93 bool FontFallbackList::shouldSkipDrawing() const
92 { 94 {
93 if (!m_hasLoadingFallback) 95 if (m_hasLoadingFallback) {
94 return false; 96 unsigned numFonts = m_fontList.size();
95 97 for (unsigned i = 0; i < numFonts; ++i) {
96 unsigned numFonts = m_fontList.size(); 98 if (m_fontList[i]->shouldSkipDrawing())
97 for (unsigned i = 0; i < numFonts; ++i) { 99 return true;
98 if (m_fontList[i]->shouldSkipDrawing()) 100 }
99 return true;
100 } 101 }
102 if (m_fontSelector)
103 m_fontSelector->reportFirstNonBlankText(m_hasCustomFont);
101 return false; 104 return false;
102 } 105 }
103 106
104 const SimpleFontData* FontFallbackList::determinePrimarySimpleFontData(const Fon tDescription& fontDescription) const 107 const SimpleFontData* FontFallbackList::determinePrimarySimpleFontData(const Fon tDescription& fontDescription) const
105 { 108 {
106 bool shouldLoadCustomFont = true; 109 bool shouldLoadCustomFont = true;
107 110
108 for (unsigned fontIndex = 0; ; ++fontIndex) { 111 for (unsigned fontIndex = 0; ; ++fontIndex) {
109 const FontData* fontData = fontDataAt(fontDescription, fontIndex); 112 const FontData* fontData = fontDataAt(fontDescription, fontIndex);
110 if (!fontData) { 113 if (!fontData) {
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
203 // Ask the font cache for the font data. 206 // Ask the font cache for the font data.
204 // We are obtaining this font for the first time. We keep track of the fami lies we've looked at before 207 // We are obtaining this font for the first time. We keep track of the fami lies we've looked at before
205 // in |m_familyIndex|, so that we never scan the same spot in the list twice . getFontData will adjust our 208 // in |m_familyIndex|, so that we never scan the same spot in the list twice . getFontData will adjust our
206 // |m_familyIndex| as it scans for the right font to make. 209 // |m_familyIndex| as it scans for the right font to make.
207 ASSERT(FontCache::fontCache()->generation() == m_generation); 210 ASSERT(FontCache::fontCache()->generation() == m_generation);
208 RefPtr<FontData> result = getFontData(fontDescription, m_familyIndex); 211 RefPtr<FontData> result = getFontData(fontDescription, m_familyIndex);
209 if (result) { 212 if (result) {
210 m_fontList.append(result); 213 m_fontList.append(result);
211 if (result->isLoadingFallback()) 214 if (result->isLoadingFallback())
212 m_hasLoadingFallback = true; 215 m_hasLoadingFallback = true;
216 if (result->isCustomFont())
217 m_hasCustomFont = true;
213 } 218 }
214 return result.get(); 219 return result.get();
215 } 220 }
216 221
217 bool FontFallbackList::isValid() const 222 bool FontFallbackList::isValid() const
218 { 223 {
219 if (!m_fontSelector) 224 if (!m_fontSelector)
220 return m_fontSelectorVersion == 0; 225 return m_fontSelectorVersion == 0;
221 226
222 return m_fontSelector->version() == m_fontSelectorVersion; 227 return m_fontSelector->version() == m_fontSelectorVersion;
223 } 228 }
224 229
225 } // namespace blink 230 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698