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

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

Issue 2199333008: Remove glyph metrics caching on non-Mac platforms (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 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
« no previous file with comments | « no previous file | 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 * 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 12 matching lines...) Expand all
23 23
24 #ifndef SimpleFontData_h 24 #ifndef SimpleFontData_h
25 #define SimpleFontData_h 25 #define SimpleFontData_h
26 26
27 #include "platform/PlatformExport.h" 27 #include "platform/PlatformExport.h"
28 #include "platform/fonts/CustomFontData.h" 28 #include "platform/fonts/CustomFontData.h"
29 #include "platform/fonts/FontBaseline.h" 29 #include "platform/fonts/FontBaseline.h"
30 #include "platform/fonts/FontData.h" 30 #include "platform/fonts/FontData.h"
31 #include "platform/fonts/FontMetrics.h" 31 #include "platform/fonts/FontMetrics.h"
32 #include "platform/fonts/FontPlatformData.h" 32 #include "platform/fonts/FontPlatformData.h"
33 #include "platform/fonts/GlyphMetricsMap.h"
34 #include "platform/fonts/GlyphPageTreeNode.h" 33 #include "platform/fonts/GlyphPageTreeNode.h"
35 #include "platform/fonts/TypesettingFeatures.h" 34 #include "platform/fonts/TypesettingFeatures.h"
36 #include "platform/fonts/opentype/OpenTypeVerticalData.h" 35 #include "platform/fonts/opentype/OpenTypeVerticalData.h"
37 #include "platform/geometry/FloatRect.h" 36 #include "platform/geometry/FloatRect.h"
38 #include "wtf/PtrUtil.h" 37 #include "wtf/PtrUtil.h"
39 #include "wtf/text/StringHash.h" 38 #include "wtf/text/StringHash.h"
40 #include <SkPaint.h> 39 #include <SkPaint.h>
41 #include <memory> 40 #include <memory>
42 41
42 #if OS(MACOSX)
43 #include "platform/fonts/GlyphMetricsMap.h"
44 #endif
45
43 namespace blink { 46 namespace blink {
44 47
45 class FontDescription; 48 class FontDescription;
46 49
47 enum FontDataVariant { AutoVariant, NormalVariant, SmallCapsVariant, EmphasisMar kVariant }; 50 enum FontDataVariant { AutoVariant, NormalVariant, SmallCapsVariant, EmphasisMar kVariant };
48 51
49 class PLATFORM_EXPORT SimpleFontData : public FontData { 52 class PLATFORM_EXPORT SimpleFontData : public FontData {
50 public: 53 public:
51 // Used to create platform fonts. 54 // Used to create platform fonts.
52 static PassRefPtr<SimpleFontData> create(const FontPlatformData& platformDat a, PassRefPtr<CustomFontData> customData = nullptr, bool isTextOrientationFallba ck = false) 55 static PassRefPtr<SimpleFontData> create(const FontPlatformData& platformDat a, PassRefPtr<CustomFontData> customData = nullptr, bool isTextOrientationFallba ck = false)
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
137 void platformInit(); 140 void platformInit();
138 void platformGlyphInit(); 141 void platformGlyphInit();
139 142
140 PassRefPtr<SimpleFontData> createScaledFontData(const FontDescription&, floa t scaleFactor) const; 143 PassRefPtr<SimpleFontData> createScaledFontData(const FontDescription&, floa t 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;
147 mutable std::unique_ptr<GlyphMetricsMap<FloatRect>> m_glyphToBoundsMap;
148 mutable GlyphMetricsMap<float> m_glyphToWidthMap;
149 SkPaint m_paint; 150 SkPaint m_paint;
150 151
151 bool m_isTextOrientationFallback; 152 bool m_isTextOrientationFallback;
152 RefPtr<OpenTypeVerticalData> m_verticalData; 153 RefPtr<OpenTypeVerticalData> m_verticalData;
153 bool m_hasVerticalGlyphs; 154 bool m_hasVerticalGlyphs;
154 155
155 Glyph m_spaceGlyph; 156 Glyph m_spaceGlyph;
156 float m_spaceWidth; 157 float m_spaceWidth;
157 Glyph m_zeroGlyph; 158 Glyph m_zeroGlyph;
158 159
(...skipping 15 matching lines...) Expand all
174 private: 175 private:
175 DerivedFontData(bool custom) 176 DerivedFontData(bool custom)
176 : forCustomFont(custom) 177 : forCustomFont(custom)
177 { 178 {
178 } 179 }
179 }; 180 };
180 181
181 mutable std::unique_ptr<DerivedFontData> m_derivedFontData; 182 mutable std::unique_ptr<DerivedFontData> m_derivedFontData;
182 183
183 RefPtr<CustomFontData> m_customFontData; 184 RefPtr<CustomFontData> m_customFontData;
185
186 // See discussion on crbug.com/631032 and Skiaissue
187 // https://bugs.chromium.org/p/skia/issues/detail?id=5328 :
188 // On Mac we're still using path based glyph metrics, and they seem to be
189 // too slow to be able to remove the caching layer we have here.
190 #if OS(MACOSX)
191 mutable std::unique_ptr<GlyphMetricsMap<FloatRect>> m_glyphToBoundsMap;
192 mutable GlyphMetricsMap<float> m_glyphToWidthMap;
193 #endif
184 }; 194 };
185 195
186 196
187 ALWAYS_INLINE FloatRect SimpleFontData::boundsForGlyph(Glyph glyph) const 197 ALWAYS_INLINE FloatRect SimpleFontData::boundsForGlyph(Glyph glyph) const
188 { 198 {
199 #if !OS(MACOSX)
200 return platformBoundsForGlyph(glyph);
201 #else
189 FloatRect boundsResult; 202 FloatRect boundsResult;
190 if (m_glyphToBoundsMap) { 203 if (m_glyphToBoundsMap) {
191 boundsResult = m_glyphToBoundsMap->metricsForGlyph(glyph); 204 boundsResult = m_glyphToBoundsMap->metricsForGlyph(glyph);
192 if (boundsResult.width() != cGlyphSizeUnknown) 205 if (boundsResult.width() != cGlyphSizeUnknown)
193 return boundsResult; 206 return boundsResult;
194 } 207 }
195 208
196 boundsResult = platformBoundsForGlyph(glyph); 209 boundsResult = platformBoundsForGlyph(glyph);
197 if (!m_glyphToBoundsMap) 210 if (!m_glyphToBoundsMap)
198 m_glyphToBoundsMap = wrapUnique(new GlyphMetricsMap<FloatRect>); 211 m_glyphToBoundsMap = wrapUnique(new GlyphMetricsMap<FloatRect>);
199 m_glyphToBoundsMap->setMetricsForGlyph(glyph, boundsResult); 212 m_glyphToBoundsMap->setMetricsForGlyph(glyph, boundsResult);
200 213
201 return boundsResult; 214 return boundsResult;
215 #endif
202 } 216 }
203 217
204 ALWAYS_INLINE float SimpleFontData::widthForGlyph(Glyph glyph) const 218 ALWAYS_INLINE float SimpleFontData::widthForGlyph(Glyph glyph) const
205 { 219 {
220 #if !OS(MACOSX)
221 return platformWidthForGlyph(glyph);
222 #else
206 float width = m_glyphToWidthMap.metricsForGlyph(glyph); 223 float width = m_glyphToWidthMap.metricsForGlyph(glyph);
207 if (width != cGlyphSizeUnknown) 224 if (width != cGlyphSizeUnknown)
208 return width; 225 return width;
209 226
210 width = platformWidthForGlyph(glyph); 227 width = platformWidthForGlyph(glyph);
211 228
212 m_glyphToWidthMap.setMetricsForGlyph(glyph, width); 229 m_glyphToWidthMap.setMetricsForGlyph(glyph, width);
213 return width; 230 return width;
231 #endif
214 } 232 }
215 233
216 DEFINE_FONT_DATA_TYPE_CASTS(SimpleFontData, false); 234 DEFINE_FONT_DATA_TYPE_CASTS(SimpleFontData, false);
217 235
218 } // namespace blink 236 } // namespace blink
219 #endif // SimpleFontData_h 237 #endif // SimpleFontData_h
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698