[SCM] WebKit Debian packaging branch, debian/experimental, updated. upstream/1.3.3-10851-g50815da

simon.fraser at apple.com simon.fraser at apple.com
Wed Dec 22 18:41:42 UTC 2010


The following commit has been merged in the debian/experimental branch:
commit 71446447207038e7fcb0406c924e0be530f3c5f3
Author: simon.fraser at apple.com <simon.fraser at apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Wed Dec 15 23:34:56 2010 +0000

    2010-12-15  Simon Fraser  <simon.fraser at apple.com>
    
            Reviewed by Dan Bernstein.
    
            Allow disabling of font smoothing in compositing layers to be overridden by style
            https://bugs.webkit.org/show_bug.cgi?id=50732
    
            Add methods to GraphicsContext to get and set font smoothing,
            and have them be part of the graphics state.
    
            Fix Font::drawGlyphs() to allow the font's smoothing mode (from style)
            to override the current smoothing mode of the context. The global
            shouldUseSmoothing() still has final say.
    
            Turn off smoothing in compositing layers with this, rather than
            the non-stateful 'allow' method.
    
            * manual-tests/compositing/font-smoothing.html: Added.
            Manual test because DRT disables font smoothing.
    
            * platform/graphics/GraphicsContext.cpp:
            (WebCore::GraphicsContext::setShouldSmoothFonts):
            (WebCore::GraphicsContext::shouldSmoothFonts):
            (WebCore::GraphicsContext::setPlatformShouldSmoothFonts):
            * platform/graphics/GraphicsContext.h:
            (WebCore::GraphicsContextState::GraphicsContextState):
            * platform/graphics/cg/GraphicsContextCG.cpp:
            (WebCore::GraphicsContext::setPlatformShouldSmoothFonts):
            * platform/graphics/mac/FontMac.mm:
            (WebCore::Font::drawGlyphs):
            * platform/graphics/mac/WebLayer.mm:
            (drawLayerContents):
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@74151 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/WebCore/ChangeLog b/WebCore/ChangeLog
index e25b2e3..7cebca5 100644
--- a/WebCore/ChangeLog
+++ b/WebCore/ChangeLog
@@ -1,3 +1,36 @@
+2010-12-15  Simon Fraser  <simon.fraser at apple.com>
+
+        Reviewed by Dan Bernstein.
+
+        Allow disabling of font smoothing in compositing layers to be overridden by style
+        https://bugs.webkit.org/show_bug.cgi?id=50732
+
+        Add methods to GraphicsContext to get and set font smoothing,
+        and have them be part of the graphics state.
+        
+        Fix Font::drawGlyphs() to allow the font's smoothing mode (from style)
+        to override the current smoothing mode of the context. The global
+        shouldUseSmoothing() still has final say.
+        
+        Turn off smoothing in compositing layers with this, rather than
+        the non-stateful 'allow' method.
+        
+        * manual-tests/compositing/font-smoothing.html: Added.
+        Manual test because DRT disables font smoothing.
+        
+        * platform/graphics/GraphicsContext.cpp:
+        (WebCore::GraphicsContext::setShouldSmoothFonts):
+        (WebCore::GraphicsContext::shouldSmoothFonts):
+        (WebCore::GraphicsContext::setPlatformShouldSmoothFonts):
+        * platform/graphics/GraphicsContext.h:
+        (WebCore::GraphicsContextState::GraphicsContextState):
+        * platform/graphics/cg/GraphicsContextCG.cpp:
+        (WebCore::GraphicsContext::setPlatformShouldSmoothFonts):
+        * platform/graphics/mac/FontMac.mm:
+        (WebCore::Font::drawGlyphs):
+        * platform/graphics/mac/WebLayer.mm:
+        (drawLayerContents):
+
 2010-12-15  Matthew Delaney  <mdelaney at apple.com>
 
         Reviewed by Simon Fraser.
