Commit 4a1481a0 authored by mihaip@chromium.org's avatar mihaip@chromium.org

2010-12-08 Mihai Parparita <mihaip@chromium.org>

        Reviewed by Darin Adler.

        fast/canvas/canvas-getImageData-negative-source.html fails on Mac
        https://bugs.webkit.org/show_bug.cgi?id=47901

        Add test for rounding behavior. Remove now-passing tests from
        test_expectations.txt.

        * fast/canvas/canvas-getImageData-rounding-expected.txt: Added.
        * fast/canvas/canvas-getImageData-rounding.html: Added.
        * platform/chromium/test_expectations.txt:
2010-12-08  Mihai Parparita  <mihaip@chromium.org>

        Reviewed by Darin Adler.

        fast/canvas/canvas-getImageData-negative-source.html fails on Mac
        https://bugs.webkit.org/show_bug.cgi?id=47901

        Test: fast/canvas/canvas-getImageData-rounding.html

        static_cast<unsigned> is generally not what we want in
        convertLogicalToDevice. It produces inconsistent results when compiling
        for 32-bit vs. 64-bit, and in any case we weren't getting correct
        rounding behavior for source rectangles (e.g. we should get a source rect
        of width 2 if the source X is 0.9 and the source width is 0.2, but we
        were getting only one of width 1).

        * html/HTMLCanvasElement.cpp:
        (WebCore::HTMLCanvasElement::convertLogicalToDevice):
        (WebCore::HTMLCanvasElement::convertToValidDeviceSize):
        * html/HTMLCanvasElement.h:

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@73744 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent c89d952a
2010-12-08 Mihai Parparita <mihaip@chromium.org>
Reviewed by Darin Adler.
fast/canvas/canvas-getImageData-negative-source.html fails on Mac
https://bugs.webkit.org/show_bug.cgi?id=47901
Add test for rounding behavior. Remove now-passing tests from
test_expectations.txt.
* fast/canvas/canvas-getImageData-rounding-expected.txt: Added.
* fast/canvas/canvas-getImageData-rounding.html: Added.
* platform/chromium/test_expectations.txt:
2010-12-10 Alejandro G. Castro <alex@igalia.com>
Unreviewed GTK test expectation update.
......
Test the handling of non-integer source coordinates in getImageData().
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
getImageData(0, 0, 20, 10)
PASS imageData.width is 20
PASS imageData.height is 10
getImageData(0.1, 0.2, 20, 10)
PASS imageData.width is 21
PASS imageData.height is 11
getImageData(0.9, 0.8, 20, 10)
PASS imageData.width is 21
PASS imageData.height is 11
getImageData(0, 0, 19.9, 9.9)
PASS imageData.width is 20
PASS imageData.height is 10
getImageData(0, 0, 19.1, 9.1)
PASS imageData.width is 20
PASS imageData.height is 10
getImageData(0.9, 0, 0.2, 10)
PASS imageData.width is 2
PASS imageData.height is 10
getImageData(-1, -1, 20, 10)
PASS imageData.width is 20
PASS imageData.height is 10
getImageData(-1.1, 0, 20, 10)
PASS imageData.width is 21
PASS imageData.height is 10
getImageData(-1.9, 0, 20, 10)
PASS imageData.width is 21
PASS imageData.height is 10
PASS successfullyParsed is true
TEST COMPLETE
<!DOCTYPE html>
<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>
description("Test the handling of non-integer source coordinates in getImageData().");
ctx = document.createElement('canvas').getContext('2d');
function dimensionsShouldBe(sx, sy, sw, sh, width, height)
{
imageData = ctx.getImageData(sx, sy, sw, sh);
debug('getImageData(' + sx + ', ' + sy + ', ' + sw + ', ' + sh + ')');
shouldBe('imageData.width', width + '');
shouldBe('imageData.height', height + '');
}
// Basic integer values
dimensionsShouldBe( 0, 0, 20, 10, 20, 10);
// Source point is not an integer
dimensionsShouldBe( .1, .2, 20, 10, 21, 11);
dimensionsShouldBe( .9, .8, 20, 10, 21, 11);
// Size is not an integer
dimensionsShouldBe( 0, 0, 19.9, 9.9, 20, 10);
dimensionsShouldBe( 0, 0, 19.1, 9.1, 20, 10);
// Width straddles a pixel boundary
dimensionsShouldBe( .9, 0, .2, 10, 2, 10);
// Basic integer negative values
dimensionsShouldBe( -1, -1, 20, 10, 20, 10);
// Non-integer negative values
dimensionsShouldBe(-1.1, 0, 20, 10, 21, 10);
dimensionsShouldBe(-1.9, 0, 20, 10, 21, 10);
successfullyParsed = true;
</script>
<script src="../js/resources/js-test-post.js"></script>
</body>
</html>
......@@ -2415,14 +2415,10 @@ BUGWK45991 MAC : canvas/philip/tests/2d.shadow.enable.blur.html = TEXT
BUGWK45991 MAC : canvas/philip/tests/2d.shadow.enable.x.html = TEXT
BUGWK45991 MAC : canvas/philip/tests/2d.shadow.enable.y.html = TEXT
BUGWK45991 MAC : canvas/philip/tests/2d.strokeRect.zero.4.html = TEXT
BUGWK45991 MAC : canvas/philip/tests/2d.imageData.get.source.outside.html = TEXT
BUGWK45991 WIN : canvas/philip/tests/2d.gradient.radial.touch2.html = TEXT
BUGWK40147 : canvas/philip/tests/toDataURL.jpeg.alpha.html = TEXT
BUG61824 : canvas/philip/tests/2d.pattern.image.string.html = TEXT
// Failures after WebKit roll 70949:71000
BUGWK45991 MAC : canvas/philip/tests/2d.imageData.get.source.negative.html = TEXT
// Flaky tests
BUG44229 WIN LINUX : fast/loader/recursive-before-unload-crash.html = PASS TEXT
......@@ -2924,8 +2920,6 @@ BUG47578 : printing/simultaneous-position-float-change.html = IMAGE+TEXT
BUG59647 WIN : svg/dom/length-list-parser.html = PASS CRASH
BUGWK47901 MAC : fast/canvas/canvas-getImageData-negative-source.html = TEXT
// We don't support layoutTestController.nodesFromRect so this test just times out
BUGWK46600 SKIP : fast/dom/nodesFromRect-links-and-text.html = TEXT
BUGWK46600 SKIP : fast/dom/nodesFromRect-inner-documents.html = TEXT
......
2010-12-08 Mihai Parparita <mihaip@chromium.org>
Reviewed by Darin Adler.
fast/canvas/canvas-getImageData-negative-source.html fails on Mac
https://bugs.webkit.org/show_bug.cgi?id=47901
Test: fast/canvas/canvas-getImageData-rounding.html
static_cast<unsigned> is generally not what we want in
convertLogicalToDevice. It produces inconsistent results when compiling
for 32-bit vs. 64-bit, and in any case we weren't getting correct
rounding behavior for source rectangles (e.g. we should get a source rect
of width 2 if the source X is 0.9 and the source width is 0.2, but we
were getting only one of width 1).
* html/HTMLCanvasElement.cpp:
(WebCore::HTMLCanvasElement::convertLogicalToDevice):
(WebCore::HTMLCanvasElement::convertToValidDeviceSize):
* html/HTMLCanvasElement.h:
2010-12-10 Hironori Bono <hbono@chromium.org>
Reviewed by Ojan Vafai.
......
......@@ -322,31 +322,33 @@ String HTMLCanvasElement::toDataURL(const String& mimeType, const double* qualit
IntRect HTMLCanvasElement::convertLogicalToDevice(const FloatRect& logicalRect) const
{
return IntRect(convertLogicalToDevice(logicalRect.location()), convertLogicalToDevice(logicalRect.size()));
float left = floorf(logicalRect.left() * m_pageScaleFactor);
float top = floorf(logicalRect.top() * m_pageScaleFactor);
float right = ceilf(logicalRect.right() * m_pageScaleFactor);
float bottom = ceilf(logicalRect.bottom() * m_pageScaleFactor);
return IntRect(IntPoint(left, top), convertToValidDeviceSize(right - left, bottom - top));
}
IntSize HTMLCanvasElement::convertLogicalToDevice(const FloatSize& logicalSize) const
{
float wf = ceilf(logicalSize.width() * m_pageScaleFactor);
float hf = ceilf(logicalSize.height() * m_pageScaleFactor);
return convertToValidDeviceSize(logicalSize.width() * m_pageScaleFactor, logicalSize.height() * m_pageScaleFactor);
}
if (!(wf >= 1 && hf >= 1 && wf * hf <= MaxCanvasArea))
IntSize HTMLCanvasElement::convertToValidDeviceSize(float width, float height) const
{
width = ceilf(width);
height = ceilf(height);
if (width < 1 || height < 1 || width * height > MaxCanvasArea)
return IntSize();
#if PLATFORM(SKIA)
if (wf > MaxSkiaDim || hf > MaxSkiaDim)
if (width > MaxSkiaDim || height > MaxSkiaDim)
return IntSize();
#endif
return IntSize(static_cast<unsigned>(wf), static_cast<unsigned>(hf));
}
IntPoint HTMLCanvasElement::convertLogicalToDevice(const FloatPoint& logicalPos) const
{
float xf = logicalPos.x() * m_pageScaleFactor;
float yf = logicalPos.y() * m_pageScaleFactor;
return IntPoint(static_cast<unsigned>(xf), static_cast<unsigned>(yf));
return IntSize(width, height);
}
const SecurityOrigin& HTMLCanvasElement::securityOrigin() const
......
......@@ -107,7 +107,7 @@ public:
IntRect convertLogicalToDevice(const FloatRect&) const;
IntSize convertLogicalToDevice(const FloatSize&) const;
IntPoint convertLogicalToDevice(const FloatPoint&) const;
IntSize convertToValidDeviceSize(float width, float height) const;
const SecurityOrigin& securityOrigin() const;
void setOriginTainted() { m_originClean = false; }
......
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