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

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

Issue 1931393002: Introduce typeface cache in blink::FontCache (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: wip: others Created 4 years, 7 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 * This file is part of the internal font implementation. 2 * This file is part of the internal font implementation.
3 * 3 *
4 * Copyright (C) 2006, 2008, 2010 Apple Inc. All rights reserved. 4 * Copyright (C) 2006, 2008, 2010 Apple Inc. All rights reserved.
5 * Copyright (C) 2007-2008 Torch Mobile, Inc. 5 * Copyright (C) 2007-2008 Torch Mobile, Inc.
6 * 6 *
7 * This library is free software; you can redistribute it and/or 7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Library General Public 8 * modify it under the terms of the GNU Library General Public
9 * License as published by the Free Software Foundation; either 9 * License as published by the Free Software Foundation; either
10 * version 2 of the License, or (at your option) any later version. 10 * version 2 of the License, or (at your option) any later version.
(...skipping 30 matching lines...) Expand all
41 41
42 namespace blink { 42 namespace blink {
43 43
44 class FontDescription; 44 class FontDescription;
45 45
46 enum FontDataVariant { AutoVariant, NormalVariant, SmallCapsVariant, EmphasisMar kVariant }; 46 enum FontDataVariant { AutoVariant, NormalVariant, SmallCapsVariant, EmphasisMar kVariant };
47 47
48 class PLATFORM_EXPORT SimpleFontData : public FontData { 48 class PLATFORM_EXPORT SimpleFontData : public FontData {
49 public: 49 public:
50 // Used to create platform fonts. 50 // Used to create platform fonts.
51 static PassRefPtr<SimpleFontData> create(const FontPlatformData& platformDat a, PassRefPtr<CustomFontData> customData = nullptr, bool isTextOrientationFallba ck = false) 51 static PassRefPtr<SimpleFontData> create(const FontPlatformData& platformDat a, float fontSize, PassRefPtr<CustomFontData> customData = nullptr, bool isTextO rientationFallback = false)
52 { 52 {
53 return adoptRef(new SimpleFontData(platformData, customData, isTextOrien tationFallback)); 53 return adoptRef(new SimpleFontData(platformData, fontSize, customData, i sTextOrientationFallback));
54 } 54 }
55 55
56 ~SimpleFontData() override; 56 ~SimpleFontData() override;
57 57
58 const FontPlatformData& platformData() const { return m_platformData; } 58 const FontPlatformData& platformData() const { return m_platformData; }
59 float size() const { return m_fontSize; }
60 const FontRenderStyle& style() const { return m_style; }
61
59 const OpenTypeVerticalData* verticalData() const { return m_verticalData.get (); } 62 const OpenTypeVerticalData* verticalData() const { return m_verticalData.get (); }
60 63
61 PassRefPtr<SimpleFontData> smallCapsFontData(const FontDescription&) const; 64 PassRefPtr<SimpleFontData> smallCapsFontData(const FontDescription&) const;
62 PassRefPtr<SimpleFontData> emphasisMarkFontData(const FontDescription&) cons t; 65 PassRefPtr<SimpleFontData> emphasisMarkFontData(const FontDescription&) cons t;
63 66
64 PassRefPtr<SimpleFontData> variantFontData(const FontDescription& descriptio n, FontDataVariant variant) const 67 PassRefPtr<SimpleFontData> variantFontData(const FontDescription& descriptio n, FontDataVariant variant) const
65 { 68 {
66 switch (variant) { 69 switch (variant) {
67 case SmallCapsVariant: 70 case SmallCapsVariant:
68 return smallCapsFontData(description); 71 return smallCapsFontData(description);
69 case EmphasisMarkVariant: 72 case EmphasisMarkVariant:
70 return emphasisMarkFontData(description); 73 return emphasisMarkFontData(description);
71 case AutoVariant: 74 case AutoVariant:
72 case NormalVariant: 75 case NormalVariant:
73 break; 76 break;
74 } 77 }
75 ASSERT_NOT_REACHED(); 78 ASSERT_NOT_REACHED();
76 return const_cast<SimpleFontData*>(this); 79 return const_cast<SimpleFontData*>(this);
77 } 80 }
78 81
79 PassRefPtr<SimpleFontData> verticalRightOrientationFontData() const; 82 PassRefPtr<SimpleFontData> verticalRightOrientationFontData() const;
80 PassRefPtr<SimpleFontData> uprightOrientationFontData() const; 83 PassRefPtr<SimpleFontData> uprightOrientationFontData() const;
81 84
82 bool hasVerticalGlyphs() const { return m_hasVerticalGlyphs; } 85 bool hasVerticalGlyphs() const { return m_hasVerticalGlyphs; }
83 bool isTextOrientationFallback() const { return m_isTextOrientationFallback; } 86 bool isTextOrientationFallback() const { return m_isTextOrientationFallback; }
84 bool isTextOrientationFallbackOf(const SimpleFontData*) const; 87 bool isTextOrientationFallbackOf(const SimpleFontData*) const;
85 88
86 FontMetrics& getFontMetrics() { return m_fontMetrics; } 89 FontMetrics& getFontMetrics() { return m_fontMetrics; }
87 const FontMetrics& getFontMetrics() const { return m_fontMetrics; } 90 const FontMetrics& getFontMetrics() const { return m_fontMetrics; }
88 float sizePerUnit() const { return platformData().size() / (getFontMetrics() .unitsPerEm() ? getFontMetrics().unitsPerEm() : 1); } 91 float sizePerUnit() const { return m_fontSize / (getFontMetrics().unitsPerEm () ? getFontMetrics().unitsPerEm() : 1); }
89 float internalLeading() const { return getFontMetrics().floatHeight() - plat formData().size(); } 92 float internalLeading() const { return getFontMetrics().floatHeight() - m_fo ntSize; }
90 93
91 float maxCharWidth() const { return m_maxCharWidth; } 94 float maxCharWidth() const { return m_maxCharWidth; }
92 void setMaxCharWidth(float maxCharWidth) { m_maxCharWidth = maxCharWidth; } 95 void setMaxCharWidth(float maxCharWidth) { m_maxCharWidth = maxCharWidth; }
93 96
94 float avgCharWidth() const { return m_avgCharWidth; } 97 float avgCharWidth() const { return m_avgCharWidth; }
95 void setAvgCharWidth(float avgCharWidth) { m_avgCharWidth = avgCharWidth; } 98 void setAvgCharWidth(float avgCharWidth) { m_avgCharWidth = avgCharWidth; }
96 99
97 FloatRect boundsForGlyph(Glyph) const; 100 FloatRect boundsForGlyph(Glyph) const;
98 float widthForGlyph(Glyph glyph) const; 101 float widthForGlyph(Glyph glyph) const;
99 FloatRect platformBoundsForGlyph(Glyph) const; 102 FloatRect platformBoundsForGlyph(Glyph) const;
(...skipping 21 matching lines...) Expand all
121 void setMissingGlyphData(const GlyphData& glyphData) { m_missingGlyphData = glyphData; } 124 void setMissingGlyphData(const GlyphData& glyphData) { m_missingGlyphData = glyphData; }
122 125
123 bool canRenderCombiningCharacterSequence(const UChar*, size_t) const; 126 bool canRenderCombiningCharacterSequence(const UChar*, size_t) const;
124 127
125 CustomFontData* customFontData() const { return m_customFontData.get(); } 128 CustomFontData* customFontData() const { return m_customFontData.get(); }
126 129
127 // Implemented by the platform. 130 // Implemented by the platform.
128 virtual bool fillGlyphPage(GlyphPage* pageToFill, unsigned offset, unsigned length, UChar* buffer, unsigned bufferLength) const; 131 virtual bool fillGlyphPage(GlyphPage* pageToFill, unsigned offset, unsigned length, UChar* buffer, unsigned bufferLength) const;
129 132
130 protected: 133 protected:
131 SimpleFontData(const FontPlatformData&, PassRefPtr<CustomFontData> customDat a, bool isTextOrientationFallback = false); 134 SimpleFontData(const FontPlatformData&, float fontSize, PassRefPtr<CustomFon tData> customData, bool isTextOrientationFallback = false);
132 135
133 SimpleFontData(PassRefPtr<CustomFontData> customData, float fontSize, bool s yntheticBold, bool syntheticItalic); 136 SimpleFontData(PassRefPtr<CustomFontData> customData, float fontSize, bool s yntheticBold, bool syntheticItalic);
134 137
135 private: 138 private:
136 void platformInit(); 139 void platformInit();
137 void platformGlyphInit(); 140 void platformGlyphInit();
138 141
139 PassRefPtr<SimpleFontData> createScaledFontData(const FontDescription&, floa t scaleFactor) const; 142 PassRefPtr<SimpleFontData> createScaledFontData(const FontDescription&, floa t scaleFactor) const;
140 PassRefPtr<SimpleFontData> platformCreateScaledFontData(const FontDescriptio n&, float scaleFactor) const; 143 PassRefPtr<SimpleFontData> platformCreateScaledFontData(const FontDescriptio n&, float scaleFactor) const;
141 144
142 FontMetrics m_fontMetrics; 145 FontMetrics m_fontMetrics;
143 float m_maxCharWidth; 146 float m_maxCharWidth;
144 float m_avgCharWidth; 147 float m_avgCharWidth;
145 148
146 FontPlatformData m_platformData; 149 FontPlatformData m_platformData;
150 float m_fontSize;
151 FontRenderStyle m_style;
147 152
148 mutable OwnPtr<GlyphMetricsMap<FloatRect>> m_glyphToBoundsMap; 153 mutable OwnPtr<GlyphMetricsMap<FloatRect>> m_glyphToBoundsMap;
149 mutable GlyphMetricsMap<float> m_glyphToWidthMap; 154 mutable GlyphMetricsMap<float> m_glyphToWidthMap;
150 155
151 bool m_isTextOrientationFallback; 156 bool m_isTextOrientationFallback;
152 RefPtr<OpenTypeVerticalData> m_verticalData; 157 RefPtr<OpenTypeVerticalData> m_verticalData;
153 bool m_hasVerticalGlyphs; 158 bool m_hasVerticalGlyphs;
154 159
155 Glyph m_spaceGlyph; 160 Glyph m_spaceGlyph;
156 float m_spaceWidth; 161 float m_spaceWidth;
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
211 width = platformWidthForGlyph(glyph); 216 width = platformWidthForGlyph(glyph);
212 217
213 m_glyphToWidthMap.setMetricsForGlyph(glyph, width); 218 m_glyphToWidthMap.setMetricsForGlyph(glyph, width);
214 return width; 219 return width;
215 } 220 }
216 221
217 DEFINE_FONT_DATA_TYPE_CASTS(SimpleFontData, false); 222 DEFINE_FONT_DATA_TYPE_CASTS(SimpleFontData, false);
218 223
219 } // namespace blink 224 } // namespace blink
220 #endif // SimpleFontData_h 225 #endif // SimpleFontData_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698