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

Side by Side Diff: Source/core/platform/graphics/chromium/FontPlatformDataChromiumWin.cpp

Issue 24874002: Have all skia platforms share FontPlatformData::hash() implementation (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 7 years, 2 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 | Annotate | Revision Log
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2006, 2007 Apple Computer, Inc. 2 * Copyright (C) 2006, 2007 Apple Computer, Inc.
3 * Copyright (c) 2006, 2007, 2008, 2009, 2012 Google Inc. All rights reserved. 3 * Copyright (c) 2006, 2007, 2008, 2009, 2012 Google Inc. All rights reserved.
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are 6 * modification, are permitted provided that the following conditions are
7 * met: 7 * met:
8 * 8 *
9 * * Redistributions of source code must retain the above copyright 9 * * Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer. 10 * notice, this list of conditions and the following disclaimer.
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
46 #include "third_party/skia/include/core/SkPaint.h" 46 #include "third_party/skia/include/core/SkPaint.h"
47 #include "third_party/skia/include/core/SkTypeface.h" 47 #include "third_party/skia/include/core/SkTypeface.h"
48 #include "third_party/skia/include/ports/SkTypeface_win.h" 48 #include "third_party/skia/include/ports/SkTypeface_win.h"
49 #include "wtf/PassOwnPtr.h" 49 #include "wtf/PassOwnPtr.h"
50 #include "wtf/StdLibExtras.h" 50 #include "wtf/StdLibExtras.h"
51 51
52 namespace WebCore { 52 namespace WebCore {
53 53
54 void FontPlatformData::setupPaint(SkPaint* paint, GraphicsContext* context) cons t 54 void FontPlatformData::setupPaint(SkPaint* paint, GraphicsContext* context) cons t
55 { 55 {
56 const float ts = m_size >= 0 ? m_size : 12; 56 const float ts = m_textSize >= 0 ? m_textSize : 12;
57 paint->setTextSize(SkFloatToScalar(m_size)); 57 paint->setTextSize(SkFloatToScalar(m_textSize));
58 paint->setTypeface(typeface()); 58 paint->setTypeface(typeface());
59 paint->setFakeBoldText(m_fakeBold); 59 paint->setFakeBoldText(m_fakeBold);
60 paint->setTextSkewX(m_fakeItalic ? -SK_Scalar1 / 4 : 0); 60 paint->setTextSkewX(m_fakeItalic ? -SK_Scalar1 / 4 : 0);
61 61
62 // Only set painting flags when we're actually painting. 62 // Only set painting flags when we're actually painting.
63 if (context) { 63 if (context) {
64 int textFlags = paintTextFlags(); 64 int textFlags = paintTextFlags();
65 if (!context->couldUseLCDRenderedText()) { 65 if (!context->couldUseLCDRenderedText()) {
66 textFlags &= ~SkPaint::kLCDRenderText_Flag; 66 textFlags &= ~SkPaint::kLCDRenderText_Flag;
67 // If we *just* clear our request for LCD, then GDI seems to 67 // If we *just* clear our request for LCD, then GDI seems to
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
162 height = -height; 162 height = -height;
163 *size = height; 163 *size = height;
164 } 164 }
165 if (paintTextFlags) 165 if (paintTextFlags)
166 *paintTextFlags = computePaintTextFlags(info); 166 *paintTextFlags = computePaintTextFlags(info);
167 return adoptRef(SkCreateTypefaceFromLOGFONT(info)); 167 return adoptRef(SkCreateTypefaceFromLOGFONT(info));
168 } 168 }
169 169
170 FontPlatformData::FontPlatformData(WTF::HashTableDeletedValueType) 170 FontPlatformData::FontPlatformData(WTF::HashTableDeletedValueType)
171 : m_font(0) 171 : m_font(0)
172 , m_size(-1) 172 , m_textSize(-1)
173 , m_fakeBold(false) 173 , m_fakeBold(false)
174 , m_fakeItalic(false) 174 , m_fakeItalic(false)
175 , m_orientation(Horizontal) 175 , m_orientation(Horizontal)
176 , m_scriptCache(0) 176 , m_scriptCache(0)
177 , m_typeface(SkTypeface::RefDefault()) 177 , m_typeface(SkTypeface::RefDefault())
178 , m_paintTextFlags(0) 178 , m_paintTextFlags(0)
179 , m_isHashTableDeletedValue(true) 179 , m_isHashTableDeletedValue(true)
180 { 180 {
181 } 181 }
182 182
183 FontPlatformData::FontPlatformData() 183 FontPlatformData::FontPlatformData()
184 : m_font(0) 184 : m_font(0)
185 , m_size(0) 185 , m_textSize(0)
186 , m_fakeBold(false) 186 , m_fakeBold(false)
187 , m_fakeItalic(false) 187 , m_fakeItalic(false)
188 , m_orientation(Horizontal) 188 , m_orientation(Horizontal)
189 , m_scriptCache(0) 189 , m_scriptCache(0)
190 , m_typeface(SkTypeface::RefDefault()) 190 , m_typeface(SkTypeface::RefDefault())
191 , m_paintTextFlags(0) 191 , m_paintTextFlags(0)
192 , m_isHashTableDeletedValue(false) 192 , m_isHashTableDeletedValue(false)
193 { 193 {
194 } 194 }
195 195
196 FontPlatformData::FontPlatformData(HFONT font, float size, FontOrientation orien tation) 196 FontPlatformData::FontPlatformData(HFONT font, float size, FontOrientation orien tation)
197 : m_font(RefCountedHFONT::create(font)) 197 : m_font(RefCountedHFONT::create(font))
198 , m_size(size) 198 , m_textSize(size)
199 , m_fakeBold(false) 199 , m_fakeBold(false)
200 , m_fakeItalic(false) 200 , m_fakeItalic(false)
201 , m_orientation(orientation) 201 , m_orientation(orientation)
202 , m_scriptCache(0) 202 , m_scriptCache(0)
203 , m_typeface(CreateTypefaceFromHFont(font, 0, &m_paintTextFlags)) 203 , m_typeface(CreateTypefaceFromHFont(font, 0, &m_paintTextFlags))
204 , m_isHashTableDeletedValue(false) 204 , m_isHashTableDeletedValue(false)
205 { 205 {
206 } 206 }
207 207
208 // FIXME: this constructor is needed for SVG fonts but doesn't seem to do much 208 // FIXME: this constructor is needed for SVG fonts but doesn't seem to do much
209 FontPlatformData::FontPlatformData(float size, bool bold, bool oblique) 209 FontPlatformData::FontPlatformData(float size, bool bold, bool oblique)
210 : m_font(0) 210 : m_font(0)
211 , m_size(size) 211 , m_textSize(size)
212 , m_fakeBold(false) 212 , m_fakeBold(false)
213 , m_fakeItalic(false) 213 , m_fakeItalic(false)
214 , m_orientation(Horizontal) 214 , m_orientation(Horizontal)
215 , m_scriptCache(0) 215 , m_scriptCache(0)
216 , m_typeface(SkTypeface::RefDefault()) 216 , m_typeface(SkTypeface::RefDefault())
217 , m_paintTextFlags(0) 217 , m_paintTextFlags(0)
218 , m_isHashTableDeletedValue(false) 218 , m_isHashTableDeletedValue(false)
219 { 219 {
220 } 220 }
221 221
222 FontPlatformData::FontPlatformData(const FontPlatformData& data) 222 FontPlatformData::FontPlatformData(const FontPlatformData& data)
223 : m_font(data.m_font) 223 : m_font(data.m_font)
224 , m_size(data.m_size) 224 , m_textSize(data.m_textSize)
225 , m_fakeBold(false) 225 , m_fakeBold(false)
226 , m_fakeItalic(false) 226 , m_fakeItalic(false)
227 , m_orientation(data.m_orientation) 227 , m_orientation(data.m_orientation)
228 , m_scriptCache(0) 228 , m_scriptCache(0)
229 , m_typeface(data.m_typeface) 229 , m_typeface(data.m_typeface)
230 , m_paintTextFlags(data.m_paintTextFlags) 230 , m_paintTextFlags(data.m_paintTextFlags)
231 , m_isHashTableDeletedValue(false) 231 , m_isHashTableDeletedValue(false)
232 { 232 {
233 } 233 }
234 234
235 FontPlatformData::FontPlatformData(const FontPlatformData& data, float textSize) 235 FontPlatformData::FontPlatformData(const FontPlatformData& data, float textSize)
236 : m_font(data.m_font) 236 : m_font(data.m_font)
237 , m_size(textSize) 237 , m_textSize(textSize)
238 , m_fakeBold(false) 238 , m_fakeBold(false)
239 , m_fakeItalic(false) 239 , m_fakeItalic(false)
240 , m_orientation(data.m_orientation) 240 , m_orientation(data.m_orientation)
241 , m_scriptCache(0) 241 , m_scriptCache(0)
242 , m_typeface(data.m_typeface) 242 , m_typeface(data.m_typeface)
243 , m_paintTextFlags(data.m_paintTextFlags) 243 , m_paintTextFlags(data.m_paintTextFlags)
244 , m_isHashTableDeletedValue(false) 244 , m_isHashTableDeletedValue(false)
245 { 245 {
246 } 246 }
247 247
248 FontPlatformData::FontPlatformData(SkTypeface* tf, const char* family, float tex tSize, bool fakeBold, bool fakeItalic, FontOrientation orientation) 248 FontPlatformData::FontPlatformData(SkTypeface* tf, const char* family, float tex tSize, bool fakeBold, bool fakeItalic, FontOrientation orientation)
249 : m_font(0) 249 : m_font(0)
250 , m_size(textSize) 250 , m_textSize(textSize)
251 , m_fakeBold(fakeBold) 251 , m_fakeBold(fakeBold)
252 , m_fakeItalic(fakeItalic) 252 , m_fakeItalic(fakeItalic)
253 , m_orientation(orientation) 253 , m_orientation(orientation)
254 , m_scriptCache(0) 254 , m_scriptCache(0)
255 , m_typeface(tf) 255 , m_typeface(tf)
256 , m_isHashTableDeletedValue(false) 256 , m_isHashTableDeletedValue(false)
257 { 257 {
258 // FIXME: This can be removed together with m_font once the last few 258 // FIXME: This can be removed together with m_font once the last few
259 // uses of hfont() has been eliminated. 259 // uses of hfont() has been eliminated.
260 LOGFONT logFont; 260 LOGFONT logFont;
261 SkLOGFONTFromTypeface(tf, &logFont); 261 SkLOGFONTFromTypeface(tf, &logFont);
262 logFont.lfHeight = -textSize; 262 logFont.lfHeight = -textSize;
263 HFONT hFont = CreateFontIndirect(&logFont); 263 HFONT hFont = CreateFontIndirect(&logFont);
264 if (hFont) 264 if (hFont)
265 m_font = RefCountedHFONT::create(hFont); 265 m_font = RefCountedHFONT::create(hFont);
266 m_paintTextFlags = computePaintTextFlags(logFont); 266 m_paintTextFlags = computePaintTextFlags(logFont);
267 } 267 }
268 268
269 FontPlatformData& FontPlatformData::operator=(const FontPlatformData& data) 269 FontPlatformData& FontPlatformData::operator=(const FontPlatformData& data)
270 { 270 {
271 if (this != &data) { 271 if (this != &data) {
272 m_font = data.m_font; 272 m_font = data.m_font;
273 m_size = data.m_size; 273 m_textSize = data.m_textSize;
274 m_fakeBold = data.m_fakeBold; 274 m_fakeBold = data.m_fakeBold;
275 m_fakeItalic = data.m_fakeItalic; 275 m_fakeItalic = data.m_fakeItalic;
276 m_orientation = data.m_orientation; 276 m_orientation = data.m_orientation;
277 m_typeface = data.m_typeface; 277 m_typeface = data.m_typeface;
278 m_paintTextFlags = data.m_paintTextFlags; 278 m_paintTextFlags = data.m_paintTextFlags;
279 279
280 // The following fields will get re-computed if necessary. 280 // The following fields will get re-computed if necessary.
281 ScriptFreeCache(&m_scriptCache); 281 ScriptFreeCache(&m_scriptCache);
282 m_scriptCache = 0; 282 m_scriptCache = 0;
283 m_scriptFontProperties.clear(); 283 m_scriptFontProperties.clear();
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
374 374
375 bool FontPlatformData::ensureFontLoaded(HFONT font) 375 bool FontPlatformData::ensureFontLoaded(HFONT font)
376 { 376 {
377 WebKit::WebSandboxSupport* sandboxSupport = WebKit::Platform::current()->san dboxSupport(); 377 WebKit::WebSandboxSupport* sandboxSupport = WebKit::Platform::current()->san dboxSupport();
378 // if there is no sandbox, then we can assume the font 378 // if there is no sandbox, then we can assume the font
379 // was able to be loaded successfully already 379 // was able to be loaded successfully already
380 return sandboxSupport ? sandboxSupport->ensureFontLoaded(font) : true; 380 return sandboxSupport ? sandboxSupport->ensureFontLoaded(font) : true;
381 } 381 }
382 382
383 } 383 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698