Title: [128936] branches/safari-536.27-branch/Source/WebCore
Revision
128936
Author
[email protected]
Date
2012-09-18 15:03:12 -0700 (Tue, 18 Sep 2012)

Log Message

Merged r126666.  <rdar://problem/12030952>

Modified Paths

Diff

Modified: branches/safari-536.27-branch/Source/WebCore/ChangeLog (128935 => 128936)


--- branches/safari-536.27-branch/Source/WebCore/ChangeLog	2012-09-18 22:00:19 UTC (rev 128935)
+++ branches/safari-536.27-branch/Source/WebCore/ChangeLog	2012-09-18 22:03:12 UTC (rev 128936)
@@ -1,3 +1,24 @@
+2012-09-18  Lucas Forschler  <[email protected]>
+
+    Merge r126666.
+
+    2012-08-24  Roger Fong  <[email protected]>
+
+            -webkit-font-smoothing: antialiased should use CG font rendering code path, not GDI
+            https://bugs.webkit.org/show_bug.cgi?id=54004
+            <rdar://problem/8971429>
+
+            Reviewed by Dan Bernstein.
+
+            When specifying -webkit-font-smoothing: antialised; the code path ends up using GDI to draw the text. 
+            GDI ends up drawing subpixel antialiased text, not aliased text anyways.
+            The CG code path also has the capability of drawing antialiased text. The reason that the GDI path was 
+            used in the first place is no longer a concern here so we can stop using the GDI code path.
+
+            * platform/graphics/win/FontCGWin.cpp: Removing GDI font drawing code path.
+            (WebCore):
+            (WebCore::Font::drawGlyphs):
+
 2012-08-29  Timothy Hatcher  <[email protected]>
 
         Merge r126921.
@@ -205301,3 +205322,4 @@
 .
 .
 .
+.

Modified: branches/safari-536.27-branch/Source/WebCore/platform/graphics/win/FontCGWin.cpp (128935 => 128936)


--- branches/safari-536.27-branch/Source/WebCore/platform/graphics/win/FontCGWin.cpp	2012-09-18 22:00:19 UTC (rev 128935)
+++ branches/safari-536.27-branch/Source/WebCore/platform/graphics/win/FontCGWin.cpp	2012-09-18 22:03:12 UTC (rev 128936)
@@ -127,176 +127,6 @@
     return path;
 }
 
