Title: [163272] trunk/Source/WebCore
Revision
163272
Author
[email protected]
Date
2014-02-02 13:59:01 -0800 (Sun, 02 Feb 2014)

Log Message

Subpixel rendering: Enable subpixel positioning/sizing/hairline border painting.
https://bugs.webkit.org/show_bug.cgi?id=128009

Reviewed by Simon Fraser.

Snap and clip to device pixels when painting boxes. Enable hairline painting
for solid border.

No existing context to test this functionality yet.

* rendering/RenderBoxModelObject.cpp:
(WebCore::RenderBoxModelObject::paintFillLayerExtended):
(WebCore::RenderBoxModelObject::drawBoxSideFromPath):
* rendering/RenderObject.cpp:
(WebCore::RenderObject::drawLineForBoxSide):
* rendering/style/RenderStyle.cpp:
(WebCore::RenderStyle::getRoundedBorderFor):
(WebCore::RenderStyle::getRoundedInnerBorderFor):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (163271 => 163272)


--- trunk/Source/WebCore/ChangeLog	2014-02-02 21:56:15 UTC (rev 163271)
+++ trunk/Source/WebCore/ChangeLog	2014-02-02 21:59:01 UTC (rev 163272)
@@ -1,3 +1,24 @@
+2014-02-02  Zalan Bujtas  <[email protected]>
+
+        Subpixel rendering: Enable subpixel positioning/sizing/hairline border painting.
+        https://bugs.webkit.org/show_bug.cgi?id=128009
+
+        Reviewed by Simon Fraser.
+
+        Snap and clip to device pixels when painting boxes. Enable hairline painting
+        for solid border.
+
+        No existing context to test this functionality yet.
+
+        * rendering/RenderBoxModelObject.cpp:
+        (WebCore::RenderBoxModelObject::paintFillLayerExtended):
+        (WebCore::RenderBoxModelObject::drawBoxSideFromPath):
+        * rendering/RenderObject.cpp:
+        (WebCore::RenderObject::drawLineForBoxSide):
+        * rendering/style/RenderStyle.cpp:
+        (WebCore::RenderStyle::getRoundedBorderFor):
+        (WebCore::RenderStyle::getRoundedInnerBorderFor):
+
 2014-02-02  Sam Weinig  <[email protected]>
 
         Add some missing override keywords

Modified: trunk/Source/WebCore/rendering/RenderBoxModelObject.cpp (163271 => 163272)


--- trunk/Source/WebCore/rendering/RenderBoxModelObject.cpp	2014-02-02 21:56:15 UTC (rev 163271)
+++ trunk/Source/WebCore/rendering/RenderBoxModelObject.cpp	2014-02-02 21:59:01 UTC (rev 163272)
@@ -655,7 +655,7 @@
                 context->restore();
             }
         } else
-            context->fillRect(pixelSnappedIntRect(rect), bgColor, style().colorSpace());
+            context->fillRect(pixelSnappedForPainting(rect, context->pixelSnappingFactor()), bgColor, style().colorSpace());
 
         return;
     }
@@ -2116,7 +2116,7 @@
 
     graphicsContext->setStrokeStyle(NoStroke);
     graphicsContext->setFillColor(color, style->colorSpace());
-    graphicsContext->drawRect(pixelSnappedIntRect(borderRect));
+    graphicsContext->drawRect(pixelSnappedForPainting(borderRect, graphicsContext->pixelSnappingFactor()));
 }
 
 static void findInnerVertex(const FloatPoint& outerCorner, const FloatPoint& innerCorner, const FloatPoint& centerPoint, FloatPoint& result)

Modified: trunk/Source/WebCore/rendering/RenderObject.cpp (163271 => 163272)


--- trunk/Source/WebCore/rendering/RenderObject.cpp	2014-02-02 21:56:15 UTC (rev 163271)
+++ trunk/Source/WebCore/rendering/RenderObject.cpp	2014-02-02 21:59:01 UTC (rev 163272)
@@ -749,15 +749,23 @@
         length = y2 - y1;
     }
 
+    if (borderStyle == DOUBLE && thickness < 3)
+        borderStyle = SOLID;
+
+    float pixelSnappingFactor = graphicsContext->pixelSnappingFactor();
     // FIXME: We really would like this check to be an ASSERT as we don't want to draw empty borders. However
     // nothing guarantees that the following recursive calls to drawLineForBoxSide will have non-null dimensions.
-    // FIXME: flooring is a temporary solution until the device pixel snapping is added here.
-    if (!floor(thickness) || !floor(length))
+    // FIXME: flooring is a temporary solution until the device pixel snapping is added here for all border types.
+    if (borderStyle == SOLID) {
+        thickness = roundToDevicePixel(thickness, pixelSnappingFactor);
+        length = roundToDevicePixel(length, pixelSnappingFactor);
+    } else {
+        thickness = floorf(thickness);
+        length = floorf(length);
+    }
+    if (!thickness || !length)
         return;
 
-    if (borderStyle == DOUBLE && thickness < 3)
-        borderStyle = SOLID;
-
     const RenderStyle& style = this->style();
     switch (borderStyle) {
         case BNONE:
@@ -925,7 +933,7 @@
                 // this matters for rects in transformed contexts.
                 bool wasAntialiased = graphicsContext->shouldAntialias();
                 graphicsContext->setShouldAntialias(antialias);
-                graphicsContext->drawRect(IntRect(x1, y1, x2 - x1, y2 - y1));
+                graphicsContext->drawRect(pixelSnappedForPainting(x1, y1, x2 - x1, y2 - y1, pixelSnappingFactor));
                 graphicsContext->setShouldAntialias(wasAntialiased);
                 graphicsContext->setStrokeStyle(oldStrokeStyle);
                 return;

Modified: trunk/Source/WebCore/rendering/style/RenderStyle.cpp (163271 => 163272)


--- trunk/Source/WebCore/rendering/style/RenderStyle.cpp	2014-02-02 21:56:15 UTC (rev 163271)
+++ trunk/Source/WebCore/rendering/style/RenderStyle.cpp	2014-02-02 21:59:01 UTC (rev 163272)
@@ -1132,11 +1132,10 @@
 
 RoundedRect RenderStyle::getRoundedBorderFor(const LayoutRect& borderRect, RenderView* renderView, bool includeLogicalLeftEdge, bool includeLogicalRightEdge) const
 {
-    IntRect snappedBorderRect(pixelSnappedIntRect(borderRect));
-    RoundedRect roundedRect(snappedBorderRect);
+    RoundedRect roundedRect(borderRect);
     if (hasBorderRadius()) {
-        RoundedRect::Radii radii = calcRadiiFor(surround->border, snappedBorderRect.size(), renderView);
-        radii.scale(calcConstraintScaleFor(snappedBorderRect, radii));
+        RoundedRect::Radii radii = calcRadiiFor(surround->border, borderRect.size(), renderView);
+        radii.scale(calcConstraintScaleFor(borderRect, radii));
         roundedRect.includeLogicalEdges(radii, isHorizontalWritingMode(), includeLogicalLeftEdge, includeLogicalRightEdge);
     }
     return roundedRect;
@@ -1162,7 +1161,7 @@
                borderRect.width() - leftWidth - rightWidth, 
                borderRect.height() - topWidth - bottomWidth);
 
-    RoundedRect roundedRect(pixelSnappedIntRect(innerRect));
+    RoundedRect roundedRect(innerRect);
 
     if (hasBorderRadius()) {
         RoundedRect::Radii radii = getRoundedBorderFor(borderRect).radii();
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to