Commit 71af7965 authored by Juanmi Huertas's avatar Juanmi Huertas Committed by Commit Bot

Revert "Fixing ShouldAccelerate to preserve acceleration"

This reverts commit 0e20fdf5.

This reverts a fix that will be reintroduced later on once we add
the WillReadFrequently to the creation of canvases.

Bug: 1001845, 983642, 1008179
Change-Id: I4e5aa58af69e1b202962eee37177e5cd0401c9a9
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1829794
Commit-Queue: Juanmi Huertas <juanmihd@chromium.org>
Reviewed-by: default avatarFernando Serboncini <fserb@chromium.org>
Cr-Commit-Position: refs/heads/master@{#702174}
parent 7519d14a
...@@ -139,8 +139,6 @@ bool Canvas2DLayerBridge::ShouldAccelerate(AccelerationHint hint) const { ...@@ -139,8 +139,6 @@ bool Canvas2DLayerBridge::ShouldAccelerate(AccelerationHint hint) const {
accelerate = true; accelerate = true;
} else if (acceleration_mode_ == kDisableAcceleration) { } else if (acceleration_mode_ == kDisableAcceleration) {
accelerate = false; accelerate = false;
} else if (acceleration_mode_ == kEnableAcceleration) {
accelerate = true;
} else { } else {
accelerate = hint == kPreferAcceleration || accelerate = hint == kPreferAcceleration ||
hint == kPreferAccelerationAfterVisibilityChange; hint == kPreferAccelerationAfterVisibilityChange;
......
...@@ -327,30 +327,6 @@ TEST_F(Canvas2DLayerBridgeTest, AccelerationHint) { ...@@ -327,30 +327,6 @@ TEST_F(Canvas2DLayerBridgeTest, AccelerationHint) {
scoped_refptr<StaticBitmapImage> image = scoped_refptr<StaticBitmapImage> image =
bridge->NewImageSnapshot(kPreferNoAcceleration); bridge->NewImageSnapshot(kPreferNoAcceleration);
EXPECT_TRUE(bridge->IsValid()); EXPECT_TRUE(bridge->IsValid());
EXPECT_TRUE(bridge->IsAccelerated());
}
{
std::unique_ptr<Canvas2DLayerBridge> bridge =
MakeBridge(IntSize(300, 300), Canvas2DLayerBridge::kDisableAcceleration,
CanvasColorParams());
PaintFlags flags;
bridge->DrawingCanvas()->drawRect(SkRect::MakeXYWH(0, 0, 1, 1), flags);
scoped_refptr<StaticBitmapImage> image =
bridge->NewImageSnapshot(kPreferAcceleration);
EXPECT_TRUE(bridge->IsValid());
EXPECT_FALSE(bridge->IsAccelerated());
}
{
std::unique_ptr<Canvas2DLayerBridge> bridge =
MakeBridge(IntSize(300, 300), Canvas2DLayerBridge::kDisableAcceleration,
CanvasColorParams());
PaintFlags flags;
bridge->DrawingCanvas()->drawRect(SkRect::MakeXYWH(0, 0, 1, 1), flags);
scoped_refptr<StaticBitmapImage> image =
bridge->NewImageSnapshot(kPreferNoAcceleration);
EXPECT_TRUE(bridge->IsValid());
EXPECT_FALSE(bridge->IsAccelerated()); EXPECT_FALSE(bridge->IsAccelerated());
} }
} }
......
...@@ -642,14 +642,6 @@ crbug.com/980804 virtual/scroll_customization/fast/scrolling/scrollbars/mouse-au ...@@ -642,14 +642,6 @@ crbug.com/980804 virtual/scroll_customization/fast/scrolling/scrollbars/mouse-au
crbug.com/980804 virtual/threaded/fast/scrolling/scrollbars/mouse-autoscrolling-on-scrollbar.html [ Slow ] crbug.com/980804 virtual/threaded/fast/scrolling/scrollbars/mouse-autoscrolling-on-scrollbar.html [ Slow ]
crbug.com/980804 virtual/main_thread_scrollbar_gestures/fast/scrolling/scrollbars/mouse-autoscrolling-on-scrollbar.html [ Slow ] crbug.com/980804 virtual/main_thread_scrollbar_gestures/fast/scrolling/scrollbars/mouse-autoscrolling-on-scrollbar.html [ Slow ]
crbug.com/983642 virtual/gpu/fast/canvas/canvas-composite-alpha.html [ Slow ]
crbug.com/983642 [ Mac Debug ] fast/canvas/canvas-composite-alpha.html [ Slow ]
crbug.com/983642 virtual/gpu/fast/canvas/canvas-composite-text-alpha.html [ Slow ]
crbug.com/983642 [ Debug ] fast/canvas/canvas-composite-text-alpha.html [ Slow ]
crbug.com/983642 virtual/gpu/fast/canvas/color-space/canvas-createImageBitmap-e_srgb.html [ Slow ]
crbug.com/983642 [ Mac ] fast/canvas/color-space/canvas-createImageBitmap-e_srgb.html [ Slow ]
crbug.com/983642 [ Win ] virtual/gpu/fast/canvas/color-space/canvas-createImageBitmap-p3.html [ Slow ]
crbug.com/983642 [ Win ] virtual/gpu/fast/canvas/color-space/canvas-createImageBitmap-rec2020.html [ Slow ]
# These tests work fine but are slow in all Debug builds and for some # These tests work fine but are slow in all Debug builds and for some
# reason Win7 is timing out occasionally crbug.com/985231. # reason Win7 is timing out occasionally crbug.com/985231.
......
...@@ -108,7 +108,7 @@ function checkPixels() { ...@@ -108,7 +108,7 @@ function checkPixels() {
assert_equals(d[0], 255); assert_equals(d[0], 255);
assert_equals(d[1], 0); assert_equals(d[1], 0);
assert_equals(d[2], 0); assert_equals(d[2], 0);
assert_approx_equals(d[3], 125, 10); assert_approx_equals(d[3], 113, 10);
imageData = ctx.getImageData(499, 499, 1, 1); imageData = ctx.getImageData(499, 499, 1, 1);
d = imageData.data; d = imageData.data;
......
...@@ -24,4 +24,4 @@ test(function(t) { ...@@ -24,4 +24,4 @@ test(function(t) {
}, "Series of tests to ensure that fillText() paints nothing on canvas when the fillStyle is set to a zero-size gradient."); }, "Series of tests to ensure that fillText() paints nothing on canvas when the fillStyle is set to a zero-size gradient.");
</script> </script>
</body> </b
\ No newline at end of file \ No newline at end of file
...@@ -3,12 +3,10 @@ ...@@ -3,12 +3,10 @@
<body> <body>
<script> <script>
var rgbApprox = 70, alphaApprox = 0, alphaMax = 0; var rgbApprox = 0, alphaApprox = 0, alphaMax = 0;
function testPixelShadow(pixel, reference) { function testPixelShadow(pixel, reference) {
for(i = 0; i < 3; i++){ for(i = 0; i < 3; i++)
if(pixel[3] != 0) pixel[i] = pixel[i] * 255 / pixel[3];
assert_approx_equals(pixel[i], reference[i], rgbApprox); assert_approx_equals(pixel[i], reference[i], rgbApprox);
}
if(alphaMax != 0) if(alphaMax != 0)
assert_true(pixel[3] < alphaMax); assert_true(pixel[3] < alphaMax);
else else
...@@ -24,7 +22,7 @@ var ctx = canvas.getContext('2d'); ...@@ -24,7 +22,7 @@ var ctx = canvas.getContext('2d');
var gradient = ctx.createLinearGradient(0, 0, 100, 100); var gradient = ctx.createLinearGradient(0, 0, 100, 100);
gradient.addColorStop(0, 'rgba(0, 0, 255, 1.0)'); gradient.addColorStop(0, 'rgba(0, 0, 255, 1.0)');
gradient.addColorStop(1, 'rgba(0, 0, 255, 1.0)'); gradient.addColorStop(1, 'rgba(0, 0, 255, 1.0)');
ctx.shadowOffsetX = 200; ctx.shadowOffsetX = 200;
ctx.fillStyle = gradient; ctx.fillStyle = gradient;
...@@ -42,7 +40,7 @@ ctx.shadowColor = 'rgba(255, 0, 0, 0.3)'; ...@@ -42,7 +40,7 @@ ctx.shadowColor = 'rgba(255, 0, 0, 0.3)';
ctx.fillRect(50, 500, 100, 100); ctx.fillRect(50, 500, 100, 100);
// rgbApprox = 1 // rgbApprox = 1
testSolidShadow = testSolidShadow =
[ [
['testSolidShadow 1', ctx.getImageData(250, 50, 1, 1).data, [255, 0, 0, 255]], ['testSolidShadow 1', ctx.getImageData(250, 50, 1, 1).data, [255, 0, 0, 255]],
['testSolidShadow 2', ctx.getImageData(250, 149, 1, 1).data, [255, 0, 0, 255]], ['testSolidShadow 2', ctx.getImageData(250, 149, 1, 1).data, [255, 0, 0, 255]],
...@@ -51,30 +49,30 @@ testSolidShadow = ...@@ -51,30 +49,30 @@ testSolidShadow =
]; ];
// rgbApprox = 3, alphaApprox = 5 // rgbApprox = 3, alphaApprox = 5
testSolidAlphaShadow = testSolidAlphaShadow =
[ [
['testSolidAlphaShadow 1', ctx.getImageData(250, 200, 1, 1).data, [255, 0, 0, 76]], ['testSolidAlphaShadow 1', ctx.getImageData(250, 200, 1, 1).data, [255, 0, 0, 76]],
['testSolidAlphaShadow 2', ctx.getImageData(250, 299, 1, 1).data, [255, 0, 0, 76]], ['testSolidAlphaShadow 2', ctx.getImageData(250, 299, 1, 1).data, [255, 0, 0, 76]],
['testSolidAlphaShadow 3', ctx.getImageData(349, 200, 1, 1).data, [255, 0, 0, 76]], ['testSolidAlphaShadow 3', ctx.getImageData(349, 200, 1, 1).data, [255, 0, 0, 76]],
['testSolidAlphaShadow 4', ctx.getImageData(349, 299, 1, 1).data, [255, 0, 0, 76]], ['testSolidAlphaShadow 4', ctx.getImageData(349, 299, 1, 1).data, [255, 0, 0, 76]],
]; ];
// alpha < 25 // alpha < 25
testBlurryShadow = testBlurryShadow =
[ [
['testBlurryShadow 1', ctx.getImageData(248, 347, 1, 1).data, [255, 0, 0, 0]], ['testBlurryShadow 1', ctx.getImageData(248, 348, 1, 1).data, [255, 0, 0, 0]],
['testBlurryShadow 2', ctx.getImageData(248, 452, 1, 1).data, [255, 0, 0, 0]], ['testBlurryShadow 2', ctx.getImageData(248, 451, 1, 1).data, [255, 0, 0, 0]],
['testBlurryShadow 3', ctx.getImageData(351, 347, 1, 1).data, [255, 0, 0, 0]], ['testBlurryShadow 3', ctx.getImageData(351, 348, 1, 1).data, [255, 0, 0, 0]],
['testBlurryShadow 4', ctx.getImageData(351, 452, 1, 1).data, [255, 0, 0, 0]], ['testBlurryShadow 4', ctx.getImageData(351, 451, 1, 1).data, [255, 0, 0, 0]],
]; ];
// alpha < 10 // alpha < 10
testBlurryAlphaShadow = testBlurryAlphaShadow =
[ [
['testBlurryAlphaShadow 1', ctx.getImageData(248, 497, 1, 1).data, [255, 0, 0, 0]], ['testBlurryAlphaShadow 1', ctx.getImageData(248, 498, 1, 1).data, [255, 0, 0, 0]],
['testBlurryAlphaShadow 2', ctx.getImageData(248, 602, 1, 1).data, [255, 0, 0, 0]], ['testBlurryAlphaShadow 2', ctx.getImageData(248, 601, 1, 1).data, [255, 0, 0, 0]],
['testBlurryAlphaShadow 3', ctx.getImageData(351, 497, 1, 1).data, [255, 0, 0, 0]], ['testBlurryAlphaShadow 3', ctx.getImageData(351, 498, 1, 1).data, [255, 0, 0, 0]],
['testBlurryAlphaShadow 4', ctx.getImageData(351, 602, 1, 1).data, [255, 0, 0, 0]], ['testBlurryAlphaShadow 4', ctx.getImageData(351, 601, 1, 1).data, [255, 0, 0, 0]],
]; ];
rgbApprox = 1; rgbApprox = 1;
...@@ -84,7 +82,7 @@ rgbApprox = 3; ...@@ -84,7 +82,7 @@ rgbApprox = 3;
alphaApprox = 5; alphaApprox = 5;
generate_tests(testPixelShadow, testSolidAlphaShadow); generate_tests(testPixelShadow, testSolidAlphaShadow);
rgbApprox = 10; rgbApprox = 0;
alphaMax = 25; alphaMax = 25;
generate_tests(testPixelShadow, testBlurryShadow); generate_tests(testPixelShadow, testBlurryShadow);
......
...@@ -49,30 +49,30 @@ testSolidShadow = ...@@ -49,30 +49,30 @@ testSolidShadow =
]; ];
// alphaApprox = 5 // alphaApprox = 5
testSolidAlphaShadow = testSolidAlphaShadow =
[ [
['testSolidAlphaShadow 1', ctx.getImageData(250, 200, 1, 1).data, [255, 0, 0, 76]], ['testSolidAlphaShadow 1', ctx.getImageData(250, 200, 1, 1).data, [255, 0, 0, 76]],
['testSolidAlphaShadow 2', ctx.getImageData(250, 299, 1, 1).data, [255, 0, 0, 76]], ['testSolidAlphaShadow 2', ctx.getImageData(250, 299, 1, 1).data, [255, 0, 0, 76]],
['testSolidAlphaShadow 3', ctx.getImageData(349, 200, 1, 1).data, [255, 0, 0, 76]], ['testSolidAlphaShadow 3', ctx.getImageData(349, 200, 1, 1).data, [255, 0, 0, 76]],
['testSolidAlphaShadow 4', ctx.getImageData(349, 299, 1, 1).data, [255, 0, 0, 76]], ['testSolidAlphaShadow 4', ctx.getImageData(349, 299, 1, 1).data, [255, 0, 0, 76]],
]; ];
// alpha < 25 // alpha < 25
testBlurryShadow = testBlurryShadow =
[ [
['testBlurryShadow 1', ctx.getImageData(248, 347, 1, 1).data, [255, 0, 0, 0]], ['testBlurryShadow 1', ctx.getImageData(248, 348, 1, 1).data, [255, 0, 0, 0]],
['testBlurryShadow 2', ctx.getImageData(248, 452, 1, 1).data, [255, 0, 0, 0]], ['testBlurryShadow 2', ctx.getImageData(248, 451, 1, 1).data, [255, 0, 0, 0]],
['testBlurryShadow 3', ctx.getImageData(351, 347, 1, 1).data, [255, 0, 0, 0]], ['testBlurryShadow 3', ctx.getImageData(351, 348, 1, 1).data, [255, 0, 0, 0]],
['testBlurryShadow 4', ctx.getImageData(351, 452, 1, 1).data, [255, 0, 0, 0]], ['testBlurryShadow 4', ctx.getImageData(351, 451, 1, 1).data, [255, 0, 0, 0]],
]; ];
// alpha < 10 // alpha < 10
testBlurryAlphaShadow = testBlurryAlphaShadow =
[ [
['testBlurryAlphaShadow 1', ctx.getImageData(248, 497, 1, 1).data, [255, 0, 0, 0]], ['testBlurryShadow 5', ctx.getImageData(248, 498, 1, 1).data, [255, 0, 0, 0]],
['testBlurryAlphaShadow 2', ctx.getImageData(248, 602, 1, 1).data, [255, 0, 0, 0]], ['testBlurryShadow 6', ctx.getImageData(248, 601, 1, 1).data, [255, 0, 0, 0]],
['testBlurryAlphaShadow 3', ctx.getImageData(351, 497, 1, 1).data, [255, 0, 0, 0]], ['testBlurryShadow 7', ctx.getImageData(351, 498, 1, 1).data, [255, 0, 0, 0]],
['testBlurryAlphaShadow 4', ctx.getImageData(351, 602, 1, 1).data, [255, 0, 0, 0]], ['testBlurryShadow 8', ctx.getImageData(351, 601, 1, 1).data, [255, 0, 0, 0]],
]; ];
generate_tests(testPixelShadow, testSolidShadow); generate_tests(testPixelShadow, testSolidShadow);
......
<!DOCTYPE html>
<canvas id="c_smooth" width="300" height="300"></canvas>
<canvas id="c_smooth_getImage" width="300" height="300"></canvas>
<script>
var canvas = document.getElementById('c_smooth');
var ctx = canvas.getContext('2d');
ctx.imageSmoothingEnabled = true;
// Create an image element
var img = document.createElement('IMG');
// When the image is loaded, draw it
img.onload = function () {
ctx.drawImage(img, 0, 0, 300, 300);
}
// This src image correspond to a gradient white line
img.src = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAkAAAAJCAYAAADgkQYQAAAAGklEQVQYlWNgYGD4j4z/////H12MYVQRUYoAkYZrlWt0UekAAAAASUVORK5CYII=";
</script>
<!DOCTYPE html>
<canvas id="c_smooth" width="300" height="300"></canvas>
<canvas id="c_smooth_getImage" width="300" height="300"></canvas>
<script>
var canvas = document.getElementById('c_smooth');
var ctx = canvas.getContext('2d');
ctx.imageSmoothingEnabled = true;
// Create an image element
var img = document.createElement('IMG');
// When the image is loaded, draw it
img.onload = function () {
ctx.drawImage(img, 0, 0, 300, 300);
// Testing that getImage will not break the original image
ctx.getImageData(0,0,canvas.width,canvas.height);
}
// This src image correspond to a gradient white line
img.src = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAkAAAAJCAYAAADgkQYQAAAAGklEQVQYlWNgYGD4j4z/////H12MYVQRUYoAkYZrlWt0UekAAAAASUVORK5CYII=";
</script>
<script src='../../resources/testharness.js'></script> <script src='../../resources/testharness.js'></script>
<script src='../../resources/testharnessreport.js'></script> <script src='../../resources/testharnessreport.js'></script>
<canvas id='c' width='100' height='50'></canvas> <canvas id='c_width' width='100' height='50'></canvas>
<canvas id='c_height' width='100' height='50'></canvas>
<script> <script>
// Tests that using reasonably large values for canvas.height and canvas.height do not cause a crash // Tests that using reasonably large values for canvas.height and canvas.height do not cause a crash
var canvas = document.getElementById('c');
var x, y, w = 1, h = 1; var x, y, w = 1, h = 1;
function testLargeDimension(size, isWidth) { function testLargeDimension(size, isWidth) {
var canvas = document.getElementById(isWidth ? 'c_width' : 'c_height');
canvas.width = (isWidth ? size : 50); canvas.width = (isWidth ? size : 50);
canvas.height = (isWidth ? 50 : size); canvas.height = (isWidth ? 50 : size);
var ctx = canvas.getContext('2d'); var ctx = canvas.getContext('2d');
...@@ -16,14 +17,16 @@ function testLargeDimension(size, isWidth) { ...@@ -16,14 +17,16 @@ function testLargeDimension(size, isWidth) {
y = canvas.height - 2; y = canvas.height - 2;
ctx.fillRect(x, y, w, h); ctx.fillRect(x, y, w, h);
var data = ctx.getImageData(x, y, w, h).data; var data = ctx.getImageData(x, y, w, h).data;
for (var i = 0; i < 4; i++) for (var i = 0; i < 3; i++)
assert_equals(data[i], 255); assert_equals(data[i], 255);
} }
testScenarios = [['Test Width = 1000', 1000, true], testScenarios = [['Test Width = 1000', 1000, true],
['Test Height = 1000', 1000, false], ['Test Height = 1000', 1000, false],
['Test Width = 10000', 10000, true], ['Test Width = 10000', 10000, true],
['Test Height = 10000', 10000, false], ['Test Height = 10000', 10000, false],
['Test Width = 32000', 32000, true], ['Test Width = 32000', 32000, true],
['Test Height = 32000', 32000, false]]; ['Test Height = 32000', 32000, false]];
......
<script src="../../resources/testharness.js"></script> <script src="../../resources/testharness.js"></script>
<script src="../../resources/testharnessreport.js"></script> <script src="../../resources/testharnessreport.js"></script>
<body>
<script> <script>
test(function(t) { test(function(t) {
var canvas = document.createElement('canvas') var ctx = document.createElement('canvas').getContext('2d');
var ctx = canvas.getContext('2d');
ctx.fillStyle = '#0f0'; ctx.fillStyle = '#0f0';
ctx.fillRect(0, 0, 1, 1); ctx.fillRect(0, 0, 1, 1);
var g = ctx.createLinearGradient(0, 0, 0, 0); // zero-length line (undefined direction); var g = ctx.createLinearGradient(0, 0, 0, 0); // zero-length line (undefined direction);
g.addColorStop(0, '#f00'); g.addColorStop(0, '#f00');
g.addColorStop(1, '#f00'); g.addColorStop(1, '#f00');
ctx.strokeStyle = g; ctx.strokeStyle = g;
ctx.strokeRect(0, 0, 1 , 1); ctx.strokeRect(0, 0, 1 , 1);
assert_array_equals(ctx.getImageData(0, 0, 1, 1).data.slice(0,3), [0, 255, 0]); assert_array_equals(ctx.getImageData(0, 0, 1, 1).data.slice(0,3), [0, 255, 0]);
}, "Series of tests to ensure that strokeRect() paints nothing on canvas when the strokeStyle is set to a zero-size gradient."); }, "Series of tests to ensure that strokeRect() paints nothing on canvas when the strokeStyle is set to a zero-size gradient.");
</script> </script>
</body>
\ No newline at end of file \ No newline at end of file
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