diff --git a/WebCore/manual-tests/compositing/font-smoothing.html b/WebCore/manual-tests/compositing/font-smoothing.html
new file mode 100644
index 0000000..fce444e
--- /dev/null
+++ b/WebCore/manual-tests/compositing/font-smoothing.html
@@ -0,0 +1,34 @@
+<!DOCTYPE html>
+
+<html>
+  <style type="text/css" media="screen">
+    div {
+      margin: 20px;
+      font-size: 24pt;
+    }
+
+    .composited {
+      -webkit-transform: translateZ(0);
+      background-color: white;
+    }
+    
+    .smoothed {
+      -webkit-font-smoothing: subpixel-antialiased;
+    }
+  </style>
+<head>
+</head>
+<body>
+  <div class="composited">
+    This text should be antialiased, but not smoothed.
+  </div>
+
+  <div class="smoothed composited">
+    This text should be antialiased and smoothed.
+  </div>
+
+  <div>
+    This text should be antialiased and smoothed in the browser, and antialiased in pixel results.
+  </div>
+</body>
+</html>
diff --git a/WebCore/platform/graphics/GraphicsContext.cpp b/WebCore/platform/graphics/GraphicsContext.cpp
index 6d32161..f7dcc62 100644
--- a/WebCore/platform/graphics/GraphicsContext.cpp
+++ b/WebCore/platform/graphics/GraphicsContext.cpp
@@ -215,6 +215,17 @@ bool GraphicsContext::shouldAntialias() const
     return m_state.shouldAntialias;
 }
 
+void GraphicsContext::setShouldSmoothFonts(bool b)
+{
+    m_state.shouldSmoothFonts = b;
+    setPlatformShouldSmoothFonts(b);
+}
+
+bool GraphicsContext::shouldSmoothFonts() const
+{
+    return m_state.shouldSmoothFonts;
+}
+
 const GraphicsContextState& GraphicsContext::state() const
 {
     return m_state;
@@ -594,6 +605,12 @@ void GraphicsContext::setPlatformStrokeStyle(const StrokeStyle&)
 }
 #endif
 
