blob: a5b032f271b8b30685f4343710360f55226934f3 [file] [log] [blame]
<!DOCTYPE HTML>
<script src="../../resources/testharness.js"></script>
<script src="../../resources/testharnessreport.js"></script>
<script>
function getCanvasDataFromDrawImage(source, disableSmoothing)
{
var canvas = document.createElement("canvas");
canvas.width = 100;
canvas.height = 100;
var ctx = canvas.getContext("2d");
ctx.clearRect(0, 0, canvas.width, canvas.height);
ctx.scale(0.9, 0.9);
ctx.rotate(45 * Math.PI / 180);
if (disableSmoothing)
ctx.imageSmoothingEnabled = false;
ctx.drawImage(source, 0, 0, source.width, source.height, 0, 0, 100, 100);
var d = ctx.getImageData(0, 0, 100, 100).data;
return d;
}
test(function() {
var canvas = document.createElement('canvas');
canvas.height = 100;
canvas.width = 100;
var ctx = canvas.getContext('2d');
ctx.fillStyle = '#FF0000';
ctx.fillRect(0, 0, canvas.width, canvas.height);
var data1 = getCanvasDataFromDrawImage(canvas, false);
var data2 = getCanvasDataFromDrawImage(canvas, true);
assert_array_equals(data1, data2, "drawImage() should have the same results with imageSmoothingEnabled = true and false when scaling down.");
}, 'Test drawImage with imageSmoothingEnabled=false and scaling down the source.');
</script>