Refactor checks for antialiasing lines to share a single function
authordarin@apple.com <darin@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 23 Sep 2011 03:00:38 +0000 (03:00 +0000)
committerdarin@apple.com <darin@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 23 Sep 2011 03:00:38 +0000 (03:00 +0000)
https://bugs.webkit.org/show_bug.cgi?id=68666

Reviewed by Dan Bernstein.

* rendering/RenderBlock.cpp:
(WebCore::RenderBlock::paintColumnRules): Call shouldAntialiasLines.
* rendering/RenderBoxModelObject.cpp:
(WebCore::RenderBoxModelObject::paintBorder): Ditto.
(WebCore::RenderBoxModelObject::shouldAntialiasLines): Added.
* rendering/RenderBoxModelObject.h: Added shouldAntialiasLines function.
* rendering/RenderInline.cpp:
(WebCore::RenderInline::paintOutlineForLine): Call shouldAntialiasLines.
* rendering/RenderTableCell.cpp:
(WebCore::RenderTableCell::paintCollapsedBorder): Ditto.

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

Source/WebCore/ChangeLog
Source/WebCore/rendering/RenderBlock.cpp
Source/WebCore/rendering/RenderBoxModelObject.cpp
Source/WebCore/rendering/RenderBoxModelObject.h
Source/WebCore/rendering/RenderInline.cpp
Source/WebCore/rendering/RenderTableCell.cpp

index 87b9c43..ca5180b 100644 (file)
@@ -1,3 +1,21 @@
+2011-09-22  Darin Adler  <darin@apple.com>
+
+        Refactor checks for antialiasing lines to share a single function
+        https://bugs.webkit.org/show_bug.cgi?id=68666
+
+        Reviewed by Dan Bernstein.
+
+        * rendering/RenderBlock.cpp:
+        (WebCore::RenderBlock::paintColumnRules): Call shouldAntialiasLines.
+        * rendering/RenderBoxModelObject.cpp:
+        (WebCore::RenderBoxModelObject::paintBorder): Ditto.
+        (WebCore::RenderBoxModelObject::shouldAntialiasLines): Added.
+        * rendering/RenderBoxModelObject.h: Added shouldAntialiasLines function.
+        * rendering/RenderInline.cpp:
+        (WebCore::RenderInline::paintOutlineForLine): Call shouldAntialiasLines.
+        * rendering/RenderTableCell.cpp:
+        (WebCore::RenderTableCell::paintCollapsedBorder): Ditto.
+
 2011-09-22  Antoine Labour  <piman@chromium.org>
 
         Remove unused members from LayerChromium.
index 004e5a0..a52d193 100644 (file)
@@ -2342,8 +2342,7 @@ void RenderBlock::paintColumnRules(PaintInfo& paintInfo, const LayoutPoint& pain
     LayoutUnit ruleAdd = logicalLeftOffsetForContent();
     LayoutUnit ruleLogicalLeft = style()->isLeftToRightDirection() ? 0 : contentLogicalWidth();
 
-    const AffineTransform& currentCTM = paintInfo.context->getCTM();
-    bool antialias = !currentCTM.isIdentityOrTranslationOrFlipped();
+    bool antialias = shouldAntialiasLines(paintInfo.context);
 
     for (unsigned i = 0; i < colCount; i++) {
         LayoutRect colRect = columnRectAt(colInfo, i);
index 60e9f9d..61739e1 100644 (file)
@@ -1537,10 +1537,6 @@ void RenderBoxModelObject::paintBorder(const PaintInfo& info, const LayoutRect&
     RoundedRect outerBorder = style->getRoundedBorderFor(rect, includeLogicalLeftEdge, includeLogicalRightEdge);
     RoundedRect innerBorder = style->getRoundedInnerBorderFor(rect, includeLogicalLeftEdge, includeLogicalRightEdge);
 
-    const AffineTransform& currentCTM = graphicsContext->getCTM();
-    // FIXME: this isn't quite correct. We may want to antialias when scaled by a non-integral value, or when the translation is non-integral.
-    bool antialias = !currentCTM.isIdentityOrTranslationOrFlipped();
-    
     bool haveAlphaColor = false;
     bool haveAllSolidEdges = true;
     bool allEdgesVisible = true;
@@ -1626,6 +1622,7 @@ void RenderBoxModelObject::paintBorder(const PaintInfo& info, const LayoutRect&
         graphicsContext->clipOutRoundedRect(innerBorder);
     }
 
+    bool antialias = shouldAntialiasLines(graphicsContext);    
     if (haveAlphaColor)
         paintTranslucentBorderSides(graphicsContext, style, outerBorder, innerBorder, edges, bleedAvoidance, includeLogicalLeftEdge, includeLogicalRightEdge, antialias);
     else
@@ -2475,4 +2472,11 @@ void RenderBoxModelObject::setContinuation(RenderBoxModelObject* continuation)
     }
 }
 
+bool RenderBoxModelObject::shouldAntialiasLines(GraphicsContext* context)
+{
+    // FIXME: We may want to not antialias when scaled by an integral value,
+    // and we may want to antialias when translated by a non-integral value.
+    return !context->getCTM().isIdentityOrTranslationOrFlipped();
+}
+
 } // namespace WebCore
index ad89ad7..fdc11c8 100644 (file)
@@ -190,6 +190,8 @@ protected:
     RenderBoxModelObject* continuation() const;
     void setContinuation(RenderBoxModelObject*);
 
+    static bool shouldAntialiasLines(GraphicsContext*);
+
 private:
     virtual bool isBoxModelObject() const { return true; }
 
index 8c78fc2..6ca9d3f 100644 (file)
@@ -1421,8 +1421,7 @@ void RenderInline::paintOutlineForLine(GraphicsContext* graphicsContext, const L
     LayoutUnit outlineWidth = styleToUse->outlineWidth();
     EBorderStyle outlineStyle = styleToUse->outlineStyle();
 
-    const AffineTransform& currentCTM = graphicsContext->getCTM();
-    bool antialias = !currentCTM.isIdentityOrTranslationOrFlipped();
+    bool antialias = shouldAntialiasLines(graphicsContext);
 
     LayoutUnit offset = style()->outlineOffset();
 
index c9c3d96..86af6ff 100644 (file)
@@ -944,8 +944,7 @@ void RenderTableCell::paintCollapsedBorder(GraphicsContext* graphicsContext, con
     borders.addBorder(leftVal, BSLeft, renderLeft, x, y, x + leftWidth, y + h, leftStyle);
     borders.addBorder(rightVal, BSRight, renderRight, x + w - rightWidth, y, x + w, y + h, rightStyle);
 
-    const AffineTransform& currentCTM = graphicsContext->getCTM();
-    bool antialias = !currentCTM.isIdentityOrTranslationOrFlipped();
+    bool antialias = shouldAntialiasLines(graphicsContext);
     
     for (CollapsedBorder* border = borders.nextBorder(); border; border = borders.nextBorder()) {
         if (border->borderValue == *table()->currentBorderStyle())