+#if !PLATFORM(CG)
+void GraphicsContext::setPlatformShouldSmoothFonts(bool)
+{
+}
+#endif
+
 #if !PLATFORM(SKIA)
 void GraphicsContext::setSharedGraphicsContext3D(SharedGraphicsContext3D*, DrawingBuffer*, const IntSize&)
 {
diff --git a/WebCore/platform/graphics/GraphicsContext.h b/WebCore/platform/graphics/GraphicsContext.h
index 6872d8a..a9b8cd9 100644
--- a/WebCore/platform/graphics/GraphicsContext.h
+++ b/WebCore/platform/graphics/GraphicsContext.h
@@ -164,6 +164,7 @@ namespace WebCore {
             , fillColorSpace(ColorSpaceDeviceRGB)
             , compositeOperator(CompositeSourceOver)
             , shouldAntialias(true)
+            , shouldSmoothFonts(true)
             , paintingDisabled(false)
             , shadowsIgnoreTransforms(false)
         {
@@ -197,9 +198,10 @@ namespace WebCore {
 
         CompositeOperator compositeOperator;
 
-        bool shouldAntialias;
-        bool paintingDisabled;
-        bool shadowsIgnoreTransforms;
+        bool shouldAntialias : 1;
+        bool shouldSmoothFonts : 1;
+        bool paintingDisabled : 1;
+        bool shadowsIgnoreTransforms : 1;
     };
 
     class GraphicsContext : public Noncopyable {
@@ -242,6 +244,9 @@ namespace WebCore {
         void setShouldAntialias(bool);
         bool shouldAntialias() const;
 
+        void setShouldSmoothFonts(bool);
+        bool shouldSmoothFonts() const;
+
         const GraphicsContextState& state() const;
 
 #if PLATFORM(CG)
@@ -497,7 +502,8 @@ namespace WebCore {
         void setPlatformFillGradient(Gradient*);
         void setPlatformFillPattern(Pattern*);
 
-        void setPlatformShouldAntialias(bool b);
+        void setPlatformShouldAntialias(bool);
+        void setPlatformShouldSmoothFonts(bool);
 
         void setPlatformShadow(const FloatSize&, float blur, const Color&, ColorSpace);
         void clearPlatformShadow();
diff --git a/WebCore/platform/graphics/cg/GraphicsContextCG.cpp b/WebCore/platform/graphics/cg/GraphicsContextCG.cpp
index 3d70fc2..7898d62 100644
--- a/WebCore/platform/graphics/cg/GraphicsContextCG.cpp
+++ b/WebCore/platform/graphics/cg/GraphicsContextCG.cpp
@@ -1188,6 +1188,13 @@ void GraphicsContext::setPlatformShouldAntialias(bool enable)
     CGContextSetShouldAntialias(platformContext(), enable);
 }
 
+void GraphicsContext::setPlatformShouldSmoothFonts(bool enable)
+{
+    if (paintingDisabled())
+        return;
+    CGContextSetShouldSmoothFonts(platformContext(), enable);
+}
+
 #ifndef BUILDING_ON_TIGER // Tiger's setPlatformCompositeOperation() is defined in GraphicsContextMac.mm.
 void GraphicsContext::setPlatformCompositeOperation(CompositeOperator mode)
 {
diff --git a/WebCore/platform/graphics/mac/FontMac.mm b/WebCore/platform/graphics/mac/FontMac.mm
index 8f15cb3..403fbe0 100644
--- a/WebCore/platform/graphics/mac/FontMac.mm
+++ b/WebCore/platform/graphics/mac/FontMac.mm
@@ -91,22 +91,27 @@ static void showGlyphsWithAdvances(const SimpleFontData* font, CGContextRef cont
 void Font::drawGlyphs(GraphicsContext* context, const SimpleFontData* font, const GlyphBuffer& glyphBuffer, int from, int numGlyphs, const FloatPoint& point) const
 {
     CGContextRef cgContext = context->platformContext();
-    bool newShouldUseFontSmoothing = shouldUseSmoothing();
 
+    bool shouldSmoothFonts = true;
+    bool changeFontSmoothing = false;
+    
     switch(fontDescription().fontSmoothing()) {
     case Antialiased: {
         context->setShouldAntialias(true);
-        newShouldUseFontSmoothing = false;
+        shouldSmoothFonts = false;
+        changeFontSmoothing = true;
         break;
     }
     case SubpixelAntialiased: {
         context->setShouldAntialias(true);
-        newShouldUseFontSmoothing = true;
+        shouldSmoothFonts = true;
+        changeFontSmoothing = true;
         break;
     }
     case NoSmoothing: {
         context->setShouldAntialias(false);
-        newShouldUseFontSmoothing = false;
+        shouldSmoothFonts = false;
+        changeFontSmoothing = true;
         break;
     }
     case AutoSmoothing: {
@@ -116,11 +121,18 @@ void Font::drawGlyphs(GraphicsContext* context, const SimpleFontData* font, cons
     default: 
         ASSERT_NOT_REACHED();
     }
-
-    bool originalShouldUseFontSmoothing = wkCGContextGetShouldSmoothFonts(cgContext);
-    if (originalShouldUseFontSmoothing != newShouldUseFontSmoothing)
-        CGContextSetShouldSmoothFonts(cgContext, newShouldUseFontSmoothing);
     
+    if (!shouldUseSmoothing()) {
+        shouldSmoothFonts = false;
+        changeFontSmoothing = true;
+    }
+
+    bool originalShouldUseFontSmoothing = false;
+    if (changeFontSmoothing) {
+        originalShouldUseFontSmoothing = wkCGContextGetShouldSmoothFonts(cgContext);
+        CGContextSetShouldSmoothFonts(cgContext, shouldSmoothFonts);
+    }
+
     const FontPlatformData& platformData = font->platformData();
     NSFont* drawFont;
     if (!isPrinterFont()) {
@@ -186,7 +198,7 @@ void Font::drawGlyphs(GraphicsContext* context, const SimpleFontData* font, cons
     if (hasSimpleShadow)
         context->setShadow(shadowOffset, shadowBlur, shadowColor, fillColorSpace);
 
-    if (originalShouldUseFontSmoothing != newShouldUseFontSmoothing)
+    if (changeFontSmoothing)
         CGContextSetShouldSmoothFonts(cgContext, originalShouldUseFontSmoothing);
 }
 
diff --git a/WebCore/platform/graphics/mac/WebLayer.mm b/WebCore/platform/graphics/mac/WebLayer.mm
index 010b488..70db44e 100644
--- a/WebCore/platform/graphics/mac/WebLayer.mm
+++ b/WebCore/platform/graphics/mac/WebLayer.mm
@@ -64,7 +64,7 @@ void drawLayerContents(CGContextRef context, CALayer *layer, WebCore::GraphicsLa
         GraphicsContext graphicsContext(context);
 
         // Turn off font smoothing to improve the appearance of text rendered onto a transparent background.
-        graphicsContext.setAllowsFontSmoothing(false);
+        graphicsContext.setShouldSmoothFonts(false);
         
         // It's important to get the clip from the context, because it may be significantly
         // smaller than the layer bounds (e.g. tiled layers)

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list