Commit 92749a8e authored by chang.shu@nokia.com's avatar chang.shu@nokia.com

2010-05-19 Andreas Kling <andreas.kling@nokia.com>

        Reviewed by Simon Hausmann.

        [Qt] REGRESSION: CoolClock isn't rendered properly

        https://bugs.webkit.org/show_bug.cgi?id=38526

        CanvasRenderingContext2D's arc() should connect to the previous point
        with a straight line (HTML5 spec 4.8.11.1.8), but if the path is empty
        to begin with, we don't want a line back to (0,0)
        This also fixes the rendering artifact discussed in bug 36226.

        Spec link:
        http://www.whatwg.org/specs/web-apps/current-work/#dom-context-2d-arc

        Test: fast/canvas/canvas-arc-connecting-line.html

        * platform/graphics/qt/PathQt.cpp:
        (WebCore::Path::addArc):

2010-05-19  Andreas Kling  <andreas.kling@nokia.com>

        Reviewed by Simon Hausmann.

        Add test to verify that CanvasRenderingContext2D's arc() connects arcs
        by a straight line (unless it's the first element in the path.)
        https://bugs.webkit.org/show_bug.cgi?id=38526

        * fast/canvas/canvas-arc-connecting-line-expected.txt: Added.
        * fast/canvas/canvas-arc-connecting-line.html: Added.
        * fast/canvas/script-tests/canvas-arc-connecting-line.js: Added.
        (deg2rad):



git-svn-id: http://svn.webkit.org/repository/webkit/trunk@59767 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent a3e99255
2010-05-19 Andreas Kling <andreas.kling@nokia.com>
Reviewed by Simon Hausmann.
Add test to verify that CanvasRenderingContext2D's arc() connects arcs
by a straight line (unless it's the first element in the path.)
https://bugs.webkit.org/show_bug.cgi?id=38526
* fast/canvas/canvas-arc-connecting-line-expected.txt: Added.
* fast/canvas/canvas-arc-connecting-line.html: Added.
* fast/canvas/script-tests/canvas-arc-connecting-line.js: Added.
(deg2rad):
2010-05-19 Peter Varga <pvarga@inf.u-szeged.hu>
Reviewed by Darin Adler.
Test that canvas arc()s are connected by a straight line. There should be two C-shapes with a line from the bottom of the left one to the top of the right one.
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
PASS imgdata[0] is 0
PASS imgdata[1] is 255
PASS imgdata[2] is 0
PASS imgdata[0] is 0
PASS imgdata[1] is 255
PASS imgdata[2] is 0
PASS imgdata[0] is 0
PASS imgdata[1] is 0
PASS imgdata[2] is 0
PASS successfullyParsed is true
TEST COMPLETE
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
<html>
<head>
<link rel="stylesheet" href="../js/resources/js-test-style.css">
<script src="../js/resources/js-test-pre.js"></script>
</head>
<body>
<p id="description"></p>
<div id="console"></div>
<script src="script-tests/canvas-arc-connecting-line.js"></script>
<script src="../js/resources/js-test-post.js"></script>
</body>
</html>
description("Test that canvas arc()s are connected by a straight line. There should be two C-shapes with a line from the bottom of the left one to the top of the right one.");
var canvas = document.createElement('canvas');
document.body.appendChild(canvas)
canvas.setAttribute('width', '300');
canvas.setAttribute('height', '300');
var ctx = canvas.getContext('2d');
function deg2rad(x) {
return x * 3.141592653589 / 180;
}
ctx.fillStyle = '#0f0';
ctx.fillRect(0, 0, canvas.width, canvas.height);
ctx.lineJoin = 'bevel';
ctx.lineWidth = 12;
ctx.beginPath();
ctx.arc(200, 50, 40, deg2rad(90), deg2rad(-90), false);
ctx.arc(100, 50, 40, deg2rad(90), deg2rad(-90), false);
ctx.stroke();
var imageData = ctx.getImageData(0, 0, 1, 1);
var imgdata = imageData.data;
shouldBe("imgdata[0]", "0");
shouldBe("imgdata[1]", "255");
shouldBe("imgdata[2]", "0");
imageData = ctx.getImageData(125, 30, 1, 1);
imgdata = imageData.data;
shouldBe("imgdata[0]", "0");
shouldBe("imgdata[1]", "255");
shouldBe("imgdata[2]", "0");
imageData = ctx.getImageData(125, 70, 1, 1);
imgdata = imageData.data;
shouldBe("imgdata[0]", "0");
shouldBe("imgdata[1]", "0");
shouldBe("imgdata[2]", "0");
var successfullyParsed = true;
2010-05-19 Andreas Kling <andreas.kling@nokia.com>
Reviewed by Simon Hausmann.
[Qt] REGRESSION: CoolClock isn't rendered properly
https://bugs.webkit.org/show_bug.cgi?id=38526
CanvasRenderingContext2D's arc() should connect to the previous point
with a straight line (HTML5 spec 4.8.11.1.8), but if the path is empty
to begin with, we don't want a line back to (0,0)
This also fixes the rendering artifact discussed in bug 36226.
Spec link:
http://www.whatwg.org/specs/web-apps/current-work/#dom-context-2d-arc
Test: fast/canvas/canvas-arc-connecting-line.html
* platform/graphics/qt/PathQt.cpp:
(WebCore::Path::addArc):
2010-05-19 Alexander Pavlov <apavlov@chromium.org>
Reviewed by Jeremy Orlow.
......@@ -298,9 +298,10 @@ void Path::addArc(const FloatPoint& p, float r, float sar, float ear, bool antic
span += ea - sa;
}
// connect to the previous point by a straight line
m_path.lineTo(QPointF(xc + radius * cos(sar),
yc - radius * sin(sar)));
// If the path is empty, move to where the arc will start to avoid painting a line from (0,0)
// NOTE: QPainterPath::isEmpty() won't work here since it ignores a lone MoveToElement
if (!m_path.elementCount())
m_path.arcMoveTo(xs, ys, width, height, sa);
m_path.arcTo(xs, ys, width, height, sa, span);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment