Commit 8ad8e044 authored by Reza.Zakerinasab's avatar Reza.Zakerinasab Committed by Commit Bot

Remove higher tolerance in roundtrip ConvertToBlob layout tests for Webp

TBR=fserb@chromium.org

Bug: 847527
Change-Id: I6effeada64f09fb2d0dc549a0de66a1c783915d1
Reviewed-on: https://chromium-review.googlesource.com/1175000Reviewed-by: default avatarMohammad Reza Zakerinasab <zakerinasab@chromium.org>
Commit-Queue: Mohammad Reza Zakerinasab <zakerinasab@chromium.org>
Cr-Commit-Position: refs/heads/master@{#583101}
parent d4b535ac
...@@ -13,27 +13,22 @@ var opaqueReferencePxiels, transparentReferencePixels; ...@@ -13,27 +13,22 @@ var opaqueReferencePxiels, transparentReferencePixels;
function testPixels(actualPixels, refPixels, testScenario) function testPixels(actualPixels, refPixels, testScenario)
{ {
// Plain testing requires a tolerance as high as 50 for 8-8-8-8, which does // Plain testing requires a tolerance as high as 26 for 8-8-8-8, which does
// not leave that much to test. Instead, we narrow down the source of // not leave that much to test. Instead, we narrow down the source of
// expected error. // expected error.
// - Alpha values should always match. // - Alpha values should always match.
// - Color components should be acceptably close, except for the red // - Color components should be acceptably close, except for the red
// channel of the green pixel. Green has the largest change in what's // channel of the green pixel. Green has the largest change in what's
// representable between sRGB and P3/2020. // representable between sRGB and P3/2020.
// Red channel of the green pixel is component numnber 5. // Red channel of the green pixel is R channel of the second pixel.
// - Webp round-trip results in significant error in the color values.
// crbug.com/847527
if (testScenario.canvasColorParam.pixelFormat == '8-8-8-8') { if (testScenario.canvasColorParam.pixelFormat == '8-8-8-8') {
let tolerance_color = 10; let tolerance_color = 10;
let tolerance_r_green = 26; let tolerance_r_green = 26;
let tolerance_webp = 50;
for (let i = 0; i < actualPixels.length; i++) { for (let i = 0; i < actualPixels.length; i++) {
// Alpha channel // Alpha channel
if (i % 4 == 3) if (i % 4 == 3)
assert_equals(actualPixels[i], refPixels[i]); assert_equals(actualPixels[i], refPixels[i]);
else if (testScenario.encodeOptions.type == 'image/webp')
assert_approx_equals(actualPixels[i], refPixels[i], tolerance_webp);
// Red channel of the green pixel // Red channel of the green pixel
else if (i == 4) else if (i == 4)
assert_approx_equals(actualPixels[i], refPixels[i], tolerance_r_green); assert_approx_equals(actualPixels[i], refPixels[i], tolerance_r_green);
...@@ -42,13 +37,10 @@ function testPixels(actualPixels, refPixels, testScenario) ...@@ -42,13 +37,10 @@ function testPixels(actualPixels, refPixels, testScenario)
} }
} else { } else {
let tolerance_color = 0.02; let tolerance_color = 0.02;
let tolerance_webp = 0.2;
for (let i = 0; i < actualPixels.length; i++) { for (let i = 0; i < actualPixels.length; i++) {
// Alpha channel // Alpha channel
if (i % 4 == 3) if (i % 4 == 3)
assert_equals(actualPixels[i], refPixels[i]); assert_equals(actualPixels[i], refPixels[i]);
else if (testScenario.encodeOptions.type == 'image/webp')
assert_approx_equals(actualPixels[i], refPixels[i], tolerance_webp);
else else
assert_approx_equals(actualPixels[i], refPixels[i], tolerance_color); assert_approx_equals(actualPixels[i], refPixels[i], tolerance_color);
} }
...@@ -99,7 +91,7 @@ function runConvertToBlobTest(testScenario) { ...@@ -99,7 +91,7 @@ function runConvertToBlobTest(testScenario) {
drawPatternOnCanvsa(ctx, testScenario.alpha, compositeOverBlack); drawPatternOnCanvsa(ctx, testScenario.alpha, compositeOverBlack);
var refPixels = ctx.getImageData(0, 0, 2, 2).dataUnion; var refPixels = ctx.getImageData(0, 0, 2, 2).dataUnion;
var t = async_test("Test canvas convertToBlob(): " + var t = async_test("Test canvas convertToBlob(): " +
testScenarioToString(testScenario)); testScenarioToString(testScenario));
var image = new Image(); var image = new Image();
...@@ -115,7 +107,7 @@ function runConvertToBlobTest(testScenario) { ...@@ -115,7 +107,7 @@ function runConvertToBlobTest(testScenario) {
t.step_func(function(blob) { t.step_func(function(blob) {
var urlCreator = window.URL || window.webkitURL; var urlCreator = window.URL || window.webkitURL;
image.src = urlCreator.createObjectURL(blob); image.src = urlCreator.createObjectURL(blob);
}), }),
t.step_func_done(function(e) { t.step_func_done(function(e) {
assert_false("convertToBlob failed."); assert_false("convertToBlob failed.");
}) })
...@@ -149,7 +141,7 @@ function runAllTests() { ...@@ -149,7 +141,7 @@ function runAllTests() {
{colorSpace: 'rec2020', pixelFormat: 'float16'}, {colorSpace: 'rec2020', pixelFormat: 'float16'},
{colorSpace: 'p3', pixelFormat: 'float16'}]; {colorSpace: 'p3', pixelFormat: 'float16'}];
// crbug.com/859102 // crbug.com/859102
// var alphaValues = [0.5, 1]; // var alphaValues = [0.5, 1];
var alphaValues = [1]; var alphaValues = [1];
// The *correct* way to test convertToBlob() is to directly examine the // The *correct* way to test convertToBlob() is to directly examine the
......
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