| 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 17 matching lines...) Expand all Loading... |
| 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 29 */ | 29 */ |
| 30 | 30 |
| 31 #include "config.h" | 31 #include "config.h" |
| 32 #include "public/platform/Platform.h" | 32 #include "public/platform/Platform.h" |
| 33 | 33 |
| 34 #include "SkTypeface.h" | 34 #include "SkTypeface.h" |
| 35 #include "platform/LayoutTestSupport.h" | 35 #include "platform/LayoutTestSupport.h" |
| 36 #include "platform/RuntimeEnabledFeatures.h" | 36 #include "platform/RuntimeEnabledFeatures.h" |
| 37 #include "platform/fonts/harfbuzz/FontPlatformDataHarfBuzz.h" | 37 #include "platform/fonts/harfbuzz/FontPlatformDataHarfBuzz.h" |
| 38 #include "platform/graphics/GraphicsContext.h" |
| 38 #include "public/platform/linux/WebFontInfo.h" | 39 #include "public/platform/linux/WebFontInfo.h" |
| 39 #include "public/platform/linux/WebFontRenderStyle.h" | 40 #include "public/platform/linux/WebFontRenderStyle.h" |
| 40 #include "public/platform/linux/WebSandboxSupport.h" | 41 #include "public/platform/linux/WebSandboxSupport.h" |
| 41 | 42 |
| 42 namespace WebCore { | 43 namespace WebCore { |
| 43 | 44 |
| 44 static SkPaint::Hinting skiaHinting = SkPaint::kNormal_Hinting; | 45 static SkPaint::Hinting skiaHinting = SkPaint::kNormal_Hinting; |
| 45 static bool useSkiaAutoHint = true; | 46 static bool useSkiaAutoHint = true; |
| 46 static bool useSkiaBitmaps = true; | 47 static bool useSkiaBitmaps = true; |
| 47 static bool useSkiaAntiAlias = true; | 48 static bool useSkiaAntiAlias = true; |
| (...skipping 17 matching lines...) Expand all Loading... |
| 65 void FontPlatformData::setAntiAlias(bool useAntiAlias) | 66 void FontPlatformData::setAntiAlias(bool useAntiAlias) |
| 66 { | 67 { |
| 67 useSkiaAntiAlias = useAntiAlias; | 68 useSkiaAntiAlias = useAntiAlias; |
| 68 } | 69 } |
| 69 | 70 |
| 70 void FontPlatformData::setSubpixelRendering(bool useSubpixelRendering) | 71 void FontPlatformData::setSubpixelRendering(bool useSubpixelRendering) |
| 71 { | 72 { |
| 72 useSkiaSubpixelRendering = useSubpixelRendering; | 73 useSkiaSubpixelRendering = useSubpixelRendering; |
| 73 } | 74 } |
| 74 | 75 |
| 75 void FontPlatformData::setupPaint(SkPaint* paint, GraphicsContext*) const | 76 void FontPlatformData::setupPaint(SkPaint* paint, GraphicsContext* context) |
| 77 const |
| 76 { | 78 { |
| 77 paint->setAntiAlias(m_style.useAntiAlias); | 79 paint->setAntiAlias(m_style.useAntiAlias); |
| 78 paint->setHinting(static_cast<SkPaint::Hinting>(m_style.hintStyle)); | 80 paint->setHinting(static_cast<SkPaint::Hinting>(m_style.hintStyle)); |
| 79 paint->setEmbeddedBitmapText(m_style.useBitmaps); | 81 paint->setEmbeddedBitmapText(m_style.useBitmaps); |
| 80 paint->setAutohinted(m_style.useAutoHint); | 82 paint->setAutohinted(m_style.useAutoHint); |
| 81 if (m_style.useAntiAlias) | 83 if (m_style.useAntiAlias) |
| 82 paint->setLCDRenderText(m_style.useSubpixelRendering); | 84 paint->setLCDRenderText(m_style.useSubpixelRendering); |
| 83 | 85 |
| 86 // Do not enable subpixel text on low-dpi if full hinting is requested. |
| 87 bool useSubpixelText = RuntimeEnabledFeatures::subpixelFontScalingEnabled() |
| 88 && context && (paint->getHinting() != SkPaint::kFull_Hinting |
| 89 || context->deviceScaleFactor() > 1.0f); |
| 90 |
| 84 // TestRunner specifically toggles the subpixel positioning flag. | 91 // TestRunner specifically toggles the subpixel positioning flag. |
| 85 if (RuntimeEnabledFeatures::subpixelFontScalingEnabled() | 92 if (useSubpixelText && !LayoutTestSupport::isRunningLayoutTest()) |
| 86 && paint->getHinting() != SkPaint::kFull_Hinting | |
| 87 && !LayoutTestSupport::isRunningLayoutTest()) | |
| 88 paint->setSubpixelText(true); | 93 paint->setSubpixelText(true); |
| 89 else | 94 else |
| 90 paint->setSubpixelText(m_style.useSubpixelPositioning); | 95 paint->setSubpixelText(m_style.useSubpixelPositioning); |
| 91 | 96 |
| 92 const float ts = m_textSize >= 0 ? m_textSize : 12; | 97 const float ts = m_textSize >= 0 ? m_textSize : 12; |
| 93 paint->setTextSize(SkFloatToScalar(ts)); | 98 paint->setTextSize(SkFloatToScalar(ts)); |
| 94 paint->setTypeface(m_typeface.get()); | 99 paint->setTypeface(m_typeface.get()); |
| 95 paint->setFakeBoldText(m_syntheticBold); | 100 paint->setFakeBoldText(m_syntheticBold); |
| 96 paint->setTextSkewX(m_syntheticItalic ? -SK_Scalar1 / 4 : 0); | 101 paint->setTextSkewX(m_syntheticItalic ? -SK_Scalar1 / 4 : 0); |
| 97 } | 102 } |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 142 || LayoutTestSupport::isRunningLayoutTest()) | 147 || LayoutTestSupport::isRunningLayoutTest()) |
| 143 m_style.useSubpixelPositioning = useSkiaSubpixelPositioning; | 148 m_style.useSubpixelPositioning = useSkiaSubpixelPositioning; |
| 144 } | 149 } |
| 145 | 150 |
| 146 bool FontPlatformData::defaultUseSubpixelPositioning() | 151 bool FontPlatformData::defaultUseSubpixelPositioning() |
| 147 { | 152 { |
| 148 return FontDescription::subpixelPositioning(); | 153 return FontDescription::subpixelPositioning(); |
| 149 } | 154 } |
| 150 | 155 |
| 151 } // namespace WebCore | 156 } // namespace WebCore |
| OLD | NEW |