OLD | NEW |
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 20 matching lines...) Expand all Loading... |
31 | 31 |
32 #include "config.h" | 32 #include "config.h" |
33 #include "core/platform/graphics/FontPlatformData.h" | 33 #include "core/platform/graphics/FontPlatformData.h" |
34 | 34 |
35 #include <windows.h> | 35 #include <windows.h> |
36 #include <mlang.h> | 36 #include <mlang.h> |
37 #include <objidl.h> | 37 #include <objidl.h> |
38 #include "core/platform/LayoutTestSupport.h" | 38 #include "core/platform/LayoutTestSupport.h" |
39 #include "core/platform/SharedBuffer.h" | 39 #include "core/platform/SharedBuffer.h" |
40 #include "core/platform/graphics/FontCache.h" | 40 #include "core/platform/graphics/FontCache.h" |
| 41 #include "core/platform/graphics/GraphicsContext.h" |
41 #include "core/platform/graphics/skia/SkiaFontWin.h" | 42 #include "core/platform/graphics/skia/SkiaFontWin.h" |
42 #include "core/platform/win/HWndDC.h" | 43 #include "core/platform/win/HWndDC.h" |
43 #include "public/platform/Platform.h" | 44 #include "public/platform/Platform.h" |
44 #include "public/platform/win/WebSandboxSupport.h" | 45 #include "public/platform/win/WebSandboxSupport.h" |
45 #include "third_party/skia/include/core/SkPaint.h" | 46 #include "third_party/skia/include/core/SkPaint.h" |
46 #include "third_party/skia/include/core/SkTypeface.h" | 47 #include "third_party/skia/include/core/SkTypeface.h" |
47 #include "third_party/skia/include/ports/SkTypeface_win.h" | 48 #include "third_party/skia/include/ports/SkTypeface_win.h" |
48 #include "wtf/PassOwnPtr.h" | 49 #include "wtf/PassOwnPtr.h" |
49 #include "wtf/StdLibExtras.h" | 50 #include "wtf/StdLibExtras.h" |
50 | 51 |
51 namespace WebCore { | 52 namespace WebCore { |
52 | 53 |
53 #if !ENABLE(GDI_FONTS_ON_WINDOWS) | 54 void FontPlatformData::setupPaint(SkPaint* paint, GraphicsContext* context) cons
t |
54 void FontPlatformData::setupPaint(SkPaint* paint) const | |
55 { | 55 { |
56 const float ts = m_size >= 0 ? m_size : 12; | 56 const float ts = m_size >= 0 ? m_size : 12; |
57 paint->setTextSize(SkFloatToScalar(m_size)); | 57 paint->setTextSize(SkFloatToScalar(m_size)); |
58 paint->setTypeface(typeface()); | 58 paint->setTypeface(typeface()); |
| 59 |
| 60 // Only set painting flags when we're actually painting. |
| 61 if (context) { |
| 62 int textFlags = paintTextFlags(); |
| 63 if (!context->couldUseLCDRenderedText()) { |
| 64 textFlags &= ~SkPaint::kLCDRenderText_Flag; |
| 65 // If we *just* clear our request for LCD, then GDI seems to |
| 66 // sometimes give us AA text, and sometimes give us BW text. Since t
he |
| 67 // original intent was LCD, we want to force AA (rather than BW), so
we |
| 68 // add a special bit to tell Skia to do its best to avoid the BW: by |
| 69 // drawing LCD offscreen and downsampling that to AA. |
| 70 textFlags |= SkPaint::kGenA8FromLCD_Flag; |
| 71 } |
| 72 |
| 73 static const uint32_t textFlagsMask = SkPaint::kAntiAlias_Flag | |
| 74 SkPaint::kLCDRenderText_Flag | |
| 75 SkPaint::kGenA8FromLCD_Flag; |
| 76 |
| 77 SkASSERT(!(textFlags & ~textFlagsMask)); |
| 78 uint32_t flags = paint->getFlags(); |
| 79 flags &= ~textFlagsMask; |
| 80 flags |= textFlags; |
| 81 paint->setFlags(flags); |
| 82 } |
59 } | 83 } |
60 #endif | |
61 | 84 |
62 // Lookup the current system settings for font smoothing. | 85 // Lookup the current system settings for font smoothing. |
63 // We cache these values for performance, but if the browser has a way to be | 86 // We cache these values for performance, but if the browser has a way to be |
64 // notified when these change, we could re-query them at that time. | 87 // notified when these change, we could re-query them at that time. |
65 static uint32_t getDefaultGDITextFlags() | 88 static uint32_t getDefaultGDITextFlags() |
66 { | 89 { |
67 static bool gInited; | 90 static bool gInited; |
68 static uint32_t gFlags; | 91 static uint32_t gFlags; |
69 if (!gInited) { | 92 if (!gInited) { |
70 BOOL enabled; | 93 BOOL enabled; |
(...skipping 262 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
333 | 356 |
334 bool FontPlatformData::ensureFontLoaded(HFONT font) | 357 bool FontPlatformData::ensureFontLoaded(HFONT font) |
335 { | 358 { |
336 WebKit::WebSandboxSupport* sandboxSupport = WebKit::Platform::current()->san
dboxSupport(); | 359 WebKit::WebSandboxSupport* sandboxSupport = WebKit::Platform::current()->san
dboxSupport(); |
337 // if there is no sandbox, then we can assume the font | 360 // if there is no sandbox, then we can assume the font |
338 // was able to be loaded successfully already | 361 // was able to be loaded successfully already |
339 return sandboxSupport ? sandboxSupport->ensureFontLoaded(font) : true; | 362 return sandboxSupport ? sandboxSupport->ensureFontLoaded(font) : true; |
340 } | 363 } |
341 | 364 |
342 } | 365 } |
OLD | NEW |