-static void drawGDIGlyphs(GraphicsContext* graphicsContext, const SimpleFontData* font, const GlyphBuffer& glyphBuffer, 
-                      int from, int numGlyphs, const FloatPoint& point)
-{
-    Color fillColor = graphicsContext->fillColor();
-
-    bool drawIntoBitmap = false;
-    TextDrawingModeFlags drawingMode = graphicsContext->textDrawingMode();
-    if (drawingMode == TextModeFill) {
-        if (!fillColor.alpha())
-            return;
-
-        drawIntoBitmap = fillColor.alpha() != 255 || graphicsContext->isInTransparencyLayer();
-        if (!drawIntoBitmap) {
-            FloatSize offset;
-            float blur;
-            Color color;
-            ColorSpace shadowColorSpace;
-
-            graphicsContext->getShadow(offset, blur, color, shadowColorSpace);
-            drawIntoBitmap = offset.width() || offset.height() || blur;
-        }
-    }
-
-    // We have to convert CG's two-dimensional floating point advances to just horizontal integer advances.
-    Vector<int, 2048> gdiAdvances;
-    int totalWidth = 0;
-    for (int i = 0; i < numGlyphs; i++) {
-        gdiAdvances.append(lroundf(glyphBuffer.advanceAt(from + i)));
-        totalWidth += gdiAdvances[i];
-    }
-
-    HDC hdc = 0;
-    OwnPtr<GraphicsContext::WindowsBitmap> bitmap;
-    IntRect textRect;
-    if (!drawIntoBitmap)
-        hdc = graphicsContext->getWindowsContext(textRect, true, false);
-    if (!hdc) {
-        drawIntoBitmap = true;
-        // We put slop into this rect, since glyphs can overflow the ascent/descent bounds and the left/right edges.
-        // FIXME: Can get glyphs' optical bounds (even from CG) to get this right.
-        const FontMetrics& fontMetrics = font->fontMetrics();
-        int lineGap = fontMetrics.lineGap();
-        textRect = IntRect(point.x() - (fontMetrics.ascent() + fontMetrics.descent()) / 2,
-                           point.y() - fontMetrics.ascent() - lineGap,
-                           totalWidth + fontMetrics.ascent() + fontMetrics.descent(),
-                           fontMetrics.lineSpacing());
-        bitmap = graphicsContext->createWindowsBitmap(textRect.size());
-        memset(bitmap->buffer(), 255, bitmap->bufferLength());
-        hdc = bitmap->hdc();
-
-        XFORM xform;
-        xform.eM11 = 1.0f;
-        xform.eM12 = 0.0f;
-        xform.eM21 = 0.0f;
-        xform.eM22 = 1.0f;
-        xform.eDx = -textRect.x();
-        xform.eDy = -textRect.y();
-        SetWorldTransform(hdc, &xform);
-    }
-
-    SelectObject(hdc, font->platformData().hfont());
-
-    // Set the correct color.
-    if (drawIntoBitmap)
-        SetTextColor(hdc, RGB(0, 0, 0));
-    else
-        SetTextColor(hdc, RGB(fillColor.red(), fillColor.green(), fillColor.blue()));
-
-    SetBkMode(hdc, TRANSPARENT);
-    SetTextAlign(hdc, TA_LEFT | TA_BASELINE);
-
-    // Uniscribe gives us offsets to help refine the positioning of combining glyphs.
-    FloatSize translation = glyphBuffer.offsetAt(from);
-    if (translation.width() || translation.height()) {
-        XFORM xform;
-        xform.eM11 = 1.0;
-        xform.eM12 = 0;
-        xform.eM21 = 0;
-        xform.eM22 = 1.0;
-        xform.eDx = translation.width();
-        xform.eDy = translation.height();
-        ModifyWorldTransform(hdc, &xform, MWT_LEFTMULTIPLY);
-    }
-
-    if (drawingMode == TextModeFill) {
-        XFORM xform;
-        xform.eM11 = 1.0;
-        xform.eM12 = 0;
-        xform.eM21 = font->platformData().syntheticOblique() ? -tanf(syntheticObliqueAngle * piFloat / 180.0f) : 0;
-        xform.eM22 = 1.0;
-        xform.eDx = point.x();
-        xform.eDy = point.y();
-        ModifyWorldTransform(hdc, &xform, MWT_LEFTMULTIPLY);
-        ExtTextOut(hdc, 0, 0, ETO_GLYPH_INDEX, 0, reinterpret_cast<const WCHAR*>(glyphBuffer.glyphs(from)), numGlyphs, gdiAdvances.data());
-        if (font->syntheticBoldOffset()) {
-            xform.eM21 = 0;
-            xform.eDx = font->syntheticBoldOffset();
-            xform.eDy = 0;
-            ModifyWorldTransform(hdc, &xform, MWT_LEFTMULTIPLY);
-            ExtTextOut(hdc, 0, 0, ETO_GLYPH_INDEX, 0, reinterpret_cast<const WCHAR*>(glyphBuffer.glyphs(from)), numGlyphs, gdiAdvances.data());
-        }
-    } else {
-        XFORM xform;
-        GetWorldTransform(hdc, &xform);
-        AffineTransform hdcTransform(xform.eM11, xform.eM21, xform.eM12, xform.eM22, xform.eDx, xform.eDy);
-        CGAffineTransform initialGlyphTransform = hdcTransform.isInvertible() ? hdcTransform.inverse() : CGAffineTransformIdentity;
-        if (font->platformData().syntheticOblique())
-            initialGlyphTransform = CGAffineTransformConcat(initialGlyphTransform, CGAffineTransformMake(1, 0, tanf(syntheticObliqueAngle * piFloat / 180.0f), 1, 0, 0));
-        initialGlyphTransform.tx = 0;
-        initialGlyphTransform.ty = 0;
-        CGContextRef cgContext = graphicsContext->platformContext();
-
-        CGContextSaveGState(cgContext);
-
-        BOOL fontSmoothingEnabled = false;
-        SystemParametersInfo(SPI_GETFONTSMOOTHING, 0, &fontSmoothingEnabled, 0);
-        CGContextSetShouldAntialias(cgContext, fontSmoothingEnabled);
-
-        CGContextScaleCTM(cgContext, 1.0, -1.0);
-        CGContextTranslateCTM(cgContext, point.x() + glyphBuffer.offsetAt(from).width(), -(point.y() + glyphBuffer.offsetAt(from).height()));
-
-        for (unsigned i = 0; i < numGlyphs; ++i) {
-            RetainPtr<CGPathRef> glyphPath(AdoptCF, createPathForGlyph(hdc, glyphBuffer.glyphAt(from + i)));
-            CGContextSaveGState(cgContext);
-            CGContextConcatCTM(cgContext, initialGlyphTransform);
-
-            if (drawingMode & TextModeFill) {
-                CGContextAddPath(cgContext, glyphPath.get());
-                CGContextFillPath(cgContext);
-                if (font->syntheticBoldOffset()) {
-                    CGContextTranslateCTM(cgContext, font->syntheticBoldOffset(), 0);
-                    CGContextAddPath(cgContext, glyphPath.get());
-                    CGContextFillPath(cgContext);
-                    CGContextTranslateCTM(cgContext, -font->syntheticBoldOffset(), 0);
-                }
-            }
-            if (drawingMode & TextModeStroke) {
-                CGContextAddPath(cgContext, glyphPath.get());
-                CGContextStrokePath(cgContext);
-                if (font->syntheticBoldOffset()) {
-                    CGContextTranslateCTM(cgContext, font->syntheticBoldOffset(), 0);
-                    CGContextAddPath(cgContext, glyphPath.get());
-                    CGContextStrokePath(cgContext);
-                    CGContextTranslateCTM(cgContext, -font->syntheticBoldOffset(), 0);
-                }
-            }
-
-            CGContextRestoreGState(cgContext);
-            CGContextTranslateCTM(cgContext, gdiAdvances[i], 0);
-        }
-
-        CGContextRestoreGState(cgContext);
-    }
-
-    if (drawIntoBitmap) {
-        UInt8* buffer = bitmap->buffer();
-        unsigned bufferLength = bitmap->bufferLength();
-        for (unsigned i = 0; i < bufferLength; i += 4) {
-            // Use green, which is always in the middle.
-            UInt8 alpha = (255 - buffer[i + 1]) * fillColor.alpha() / 255;
-            buffer[i] = fillColor.blue();
-            buffer[i + 1] = fillColor.green();
-            buffer[i + 2] = fillColor.red();
-            buffer[i + 3] = alpha;
-        }
-        graphicsContext->drawWindowsBitmap(bitmap.get(), textRect.location());
-    } else
-        graphicsContext->releaseWindowsContext(hdc, textRect, true, false);
-}
-
 void Font::drawGlyphs(GraphicsContext* graphicsContext, const SimpleFontData* font, const GlyphBuffer& glyphBuffer, 
                       int from, int numGlyphs, const FloatPoint& point) const
 {
@@ -327,11 +157,6 @@
         ASSERT_NOT_REACHED();
     }
 
-    if (font->platformData().useGDI() && !shouldUseFontSmoothing) {
-        drawGDIGlyphs(graphicsContext, font, glyphBuffer, from, numGlyphs, point);
-        return;
-    }
-
     uint32_t oldFontSmoothingStyle = wkSetFontSmoothingStyle(cgContext, shouldUseFontSmoothing);
 
     const FontPlatformData& platformData = font->platformData();
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to