Title: [96366] trunk/Source/WebCore
Revision
96366
Author
[email protected]
Date
2011-09-29 15:21:00 -0700 (Thu, 29 Sep 2011)

Log Message

Enable LCD text in Skia on Mac
https://bugs.webkit.org/show_bug.cgi?id=68734

Reviewed by Stephen White.

No new tests. Existing layout tests are generated
with LCD text disabled for pixel comparisons.

Duplicate the logic in FontMac.mm to pass settings
for antialiasing and smoothing. Also disable smoothing
for DumpRenderTree.

* platform/graphics/skia/FontSkia.cpp:
(WebCore::setupPaint):
(WebCore::Font::drawGlyphs):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (96365 => 96366)


--- trunk/Source/WebCore/ChangeLog	2011-09-29 22:16:56 UTC (rev 96365)
+++ trunk/Source/WebCore/ChangeLog	2011-09-29 22:21:00 UTC (rev 96366)
@@ -1,3 +1,21 @@
+2011-09-29  Cary Clark  <[email protected]>
+
+        Enable LCD text in Skia on Mac
+        https://bugs.webkit.org/show_bug.cgi?id=68734
+
+        Reviewed by Stephen White.
+
+        No new tests. Existing layout tests are generated
+        with LCD text disabled for pixel comparisons.
+
+        Duplicate the logic in FontMac.mm to pass settings
+        for antialiasing and smoothing. Also disable smoothing
+        for DumpRenderTree.
+ 
+        * platform/graphics/skia/FontSkia.cpp:
+        (WebCore::setupPaint):
+        (WebCore::Font::drawGlyphs):
+
 2011-09-29  Varun Jain  <[email protected]>
  
          Implement flick gesture in Chromium Gesture Recognizer

Modified: trunk/Source/WebCore/platform/graphics/skia/FontSkia.cpp (96365 => 96366)


--- trunk/Source/WebCore/platform/graphics/skia/FontSkia.cpp	2011-09-29 22:16:56 UTC (rev 96365)
+++ trunk/Source/WebCore/platform/graphics/skia/FontSkia.cpp	2011-09-29 22:21:00 UTC (rev 96366)
@@ -34,6 +34,7 @@
 #include "GlyphBuffer.h"
 #include "GraphicsContext.h"
 #include "PlatformContextSkia.h"
+#include "PlatformSupport.h"
 #include "SimpleFontData.h"
 
 #include "SkCanvas.h"
@@ -73,12 +74,12 @@
         paint->setLCDRenderText(false);
 }
 
-static void setupPaint(SkPaint* paint, const SimpleFontData* fontData, const Font* font)
+static void setupPaint(SkPaint* paint, const SimpleFontData* fontData, const Font* font, bool shouldAntialias, bool shouldSmoothFonts)
 {
     const FontPlatformData& platformData = fontData->platformData();
     const float textSize = platformData.m_size >= 0 ? platformData.m_size : 12;
 
-    paint->setAntiAlias(true);
+    paint->setAntiAlias(shouldAntialias);
     paint->setEmbeddedBitmapText(false);
     paint->setTextSize(SkFloatToScalar(textSize));
     SkTypeface* typeface = SkCreateTypefaceFromCTFont(platformData.ctFont());
@@ -87,7 +88,7 @@
     paint->setFakeBoldText(platformData.m_syntheticBold);
     paint->setTextSkewX(platformData.m_syntheticOblique ? -SK_Scalar1 / 4 : 0);
     paint->setAutohinted(false); // freetype specific
-    paint->setLCDRenderText(font->fontDescription().fontSmoothing() == SubpixelAntialiased);
+    paint->setLCDRenderText(shouldSmoothFonts);
 }
 
 // TODO: This needs to be split into helper functions to better scope the
@@ -98,6 +99,27 @@
                       const FloatPoint& point) const {
     COMPILE_ASSERT(sizeof(GlyphBufferGlyph) == sizeof(uint16_t), GlyphBufferGlyphSize_equals_uint16_t);
 
+    bool shouldSmoothFonts = true;
+    bool shouldAntialias = true;
+    
+    switch (fontDescription().fontSmoothing()) {
+    case Antialiased:
+        shouldSmoothFonts = false;
+        break;
+    case SubpixelAntialiased:
+        break;
+    case NoSmoothing:
+        shouldAntialias = false;
+        shouldSmoothFonts = false;
+        break;
+    case AutoSmoothing:
+        // For the AutoSmooth case, don't do anything! Keep the default settings.
+        break; 
+    }
+    
+    if (!shouldUseSmoothing() || PlatformSupport::layoutTestMode())
+        shouldSmoothFonts = false;
+
     const GlyphBufferGlyph* glyphs = glyphBuffer.glyphs(from);
     SkScalar x = SkFloatToScalar(point.x());
     SkScalar y = SkFloatToScalar(point.y());
@@ -133,7 +155,7 @@
     if (textMode & TextModeFill) {
         SkPaint paint;
         gc->platformContext()->setupPaintForFilling(&paint);
-        setupPaint(&paint, font, this);
+        setupPaint(&paint, font, this, shouldAntialias, shouldSmoothFonts);
         adjustTextRenderMode(&paint, gc->platformContext());
         paint.setTextEncoding(SkPaint::kGlyphID_TextEncoding);
         paint.setColor(gc->fillColor().rgb());
@@ -156,7 +178,7 @@
 
         SkPaint paint;
         gc->platformContext()->setupPaintForStroking(&paint, 0, 0);
-        setupPaint(&paint, font, this);
+        setupPaint(&paint, font, this, shouldAntialias, shouldSmoothFonts);
         adjustTextRenderMode(&paint, gc->platformContext());
         paint.setTextEncoding(SkPaint::kGlyphID_TextEncoding);
         paint.setColor(gc->strokeColor().rgb());
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to