OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2006, 2007, 2008, Google Inc. All rights reserved. | 2 * Copyright (c) 2006, 2007, 2008, Google 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 are | 5 * modification, are permitted provided that the following conditions are |
6 * met: | 6 * met: |
7 * | 7 * |
8 * * Redistributions of source code must retain the above copyright | 8 * * 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 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
(...skipping 24 matching lines...) Expand all Loading... |
35 #include "SkPaint.h" | 35 #include "SkPaint.h" |
36 #include "SkTypeface.h" | 36 #include "SkTypeface.h" |
37 #include "core/platform/NotImplemented.h" | 37 #include "core/platform/NotImplemented.h" |
38 #include "core/platform/graphics/FontCache.h" | 38 #include "core/platform/graphics/FontCache.h" |
39 #include "core/platform/graphics/harfbuzz/HarfBuzzFace.h" | 39 #include "core/platform/graphics/harfbuzz/HarfBuzzFace.h" |
40 | 40 |
41 #include "public/platform/linux/WebFontInfo.h" | 41 #include "public/platform/linux/WebFontInfo.h" |
42 #include "public/platform/linux/WebFontRenderStyle.h" | 42 #include "public/platform/linux/WebFontRenderStyle.h" |
43 #include "public/platform/linux/WebSandboxSupport.h" | 43 #include "public/platform/linux/WebSandboxSupport.h" |
44 #include "public/platform/Platform.h" | 44 #include "public/platform/Platform.h" |
| 45 #include "wtf/text/AtomicStringHash.h" |
| 46 #include "wtf/text/StringHash.h" |
45 #include "wtf/text/StringImpl.h" | 47 #include "wtf/text/StringImpl.h" |
46 #include "wtf/text/WTFString.h" | 48 #include "wtf/text/WTFString.h" |
47 | 49 |
48 namespace WebCore { | 50 namespace WebCore { |
49 | 51 |
50 static SkPaint::Hinting skiaHinting = SkPaint::kNormal_Hinting; | 52 static SkPaint::Hinting skiaHinting = SkPaint::kNormal_Hinting; |
51 static bool useSkiaAutoHint = true; | 53 static bool useSkiaAutoHint = true; |
52 static bool useSkiaBitmaps = true; | 54 static bool useSkiaBitmaps = true; |
53 static bool useSkiaAntiAlias = true; | 55 static bool useSkiaAntiAlias = true; |
54 static bool useSkiaSubpixelRendering = false; | 56 static bool useSkiaSubpixelRendering = false; |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
117 FontPlatformData::FontPlatformData(const FontPlatformData& src) | 119 FontPlatformData::FontPlatformData(const FontPlatformData& src) |
118 : m_typeface(src.m_typeface) | 120 : m_typeface(src.m_typeface) |
119 , m_family(src.m_family) | 121 , m_family(src.m_family) |
120 , m_textSize(src.m_textSize) | 122 , m_textSize(src.m_textSize) |
121 , m_emSizeInFontUnits(src.m_emSizeInFontUnits) | 123 , m_emSizeInFontUnits(src.m_emSizeInFontUnits) |
122 , m_fakeBold(src.m_fakeBold) | 124 , m_fakeBold(src.m_fakeBold) |
123 , m_fakeItalic(src.m_fakeItalic) | 125 , m_fakeItalic(src.m_fakeItalic) |
124 , m_orientation(src.m_orientation) | 126 , m_orientation(src.m_orientation) |
125 , m_style(src.m_style) | 127 , m_style(src.m_style) |
126 , m_harfBuzzFace(src.m_harfBuzzFace) | 128 , m_harfBuzzFace(src.m_harfBuzzFace) |
| 129 , m_locale(src.m_locale) |
127 , m_isHashTableDeletedValue(false) | 130 , m_isHashTableDeletedValue(false) |
128 { | 131 { |
129 } | 132 } |
130 | 133 |
131 FontPlatformData::FontPlatformData(SkTypeface* tf, const char* family, float tex
tSize, bool fakeBold, bool fakeItalic, FontOrientation orientation) | 134 FontPlatformData::FontPlatformData(SkTypeface* tf, const char* family, float tex
tSize, bool fakeBold, bool fakeItalic, FontOrientation orientation, const Atomic
String& locale) |
132 : m_typeface(tf) | 135 : m_typeface(tf) |
133 , m_family(family) | 136 , m_family(family) |
134 , m_textSize(textSize) | 137 , m_textSize(textSize) |
135 , m_emSizeInFontUnits(0) | 138 , m_emSizeInFontUnits(0) |
136 , m_fakeBold(fakeBold) | 139 , m_fakeBold(fakeBold) |
137 , m_fakeItalic(fakeItalic) | 140 , m_fakeItalic(fakeItalic) |
138 , m_orientation(orientation) | 141 , m_orientation(orientation) |
| 142 , m_locale(locale) |
139 , m_isHashTableDeletedValue(false) | 143 , m_isHashTableDeletedValue(false) |
140 { | 144 { |
141 querySystemForRenderStyle(); | 145 querySystemForRenderStyle(); |
142 } | 146 } |
143 | 147 |
144 FontPlatformData::FontPlatformData(const FontPlatformData& src, float textSize) | 148 FontPlatformData::FontPlatformData(const FontPlatformData& src, float textSize) |
145 : m_typeface(src.m_typeface) | 149 : m_typeface(src.m_typeface) |
146 , m_family(src.m_family) | 150 , m_family(src.m_family) |
147 , m_textSize(textSize) | 151 , m_textSize(textSize) |
148 , m_emSizeInFontUnits(src.m_emSizeInFontUnits) | 152 , m_emSizeInFontUnits(src.m_emSizeInFontUnits) |
149 , m_fakeBold(src.m_fakeBold) | 153 , m_fakeBold(src.m_fakeBold) |
150 , m_fakeItalic(src.m_fakeItalic) | 154 , m_fakeItalic(src.m_fakeItalic) |
151 , m_orientation(src.m_orientation) | 155 , m_orientation(src.m_orientation) |
152 , m_harfBuzzFace(src.m_harfBuzzFace) | 156 , m_harfBuzzFace(src.m_harfBuzzFace) |
| 157 , m_locale(src.m_locale) |
153 , m_isHashTableDeletedValue(false) | 158 , m_isHashTableDeletedValue(false) |
154 { | 159 { |
155 querySystemForRenderStyle(); | 160 querySystemForRenderStyle(); |
156 } | 161 } |
157 | 162 |
158 FontPlatformData::~FontPlatformData() | 163 FontPlatformData::~FontPlatformData() |
159 { | 164 { |
160 } | 165 } |
161 | 166 |
162 int FontPlatformData::emSizeInFontUnits() const | 167 int FontPlatformData::emSizeInFontUnits() const |
163 { | 168 { |
164 if (m_emSizeInFontUnits) | 169 if (m_emSizeInFontUnits) |
165 return m_emSizeInFontUnits; | 170 return m_emSizeInFontUnits; |
166 | 171 |
167 m_emSizeInFontUnits = m_typeface->getUnitsPerEm(); | 172 m_emSizeInFontUnits = m_typeface->getUnitsPerEm(); |
168 return m_emSizeInFontUnits; | 173 return m_emSizeInFontUnits; |
169 } | 174 } |
170 | 175 |
171 FontPlatformData& FontPlatformData::operator=(const FontPlatformData& src) | 176 FontPlatformData& FontPlatformData::operator=(const FontPlatformData& src) |
172 { | 177 { |
173 m_typeface = src.m_typeface; | 178 m_typeface = src.m_typeface; |
174 m_family = src.m_family; | 179 m_family = src.m_family; |
175 m_textSize = src.m_textSize; | 180 m_textSize = src.m_textSize; |
176 m_fakeBold = src.m_fakeBold; | 181 m_fakeBold = src.m_fakeBold; |
177 m_fakeItalic = src.m_fakeItalic; | 182 m_fakeItalic = src.m_fakeItalic; |
178 m_harfBuzzFace = src.m_harfBuzzFace; | 183 m_harfBuzzFace = src.m_harfBuzzFace; |
179 m_orientation = src.m_orientation; | 184 m_orientation = src.m_orientation; |
180 m_style = src.m_style; | 185 m_style = src.m_style; |
| 186 m_locale = src.m_locale; |
181 m_emSizeInFontUnits = src.m_emSizeInFontUnits; | 187 m_emSizeInFontUnits = src.m_emSizeInFontUnits; |
182 | 188 |
183 return *this; | 189 return *this; |
184 } | 190 } |
185 | 191 |
186 #ifndef NDEBUG | 192 #ifndef NDEBUG |
187 String FontPlatformData::description() const | 193 String FontPlatformData::description() const |
188 { | 194 { |
189 return String(); | 195 return String(); |
190 } | 196 } |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
230 typefacesEqual = m_typeface == a.m_typeface; | 236 typefacesEqual = m_typeface == a.m_typeface; |
231 else | 237 else |
232 typefacesEqual = SkTypeface::Equal(m_typeface.get(), a.m_typeface.get())
; | 238 typefacesEqual = SkTypeface::Equal(m_typeface.get(), a.m_typeface.get())
; |
233 | 239 |
234 return typefacesEqual | 240 return typefacesEqual |
235 && m_textSize == a.m_textSize | 241 && m_textSize == a.m_textSize |
236 && m_fakeBold == a.m_fakeBold | 242 && m_fakeBold == a.m_fakeBold |
237 && m_fakeItalic == a.m_fakeItalic | 243 && m_fakeItalic == a.m_fakeItalic |
238 && m_orientation == a.m_orientation | 244 && m_orientation == a.m_orientation |
239 && m_style == a.m_style | 245 && m_style == a.m_style |
| 246 && m_locale == a.m_locale |
240 && m_isHashTableDeletedValue == a.m_isHashTableDeletedValue; | 247 && m_isHashTableDeletedValue == a.m_isHashTableDeletedValue; |
241 } | 248 } |
242 | 249 |
243 unsigned FontPlatformData::hash() const | 250 unsigned FontPlatformData::hash() const |
244 { | 251 { |
245 unsigned h = SkTypeface::UniqueID(m_typeface.get()); | 252 unsigned h = SkTypeface::UniqueID(m_typeface.get()); |
246 h ^= 0x01010101 * ((static_cast<int>(m_orientation) << 2) | (static_cast<int
>(m_fakeBold) << 1) | static_cast<int>(m_fakeItalic)); | 253 h ^= 0x01010101 * ((static_cast<int>(m_orientation) << 2) | (static_cast<int
>(m_fakeBold) << 1) | static_cast<int>(m_fakeItalic)); |
247 | 254 |
248 // This memcpy is to avoid a reinterpret_cast that breaks strict-aliasing | 255 // This memcpy is to avoid a reinterpret_cast that breaks strict-aliasing |
249 // rules. Memcpy is generally optimized enough so that performance doesn't | 256 // rules. Memcpy is generally optimized enough so that performance doesn't |
250 // matter here. | 257 // matter here. |
251 uint32_t textSizeBytes; | 258 uint32_t textSizeBytes; |
252 memcpy(&textSizeBytes, &m_textSize, sizeof(uint32_t)); | 259 memcpy(&textSizeBytes, &m_textSize, sizeof(uint32_t)); |
253 h ^= textSizeBytes; | 260 h ^= textSizeBytes; |
| 261 h ^= m_locale.isNull() ? 0 : CaseFoldingHash::hash(m_locale); |
254 | 262 |
255 return h; | 263 return h; |
256 } | 264 } |
257 | 265 |
258 bool FontPlatformData::isFixedPitch() const | 266 bool FontPlatformData::isFixedPitch() const |
259 { | 267 { |
260 notImplemented(); | 268 notImplemented(); |
261 return false; | 269 return false; |
262 } | 270 } |
263 | 271 |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
306 m_style.useAutoHint = useSkiaAutoHint; | 314 m_style.useAutoHint = useSkiaAutoHint; |
307 if (m_style.useSubpixelPositioning == FontRenderStyle::NoPreference) | 315 if (m_style.useSubpixelPositioning == FontRenderStyle::NoPreference) |
308 m_style.useSubpixelPositioning = useSkiaSubpixelPositioning; | 316 m_style.useSubpixelPositioning = useSkiaSubpixelPositioning; |
309 if (m_style.useAntiAlias == FontRenderStyle::NoPreference) | 317 if (m_style.useAntiAlias == FontRenderStyle::NoPreference) |
310 m_style.useAntiAlias = useSkiaAntiAlias; | 318 m_style.useAntiAlias = useSkiaAntiAlias; |
311 if (m_style.useSubpixelRendering == FontRenderStyle::NoPreference) | 319 if (m_style.useSubpixelRendering == FontRenderStyle::NoPreference) |
312 m_style.useSubpixelRendering = useSkiaSubpixelRendering; | 320 m_style.useSubpixelRendering = useSkiaSubpixelRendering; |
313 } | 321 } |
314 | 322 |
315 } // namespace WebCore | 323 } // namespace WebCore |
OLD | NEW |