Diff
Modified: trunk/LayoutTests/ChangeLog (117634 => 117635)
--- trunk/LayoutTests/ChangeLog 2012-05-18 21:45:10 UTC (rev 117634)
+++ trunk/LayoutTests/ChangeLog 2012-05-18 21:46:18 UTC (rev 117635)
@@ -1,3 +1,14 @@
+2012-05-18 Keyar Hood <[email protected]>
+
+ Support imageSmoothingEnabled
+ https://bugs.webkit.org/show_bug.cgi?id=82804
+
+ Reviewed by Stephen White.
+
+ * fast/canvas/canvas-imageSmoothingEnabled-expected.txt: Added.
+ * fast/canvas/canvas-imageSmoothingEnabled.html: Added.
+ * fast/canvas/script-tests/canvas-imageSmoothingEnabled.js: Added.
+
2012-05-18 Terry Anderson <[email protected]>
Percentage height replaced elements sometimes cause overflow of table contents
Added: trunk/LayoutTests/fast/canvas/canvas-imageSmoothingEnabled-expected.txt (0 => 117635)
--- trunk/LayoutTests/fast/canvas/canvas-imageSmoothingEnabled-expected.txt (rev 0)
+++ trunk/LayoutTests/fast/canvas/canvas-imageSmoothingEnabled-expected.txt 2012-05-18 21:46:18 UTC (rev 117635)
@@ -0,0 +1,26 @@
+Tests for the imageSmoothingEnabled attribute.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+Test that the default value is true.
+PASS ctx.webkitImageSmoothingEnabled is true
+Test that false is returned after a the attribute is set to false.
+PASS ctx.webkitImageSmoothingEnabled is false
+New canvas element created.
+Test that the image is smoothed by default. We check by making sure the pixel just to the left of the middle line is not completely black.
+PASS left_of_center_pixel.data[0] !== 0 is true
+PASS left_of_center_pixel.data[1] !== 0 is true
+PASS left_of_center_pixel.data[2] !== 0 is true
+Test that nearest neighbour is used when imageSmoothingEnabled is set to false. We check this by making sure the pixel just to the left of the middle line is completely black.
+PASS left_of_center_pixel.data[0] is 0
+PASS left_of_center_pixel.data[1] is 0
+PASS left_of_center_pixel.data[2] is 0
+Test that the image is smoothed when imageSmoothingEnabled is set to true.
+PASS left_of_center_pixel.data[0] !== 0 is true
+PASS left_of_center_pixel.data[1] !== 0 is true
+PASS left_of_center_pixel.data[2] !== 0 is true
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
Added: trunk/LayoutTests/fast/canvas/canvas-imageSmoothingEnabled.html (0 => 117635)
--- trunk/LayoutTests/fast/canvas/canvas-imageSmoothingEnabled.html (rev 0)
+++ trunk/LayoutTests/fast/canvas/canvas-imageSmoothingEnabled.html 2012-05-18 21:46:18 UTC (rev 117635)
@@ -0,0 +1,10 @@
+<!DOCTYPE html>
+<html>
+<head>
+ <script src=""
+</head>
+<body>
+ <script src=""
+ <script src=""
+</body>
+</html>
Added: trunk/LayoutTests/fast/canvas/script-tests/canvas-imageSmoothingEnabled.js (0 => 117635)
--- trunk/LayoutTests/fast/canvas/script-tests/canvas-imageSmoothingEnabled.js (rev 0)
+++ trunk/LayoutTests/fast/canvas/script-tests/canvas-imageSmoothingEnabled.js 2012-05-18 21:46:18 UTC (rev 117635)
@@ -0,0 +1,61 @@
+description("Tests for the imageSmoothingEnabled attribute.");
+var ctx = document.createElement('canvas').getContext('2d');
+
+debug("Test that the default value is true.");
+shouldBe("ctx.webkitImageSmoothingEnabled", "true");
+
+debug("Test that false is returned after a the attribute is set to false.");
+ctx.webkitImageSmoothingEnabled = false;
+shouldBe("ctx.webkitImageSmoothingEnabled", "false");
+
+var image = document.createElement('canvas');
+image.width = 2;
+image.height = 1;
+
+// We use this to colour the individual pixels
+var dotter = ctx.createImageData(1, 1);
+
+// Colour the left pixel black.
+dotter.data[0] = 0;
+dotter.data[1] = 0;
+dotter.data[2] = 0;
+dotter.data[3] = 255;
+image.getContext('2d').putImageData(dotter, 0, 0);
+
+// Colour the right pixel white.
+dotter.data[0] = 255;
+dotter.data[1] = 255;
+dotter.data[2] = 255;
+dotter.data[3] = 255;
+image.getContext('2d').putImageData(dotter, 1, 0);
+
+
+debug("New canvas element created.");
+var canvas = document.createElement('canvas');
+canvas.width = 4;
+canvas.height = 1;
+ctx = canvas.getContext('2d');
+ctx.drawImage(image, 0, 0, canvas.width, canvas.height);
+left_of_center_pixel = ctx.getImageData(1, 0, 1, 1);
+
+debug("Test that the image is smoothed by default. We check by making sure the pixel just to the left of the middle line is not completely black.");
+shouldBe("left_of_center_pixel.data[0] !== 0", "true");
+shouldBe("left_of_center_pixel.data[1] !== 0", "true");
+shouldBe("left_of_center_pixel.data[2] !== 0", "true");
+
+ctx.webkitImageSmoothingEnabled = false;
+ctx.drawImage(image, 0, 0, canvas.width, canvas.height);
+left_of_center_pixel = ctx.getImageData(1, 0, 1, 1);
+debug("Test that nearest neighbour is used when imageSmoothingEnabled is set to false. We check this by making sure the pixel just to the left of the middle line is completely black.");
+shouldBe("left_of_center_pixel.data[0]", "0");
+shouldBe("left_of_center_pixel.data[1]", "0");
+shouldBe("left_of_center_pixel.data[2]", "0");
+
+ctx.webkitImageSmoothingEnabled = true;
+ctx.drawImage(image, 0, 0, canvas.width, canvas.height);
+left_of_center_pixel = ctx.getImageData(1, 0, 1, 1);
+debug("Test that the image is smoothed when imageSmoothingEnabled is set to true.");
+shouldBe("left_of_center_pixel.data[0] !== 0", "true");
+shouldBe("left_of_center_pixel.data[1] !== 0", "true");
+shouldBe("left_of_center_pixel.data[2] !== 0", "true");
+
Modified: trunk/Source/WebCore/ChangeLog (117634 => 117635)
--- trunk/Source/WebCore/ChangeLog 2012-05-18 21:45:10 UTC (rev 117634)
+++ trunk/Source/WebCore/ChangeLog 2012-05-18 21:46:18 UTC (rev 117635)
@@ -1,3 +1,27 @@
+2012-05-18 Keyar Hood <[email protected]>
+
+ Support imageSmoothingEnabled
+ https://bugs.webkit.org/show_bug.cgi?id=82804
+
+ Reviewed by Stephen White.
+
+ Test: fast/canvas/canvas-imageSmoothingEnabled.html
+
+ Added the imageSmoothingEnabled parameter to the
+ CanvasRenderingContext2D object. When it is set to false, it sets
+ InterpolationQuality to InterpolationNone. When set to true, it sets
+ the InterpolationQuality to DefaultInterpolationQuality (as that is the
+ only other value used).
+
+ * html/canvas/CanvasRenderingContext2D.cpp:
+ (WebCore::CanvasRenderingContext2D::CanvasRenderingContext2D):
+ (WebCore::CanvasRenderingContext2D::webkitImageSmoothingEnabled):
+ (WebCore):
+ (WebCore::CanvasRenderingContext2D::setWebkitImageSmoothingEnabled):
+ * html/canvas/CanvasRenderingContext2D.h:
+ (CanvasRenderingContext2D):
+ * html/canvas/CanvasRenderingContext2D.idl:
+
2012-05-18 Terry Anderson <[email protected]>
Percentage height replaced elements sometimes cause overflow of table contents
Modified: trunk/Source/WebCore/html/canvas/CanvasRenderingContext2D.cpp (117634 => 117635)
--- trunk/Source/WebCore/html/canvas/CanvasRenderingContext2D.cpp 2012-05-18 21:45:10 UTC (rev 117634)
+++ trunk/Source/WebCore/html/canvas/CanvasRenderingContext2D.cpp 2012-05-18 21:46:18 UTC (rev 117635)
@@ -120,6 +120,7 @@
#if ENABLE(DASHBOARD_SUPPORT)
, m_usesDashboardCompatibilityMode(usesDashboardCompatibilityMode)
#endif
+ , m_imageSmoothingEnabled(true)
{
#if !ENABLE(DASHBOARD_SUPPORT)
ASSERT_UNUSED(usesDashboardCompatibilityMode, !usesDashboardCompatibilityMode);
@@ -2265,4 +2266,18 @@
}
#endif
+bool CanvasRenderingContext2D::webkitImageSmoothingEnabled() const
+{
+ return m_imageSmoothingEnabled;
+}
+
+void CanvasRenderingContext2D::setWebkitImageSmoothingEnabled(bool enabled)
+{
+ if (enabled == m_imageSmoothingEnabled)
+ return;
+
+ drawingContext()->setImageInterpolationQuality(enabled ? DefaultInterpolationQuality : InterpolationNone);
+ m_imageSmoothingEnabled = enabled;
+}
+
} // namespace WebCore
Modified: trunk/Source/WebCore/html/canvas/CanvasRenderingContext2D.h (117634 => 117635)
--- trunk/Source/WebCore/html/canvas/CanvasRenderingContext2D.h 2012-05-18 21:45:10 UTC (rev 117634)
+++ trunk/Source/WebCore/html/canvas/CanvasRenderingContext2D.h 2012-05-18 21:46:18 UTC (rev 117635)
@@ -222,6 +222,9 @@
LineCap getLineCap() const { return state().m_lineCap; }
LineJoin getLineJoin() const { return state().m_lineJoin; }
+ bool webkitImageSmoothingEnabled() const;
+ void setWebkitImageSmoothingEnabled(bool);
+
private:
struct State : FontSelectorClient {
State();
@@ -326,13 +329,14 @@
virtual PlatformLayer* platformLayer() const OVERRIDE;
#endif
- Path m_path;
+ Path m_path;
Vector<State, 1> m_stateStack;
unsigned m_unrealizedSaveCount;
bool m_usesCSSCompatibilityParseMode;
#if ENABLE(DASHBOARD_SUPPORT)
bool m_usesDashboardCompatibilityMode;
#endif
+ bool m_imageSmoothingEnabled;
};
} // namespace WebCore
Modified: trunk/Source/WebCore/html/canvas/CanvasRenderingContext2D.idl (117634 => 117635)
--- trunk/Source/WebCore/html/canvas/CanvasRenderingContext2D.idl 2012-05-18 21:45:10 UTC (rev 117634)
+++ trunk/Source/WebCore/html/canvas/CanvasRenderingContext2D.idl 2012-05-18 21:46:18 UTC (rev 117635)
@@ -231,6 +231,8 @@
raises(DOMException);
readonly attribute float webkitBackingStorePixelRatio;
+
+ attribute boolean webkitImageSmoothingEnabled;
};
}