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

Side by Side Diff: third_party/WebKit/Source/platform/fonts/FontFallbackIterator.h

Issue 2230233002: Skip redundant fonts returned by FontFallbackIterator (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Logging removed Created 4 years, 4 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 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef FontFallbackIterator_h 5 #ifndef FontFallbackIterator_h
6 #define FontFallbackIterator_h 6 #define FontFallbackIterator_h
7 7
8 #include "platform/fonts/FontDataForRangeSet.h" 8 #include "platform/fonts/FontDataForRangeSet.h"
9 #include "platform/fonts/FontFallbackPriority.h" 9 #include "platform/fonts/FontFallbackPriority.h"
10 #include "wtf/HashMap.h" 10 #include "wtf/HashMap.h"
(...skipping 12 matching lines...) Expand all
23 class SimpleFontData; 23 class SimpleFontData;
24 class FontFamily; 24 class FontFamily;
25 25
26 class FontFallbackIterator : public RefCounted<FontFallbackIterator> { 26 class FontFallbackIterator : public RefCounted<FontFallbackIterator> {
27 WTF_MAKE_NONCOPYABLE(FontFallbackIterator); 27 WTF_MAKE_NONCOPYABLE(FontFallbackIterator);
28 28
29 public: 29 public:
30 static PassRefPtr<FontFallbackIterator> create(const FontDescription&, PassR efPtr<FontFallbackList>, 30 static PassRefPtr<FontFallbackIterator> create(const FontDescription&, PassR efPtr<FontFallbackList>,
31 FontFallbackPriority); 31 FontFallbackPriority);
32 32
33 // Returns whether a list of all remaining characters to be shaped is
34 // needed. Needed by the FontfallbackIterator in order to check whether a
35 // font from a segmented range should be loaded.
36 bool needsHintList() const;
37
38 bool hasNext() const { return m_fallbackStage != OutOfLuck; }; 33 bool hasNext() const { return m_fallbackStage != OutOfLuck; };
39 34
40 // Some system fallback APIs (Windows, Android) require a character, or a 35 // Some system fallback APIs (Windows, Android) require a character, or a
41 // portion of the string to be passed. On Mac and Linux, we get a list of 36 // portion of the string to be passed. On Mac and Linux, we get a list of
42 // fonts without passing in characters. 37 // fonts without passing in characters.
43 const PassRefPtr<FontDataForRangeSet> next(const Vector<UChar32>& hintList); 38 const PassRefPtr<FontDataForRangeSet> next(const Vector<UChar32>& hintList);
44 39
45 private: 40 private:
46 FontFallbackIterator(const FontDescription&, PassRefPtr<FontFallbackList>, 41 FontFallbackIterator(const FontDescription&, PassRefPtr<FontFallbackList>,
47 FontFallbackPriority); 42 FontFallbackPriority);
48 bool rangeSetContributesForHint(const Vector<UChar32> hintList, const FontDa taForRangeSet*); 43 bool rangeSetContributesForHint(const Vector<UChar32> hintList, const FontDa taForRangeSet*);
49 bool alreadyLoadingRangeForHintChar(UChar32 hintChar); 44 bool alreadyLoadingRangeForHintChar(UChar32 hintChar);
50 void willUseRange(const AtomicString& family, const FontDataForRangeSet&); 45 void willUseRange(const AtomicString& family, const FontDataForRangeSet&);
51 46
47 const PassRefPtr<FontDataForRangeSet> uniqueOrNext(PassRefPtr<FontDataForRan geSet> candidate, const Vector<UChar32>& hintList);
48
52 const PassRefPtr<SimpleFontData> fallbackPriorityFont(UChar32 hint); 49 const PassRefPtr<SimpleFontData> fallbackPriorityFont(UChar32 hint);
53 const PassRefPtr<SimpleFontData> uniqueSystemFontForHint(UChar32 hint); 50 const PassRefPtr<SimpleFontData> uniqueSystemFontForHint(UChar32 hint);
54 51
55 const FontDescription& m_fontDescription; 52 const FontDescription& m_fontDescription;
56 RefPtr<FontFallbackList> m_fontFallbackList; 53 RefPtr<FontFallbackList> m_fontFallbackList;
57 int m_currentFontDataIndex; 54 int m_currentFontDataIndex;
58 unsigned m_segmentedFaceIndex; 55 unsigned m_segmentedFaceIndex;
59 56
60 enum FallbackStage { 57 enum FallbackStage {
61 FallbackPriorityFonts, 58 FallbackPriorityFonts,
62 FontGroupFonts, 59 FontGroupFonts,
63 SegmentedFace, 60 SegmentedFace,
64 PreferencesFonts, 61 PreferencesFonts,
65 SystemFonts, 62 SystemFonts,
66 OutOfLuck 63 OutOfLuck
67 }; 64 };
68 65
69 FallbackStage m_fallbackStage; 66 FallbackStage m_fallbackStage;
70 HashSet<UChar32> m_previouslyAskedForHint; 67 HashSet<UChar32> m_previouslyAskedForHint;
68 // FontFallbackIterator is meant for single use by HarfBuzzShaper,
69 // traversing through the fonts for shaping only once. We must not return
70 // duplicate FontDataForRangeSet objects from the next() iteration functions
71 // as returning a duplicate value causes a shaping run that won't return any
72 // results.
73 HashSet<uint32_t> m_uniqueFontDataForRangeSetsReturned;
71 Vector<RefPtr<FontDataForRangeSet>> m_trackedLoadingRangeSets; 74 Vector<RefPtr<FontDataForRangeSet>> m_trackedLoadingRangeSets;
72 FontFallbackPriority m_fontFallbackPriority; 75 FontFallbackPriority m_fontFallbackPriority;
73 }; 76 };
74 77
75 } // namespace blink 78 } // namespace blink
76 79
77 #endif 80 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698