Signal to skia to force A8 text from LCD output, but only when we have to disable...
authorvangelis@chromium.org <vangelis@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 26 Jan 2012 20:30:40 +0000 (20:30 +0000)
committervangelis@chromium.org <vangelis@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 26 Jan 2012 20:30:40 +0000 (20:30 +0000)
https://bugs.webkit.org/show_bug.cgi?id=76547

Patch by Mike Reed <reed@google.com> on 2012-01-26
Reviewed by Stephen White.

Existing tests should confirm nothing is broken. Antialiased text
is disabled in layouttests, so they should be unaffected by the
difference in antialiasing quality.

* platform/graphics/skia/SkiaFontWin.cpp:
(WebCore::setupPaintForFont):

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@106029 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebCore/ChangeLog
Source/WebCore/platform/graphics/skia/SkiaFontWin.cpp

index ce41389..e0de8d7 100644 (file)
@@ -1,3 +1,18 @@
+2012-01-26  Mike Reed  <reed@google.com>
+
+        Signal to skia to force A8 text from LCD output, but only when we have to disable LCD because we're in a layer
+        https://bugs.webkit.org/show_bug.cgi?id=76547
+
+        Reviewed by Stephen White.
+
+        Existing tests should confirm nothing is broken. Antialiased text
+        is disabled in layouttests, so they should be unaffected by the
+        difference in antialiasing quality.
+
+        * platform/graphics/skia/SkiaFontWin.cpp:
+        (WebCore::setupPaintForFont):
+
+
 2012-01-26  Anders Carlsson  <andersca@apple.com>
 
         Use PlatformWheelEvent::phase() to determine if a scroll gesture begins or ends
index 8bed354..1087cd0 100644 (file)
@@ -205,12 +205,24 @@ static void setupPaintForFont(SkPaint* paint, PlatformContextSkia* pcs,
     textFlags &= getDefaultGDITextFlags();
 
     // do this check after our switch on lfQuality
-    if (disableTextLCD(pcs))
+    if (disableTextLCD(pcs)) {
         textFlags &= ~SkPaint::kLCDRenderText_Flag;
+        // If we *just* clear our request for LCD, then GDI seems to
+        // sometimes give us AA text, and sometimes give us BW text. Since the
+        // original intent was LCD, we want to force AA (rather than BW), so we
+        // add a special bit to tell Skia to do its best to avoid the BW: by
+        // drawing LCD offscreen and downsampling that to AA.
+        textFlags |= SkPaint::kGenA8FromLCD_Flag;
+    }
+
+    static const uint32_t textFlagsMask = SkPaint::kAntiAlias_Flag |
+                                          SkPaint::kLCDRenderText_Flag |
+                                          SkPaint::kGenA8FromLCD_Flag;
 
     // now copy in just the text flags
+    SkASSERT(!(textFlags & ~textFlagsMask));
     uint32_t flags = paint->getFlags();
-    flags &= ~(SkPaint::kAntiAlias_Flag | SkPaint::kLCDRenderText_Flag);
+    flags &= ~textFlagsMask;
     flags |= textFlags;
     paint->setFlags(flags);
 }