<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[165065] trunk/Source/WebCore</title>
</head>
<body>
<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; }
#msg dl a { font-weight: bold}
#msg dl a:link { color:#fc3; }
#msg dl a:active { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/165065">165065</a></dd>
<dt>Author</dt> <dd>zalan@apple.com</dd>
<dt>Date</dt> <dd>2014-03-04 11:53:26 -0800 (Tue, 04 Mar 2014)</dd>
</dl>
<h3>Log Message</h3>
<pre>Subpixel rendering: Make border-radius painting device pixel aware.
https://bugs.webkit.org/show_bug.cgi?id=129558
Reviewed by Simon Fraser.
Snap rounded rects to device pixels right before passing them to GraphicsContext.
* rendering/RenderBoxModelObject.cpp:
(WebCore::RenderBoxModelObject::clipRoundedInnerRect):
(WebCore::RenderBoxModelObject::paintFillLayerExtended):
(WebCore::RenderBoxModelObject::paintBorder):
* rendering/RenderBoxModelObject.h:
* rendering/RenderReplaced.cpp:
(WebCore::RenderReplaced::paint):
* rendering/RenderWidget.cpp:
(WebCore::RenderWidget::paint):</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCorerenderingRenderBoxModelObjectcpp">trunk/Source/WebCore/rendering/RenderBoxModelObject.cpp</a></li>
<li><a href="#trunkSourceWebCorerenderingRenderBoxModelObjecth">trunk/Source/WebCore/rendering/RenderBoxModelObject.h</a></li>
<li><a href="#trunkSourceWebCorerenderingRenderReplacedcpp">trunk/Source/WebCore/rendering/RenderReplaced.cpp</a></li>
<li><a href="#trunkSourceWebCorerenderingRenderWidgetcpp">trunk/Source/WebCore/rendering/RenderWidget.cpp</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (165064 => 165065)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2014-03-04 19:43:49 UTC (rev 165064)
+++ trunk/Source/WebCore/ChangeLog        2014-03-04 19:53:26 UTC (rev 165065)
</span><span class="lines">@@ -1,3 +1,22 @@
</span><ins>+2014-03-04 Zalan Bujtas <zalan@apple.com>
+
+ Subpixel rendering: Make border-radius painting device pixel aware.
+ https://bugs.webkit.org/show_bug.cgi?id=129558
+
+ Reviewed by Simon Fraser.
+
+ Snap rounded rects to device pixels right before passing them to GraphicsContext.
+
+ * rendering/RenderBoxModelObject.cpp:
+ (WebCore::RenderBoxModelObject::clipRoundedInnerRect):
+ (WebCore::RenderBoxModelObject::paintFillLayerExtended):
+ (WebCore::RenderBoxModelObject::paintBorder):
+ * rendering/RenderBoxModelObject.h:
+ * rendering/RenderReplaced.cpp:
+ (WebCore::RenderReplaced::paint):
+ * rendering/RenderWidget.cpp:
+ (WebCore::RenderWidget::paint):
+
</ins><span class="cx"> 2014-03-04 Simon Fraser <simon.fraser@apple.com>
</span><span class="cx">
</span><span class="cx"> Crashes and assertions running iOS compositing tests
</span></span></pre></div>
<a id="trunkSourceWebCorerenderingRenderBoxModelObjectcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/rendering/RenderBoxModelObject.cpp (165064 => 165065)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/rendering/RenderBoxModelObject.cpp        2014-03-04 19:43:49 UTC (rev 165064)
+++ trunk/Source/WebCore/rendering/RenderBoxModelObject.cpp        2014-03-04 19:53:26 UTC (rev 165065)
</span><span class="lines">@@ -498,10 +498,10 @@
</span><span class="cx"> return border;
</span><span class="cx"> }
</span><span class="cx">
</span><del>-void RenderBoxModelObject::clipRoundedInnerRect(GraphicsContext * context, const LayoutRect& rect, const RoundedRect& clipRect)
</del><ins>+void RenderBoxModelObject::clipRoundedInnerRect(GraphicsContext * context, const FloatRect& rect, const FloatRoundedRect& clipRect)
</ins><span class="cx"> {
</span><span class="cx"> if (clipRect.isRenderable())
</span><del>- context->clipRoundedRect(FloatRoundedRect(clipRect));
</del><ins>+ context->clipRoundedRect(clipRect);
</ins><span class="cx"> else {
</span><span class="cx"> // We create a rounded rect for each of the corners and clip it, while making sure we clip opposing corners together.
</span><span class="cx"> if (!clipRect.radii().topLeft().isEmpty() || !clipRect.radii().bottomRight().isEmpty()) {
</span><span class="lines">@@ -640,7 +640,9 @@
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> bool colorVisible = bgColor.isValid() && bgColor.alpha();
</span><del>-
</del><ins>+ float deviceScaleFactor = document().deviceScaleFactor();
+ FloatRect pixelSnappedRect = pixelSnappedForPainting(rect, deviceScaleFactor);
+
</ins><span class="cx"> // Fast path for drawing simple color backgrounds.
</span><span class="cx"> if (!isRoot && !clippedWithLocalScrolling && !shouldPaintBackgroundImage && isBorderFill && !bgLayer->next()) {
</span><span class="cx"> if (!colorVisible)
</span><span class="lines">@@ -652,17 +654,18 @@
</span><span class="cx"> applyBoxShadowForBackground(context, &style());
</span><span class="cx">
</span><span class="cx"> if (hasRoundedBorder && bleedAvoidance != BackgroundBleedUseTransparencyLayer) {
</span><del>- RoundedRect border = backgroundRoundedRectAdjustedForBleedAvoidance(*context, rect, bleedAvoidance, box, boxSize, includeLeftEdge, includeRightEdge);
- if (border.isRenderable())
- context->fillRoundedRect(FloatRoundedRect(border), bgColor, style().colorSpace());
</del><ins>+ FloatRoundedRect pixelSnappedBorder = backgroundRoundedRectAdjustedForBleedAvoidance(*context, rect, bleedAvoidance, box, boxSize,
+ includeLeftEdge, includeRightEdge).pixelSnappedRoundedRectForPainting(deviceScaleFactor);
+ if (pixelSnappedBorder.isRenderable())
+ context->fillRoundedRect(pixelSnappedBorder, bgColor, style().colorSpace());
</ins><span class="cx"> else {
</span><span class="cx"> context->save();
</span><del>- clipRoundedInnerRect(context, rect, border);
- context->fillRect(border.rect(), bgColor, style().colorSpace());
</del><ins>+ clipRoundedInnerRect(context, pixelSnappedRect, pixelSnappedBorder);
+ context->fillRect(pixelSnappedBorder.rect(), bgColor, style().colorSpace());
</ins><span class="cx"> context->restore();
</span><span class="cx"> }
</span><span class="cx"> } else
</span><del>- context->fillRect(pixelSnappedForPainting(rect, document().deviceScaleFactor()), bgColor, style().colorSpace());
</del><ins>+ context->fillRect(pixelSnappedRect, bgColor, style().colorSpace());
</ins><span class="cx">
</span><span class="cx"> return;
</span><span class="cx"> }
</span><span class="lines">@@ -680,7 +683,7 @@
</span><span class="cx"> } else if (bgLayer->clip() == PaddingFillBox)
</span><span class="cx"> border = style().getRoundedInnerBorderFor(border.rect(), includeLeftEdge, includeRightEdge);
</span><span class="cx">
</span><del>- clipRoundedInnerRect(context, rect, border);
</del><ins>+ clipRoundedInnerRect(context, pixelSnappedRect, border.pixelSnappedRoundedRectForPainting(deviceScaleFactor));
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> LayoutUnit bLeft = includeLeftEdge ? borderLeft() : LayoutUnit::fromPixel(0);
</span><span class="lines">@@ -1872,6 +1875,7 @@
</span><span class="cx"> if (haveAllSolidEdges && outerBorder.isRounded() && allCornersClippedOut(outerBorder, info.rect))
</span><span class="cx"> outerBorder.setRadii(RoundedRect::Radii());
</span><span class="cx">
</span><ins>+ float deviceScaleFactor = document().deviceScaleFactor();
</ins><span class="cx"> // isRenderable() check avoids issue described in https://bugs.webkit.org/show_bug.cgi?id=38787
</span><span class="cx"> if ((haveAllSolidEdges || haveAllDoubleEdges) && allEdgesShareColor && innerBorder.isRenderable()) {
</span><span class="cx"> // Fast path for drawing all solid edges and all unrounded double edges
</span><span class="lines">@@ -1879,10 +1883,11 @@
</span><span class="cx"> && (haveAllSolidEdges || (!outerBorder.isRounded() && !innerBorder.isRounded()))) {
</span><span class="cx"> Path path;
</span><span class="cx">
</span><del>- if (outerBorder.isRounded() && bleedAvoidance != BackgroundBleedUseTransparencyLayer)
- path.addRoundedRect(outerBorder);
</del><ins>+ FloatRoundedRect pixelSnappedRoundedRect = outerBorder.pixelSnappedRoundedRectForPainting(deviceScaleFactor);
+ if (pixelSnappedRoundedRect.isRounded() && bleedAvoidance != BackgroundBleedUseTransparencyLayer)
+ path.addRoundedRect(pixelSnappedRoundedRect);
</ins><span class="cx"> else
</span><del>- path.addRect(outerBorder.rect());
</del><ins>+ path.addRect(pixelSnappedRoundedRect.rect());
</ins><span class="cx">
</span><span class="cx"> if (haveAllDoubleEdges) {
</span><span class="cx"> LayoutRect innerThirdRect = outerBorder.rect();
</span><span class="lines">@@ -1907,26 +1912,27 @@
</span><span class="cx"> }
</span><span class="cx"> }
</span><span class="cx">
</span><del>- RoundedRect outerThird = outerBorder;
- RoundedRect innerThird = innerBorder;
- innerThird.setRect(innerThirdRect);
- outerThird.setRect(outerThirdRect);
</del><ins>+ FloatRoundedRect pixelSnappedOuterThird = outerBorder.pixelSnappedRoundedRectForPainting(deviceScaleFactor);
+ pixelSnappedOuterThird.setRect(pixelSnappedForPainting(outerThirdRect, deviceScaleFactor));
</ins><span class="cx">
</span><del>- if (outerThird.isRounded() && bleedAvoidance != BackgroundBleedUseTransparencyLayer)
- path.addRoundedRect(outerThird);
</del><ins>+ if (pixelSnappedOuterThird.isRounded() && bleedAvoidance != BackgroundBleedUseTransparencyLayer)
+ path.addRoundedRect(pixelSnappedOuterThird);
</ins><span class="cx"> else
</span><del>- path.addRect(outerThird.rect());
</del><ins>+ path.addRect(pixelSnappedOuterThird.rect());
</ins><span class="cx">
</span><del>- if (innerThird.isRounded() && bleedAvoidance != BackgroundBleedUseTransparencyLayer)
- path.addRoundedRect(innerThird);
</del><ins>+ FloatRoundedRect pixelSnappedInnerThird = innerBorder.pixelSnappedRoundedRectForPainting(deviceScaleFactor);
+ pixelSnappedInnerThird.setRect(pixelSnappedForPainting(innerThirdRect, deviceScaleFactor));
+ if (pixelSnappedInnerThird.isRounded() && bleedAvoidance != BackgroundBleedUseTransparencyLayer)
+ path.addRoundedRect(pixelSnappedInnerThird);
</ins><span class="cx"> else
</span><del>- path.addRect(innerThird.rect());
</del><ins>+ path.addRect(pixelSnappedInnerThird.rect());
</ins><span class="cx"> }
</span><span class="cx">
</span><del>- if (innerBorder.isRounded())
- path.addRoundedRect(innerBorder);
</del><ins>+ FloatRoundedRect snappedInnerBorder = innerBorder.pixelSnappedRoundedRectForPainting(deviceScaleFactor);
+ if (snappedInnerBorder.isRounded())
+ path.addRoundedRect(snappedInnerBorder);
</ins><span class="cx"> else
</span><del>- path.addRect(innerBorder.rect());
</del><ins>+ path.addRect(snappedInnerBorder.rect());
</ins><span class="cx">
</span><span class="cx"> graphicsContext->setFillRule(RULE_EVENODD);
</span><span class="cx"> graphicsContext->setFillColor(edges[firstVisibleEdge].color, style->colorSpace());
</span><span class="lines">@@ -1961,7 +1967,7 @@
</span><span class="cx"> // isRenderable() check avoids issue described in https://bugs.webkit.org/show_bug.cgi?id=38787
</span><span class="cx"> // The inside will be clipped out later (in clipBorderSideForComplexInnerPath)
</span><span class="cx"> if (innerBorder.isRenderable())
</span><del>- graphicsContext->clipOutRoundedRect(FloatRoundedRect(innerBorder));
</del><ins>+ graphicsContext->clipOutRoundedRect(innerBorder.pixelSnappedRoundedRectForPainting(deviceScaleFactor));
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> // If only one edge visible antialiasing doesn't create seams
</span></span></pre></div>
<a id="trunkSourceWebCorerenderingRenderBoxModelObjecth"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/rendering/RenderBoxModelObject.h (165064 => 165065)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/rendering/RenderBoxModelObject.h        2014-03-04 19:43:49 UTC (rev 165064)
+++ trunk/Source/WebCore/rendering/RenderBoxModelObject.h        2014-03-04 19:53:26 UTC (rev 165065)
</span><span class="lines">@@ -279,7 +279,7 @@
</span><span class="cx">
</span><span class="cx"> static bool shouldAntialiasLines(GraphicsContext*);
</span><span class="cx">
</span><del>- static void clipRoundedInnerRect(GraphicsContext*, const LayoutRect&, const RoundedRect& clipRect);
</del><ins>+ static void clipRoundedInnerRect(GraphicsContext*, const FloatRect&, const FloatRoundedRect& clipRect);
</ins><span class="cx">
</span><span class="cx"> bool hasAutoHeightOrContainingBlockWithAutoHeight() const;
</span><span class="cx">
</span></span></pre></div>
<a id="trunkSourceWebCorerenderingRenderReplacedcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/rendering/RenderReplaced.cpp (165064 => 165065)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/rendering/RenderReplaced.cpp        2014-03-04 19:43:49 UTC (rev 165064)
+++ trunk/Source/WebCore/rendering/RenderReplaced.cpp        2014-03-04 19:53:26 UTC (rev 165065)
</span><span class="lines">@@ -24,6 +24,7 @@
</span><span class="cx"> #include "config.h"
</span><span class="cx"> #include "RenderReplaced.h"
</span><span class="cx">
</span><ins>+#include "FloatRoundedRect.h"
</ins><span class="cx"> #include "Frame.h"
</span><span class="cx"> #include "GraphicsContext.h"
</span><span class="cx"> #include "InlineElementBox.h"
</span><span class="lines">@@ -169,8 +170,8 @@
</span><span class="cx"> else {
</span><span class="cx"> // Push a clip if we have a border radius, since we want to round the foreground content that gets painted.
</span><span class="cx"> paintInfo.context->save();
</span><del>- RoundedRect roundedInnerRect = style().getRoundedInnerBorderFor(paintRect,
- paddingTop() + borderTop(), paddingBottom() + borderBottom(), paddingLeft() + borderLeft(), paddingRight() + borderRight(), true, true);
</del><ins>+ FloatRoundedRect roundedInnerRect = FloatRoundedRect(style().getRoundedInnerBorderFor(paintRect,
+ paddingTop() + borderTop(), paddingBottom() + borderBottom(), paddingLeft() + borderLeft(), paddingRight() + borderRight(), true, true));
</ins><span class="cx"> clipRoundedInnerRect(paintInfo.context, paintRect, roundedInnerRect);
</span><span class="cx"> }
</span><span class="cx"> }
</span></span></pre></div>
<a id="trunkSourceWebCorerenderingRenderWidgetcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/rendering/RenderWidget.cpp (165064 => 165065)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/rendering/RenderWidget.cpp        2014-03-04 19:43:49 UTC (rev 165064)
+++ trunk/Source/WebCore/rendering/RenderWidget.cpp        2014-03-04 19:53:26 UTC (rev 165065)
</span><span class="lines">@@ -24,6 +24,7 @@
</span><span class="cx"> #include "RenderWidget.h"
</span><span class="cx">
</span><span class="cx"> #include "AXObjectCache.h"
</span><ins>+#include "FloatRoundedRect.h"
</ins><span class="cx"> #include "Frame.h"
</span><span class="cx"> #include "HTMLFrameOwnerElement.h"
</span><span class="cx"> #include "HitTestResult.h"
</span><span class="lines">@@ -276,8 +277,8 @@
</span><span class="cx">
</span><span class="cx"> // Push a clip if we have a border radius, since we want to round the foreground content that gets painted.
</span><span class="cx"> paintInfo.context->save();
</span><del>- RoundedRect roundedInnerRect = style().getRoundedInnerBorderFor(borderRect,
- paddingTop() + borderTop(), paddingBottom() + borderBottom(), paddingLeft() + borderLeft(), paddingRight() + borderRight(), true, true);
</del><ins>+ FloatRoundedRect roundedInnerRect = FloatRoundedRect(style().getRoundedInnerBorderFor(borderRect,
+ paddingTop() + borderTop(), paddingBottom() + borderBottom(), paddingLeft() + borderLeft(), paddingRight() + borderRight(), true, true));
</ins><span class="cx"> clipRoundedInnerRect(paintInfo.context, borderRect, roundedInnerRect);
</span><span class="cx"> }
</span><span class="cx">
</span></span></pre>
</div>
</div>
</body>
</html>