forked from chromium/chromium
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add Performance tests for willReadFrequently Feature
Adding performance tests that serve to measure how much performance improvements can be obtained by the addition of willReadFrequently option. Test cases include multiple draws and multiple getImageData calls. The canvas-getImageData-smooth.html is corrected and shows that the discrepancy between cpu and gpu rendering does exist. Bug: 1090180 Change-Id: I8701f4389d8f0c9a26498d35b874453512e4669f Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2231808 Reviewed-by: Juanmi Huertas <juanmihd@chromium.org> Reviewed-by: Fernando Serboncini <fserb@chromium.org> Commit-Queue: Teresa Kang <teresakang@google.com> Cr-Commit-Position: refs/heads/master@{#776577}
- Loading branch information
Teresa Kang
authored and
Commit Bot
committed
Jun 9, 2020
1 parent
0d1ea14
commit f7cf80b
Showing
7 changed files
with
183 additions
and
0 deletions.
There are no files selected for viewing
36 changes: 36 additions & 0 deletions
36
third_party/blink/perf_tests/canvas/repeated-draw-cpu.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<body> | ||
<script src="../resources/runner.js"></script> | ||
<script> | ||
|
||
const canvas2D = document.createElement("canvas"); | ||
var ctx2D = canvas2D.getContext("2d", { willReadFrequently: true }); | ||
|
||
function setSize(width, height) { | ||
canvas2D.width = width; | ||
canvas2D.height = height; | ||
} | ||
|
||
function fillCanvas(ctx2d) { | ||
ctx2d.fillStyle = "green"; | ||
ctx2d.fillRect(0, 0, ctx2d.canvas.width, ctx2d.canvas.height); | ||
} | ||
|
||
function repeatedDrawAndGetImageDataFromCanvas2D() { | ||
for (let i = 0; i < 10; ++i) | ||
fillCanvas(ctx2D); | ||
ctx2D.getImageData(0, 0, canvas2D.width, canvas2D.height); | ||
} | ||
|
||
setSize(1024, 1024); | ||
|
||
PerfTestRunner.measureRunsPerSecond({ | ||
run: repeatedDrawAndGetImageDataFromCanvas2D, | ||
description: "This bench test checks the speed on repeated draw and" + | ||
" getImageData once from Canvas2D(1024x1024) if rendered by CPU." | ||
}); | ||
|
||
</script> | ||
</body> | ||
</html> |
36 changes: 36 additions & 0 deletions
36
third_party/blink/perf_tests/canvas/repeated-draw-gpu.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<body> | ||
<script src="../resources/runner.js"></script> | ||
<script> | ||
|
||
const canvas2D = document.createElement("canvas"); | ||
var ctx2D = canvas2D.getContext("2d", { willReadFrequently: false }); | ||
|
||
function setSize(width, height) { | ||
canvas2D.width = width; | ||
canvas2D.height = height; | ||
} | ||
|
||
function fillCanvas(ctx2d) { | ||
ctx2d.fillStyle = "green"; | ||
ctx2d.fillRect(0, 0, ctx2d.canvas.width, ctx2d.canvas.height); | ||
} | ||
|
||
function repeatedDrawAndGetImageDataFromCanvas2D() { | ||
for (let i = 0; i < 10; ++i) | ||
fillCanvas(ctx2D); | ||
ctx2D.getImageData(0, 0, canvas2D.width, canvas2D.height); | ||
} | ||
|
||
setSize(1024, 1024); | ||
|
||
PerfTestRunner.measureRunsPerSecond({ | ||
run: repeatedDrawAndGetImageDataFromCanvas2D, | ||
description: "This bench test checks the speed on repeated draw and" + | ||
" getImageData once from Canvas2D(1024x1024) if rendered by GPU." | ||
}); | ||
|
||
</script> | ||
</body> | ||
</html> |
37 changes: 37 additions & 0 deletions
37
third_party/blink/perf_tests/canvas/repeated-getImageData-cpu.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<body> | ||
<script src="../resources/runner.js"></script> | ||
<script> | ||
|
||
const canvas2D = document.createElement("canvas"); | ||
var ctx2D = canvas2D.getContext("2d", { willReadFrequently: true }); | ||
|
||
function setSize(width, height) { | ||
canvas2D.width = width; | ||
canvas2D.height = height; | ||
} | ||
|
||
function fillCanvas(ctx2d) { | ||
ctx2d.fillStyle = "green"; | ||
ctx2d.fillRect(0, 0, ctx2d.canvas.width, ctx2d.canvas.height); | ||
} | ||
|
||
function drawAndRepeatedGetImageDataFromCanvas2D() { | ||
fillCanvas(ctx2D); | ||
for (let i = 0; i < 10; ++i) | ||
ctx2D.getImageData(0, 0, canvas2D.width, canvas2D.height); | ||
} | ||
|
||
setSize(1024, 1024); | ||
|
||
PerfTestRunner.measureRunsPerSecond({ | ||
run: drawAndRepeatedGetImageDataFromCanvas2D, | ||
description: "This bench test checks the speed on a draw operation followed" + | ||
" by repeatedly calling getImageData from Canvas2D(1024x1024) if rendered" + | ||
" by CPU." | ||
}); | ||
|
||
</script> | ||
</body> | ||
</html> |
37 changes: 37 additions & 0 deletions
37
third_party/blink/perf_tests/canvas/repeated-getImageData-gpu.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<body> | ||
<script src="../resources/runner.js"></script> | ||
<script> | ||
|
||
const canvas2D = document.createElement("canvas"); | ||
var ctx2D = canvas2D.getContext("2d", { willReadFrequently: false }); | ||
|
||
function setSize(width, height) { | ||
canvas2D.width = width; | ||
canvas2D.height = height; | ||
} | ||
|
||
function fillCanvas(ctx2d) { | ||
ctx2d.fillStyle = "green"; | ||
ctx2d.fillRect(0, 0, ctx2d.canvas.width, ctx2d.canvas.height); | ||
} | ||
|
||
function drawAndRepeatedGetImageDataFromCanvas2D() { | ||
fillCanvas(ctx2D); | ||
for (let i = 0; i < 10; ++i) | ||
ctx2D.getImageData(0, 0, canvas2D.width, canvas2D.height); | ||
} | ||
|
||
setSize(1024, 1024); | ||
|
||
PerfTestRunner.measureRunsPerSecond({ | ||
run: drawAndRepeatedGetImageDataFromCanvas2D, | ||
description: "This bench test checks the speed on a draw operation followed" + | ||
" by repeatedly calling getImageData from Canvas2D(1024x1024) if rendered" + | ||
" by GPU." | ||
}); | ||
|
||
</script> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
17 changes: 17 additions & 0 deletions
17
third_party/blink/web_tests/fast/canvas/canvas-gpu-consistency-expected.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<!DOCTYPE html> | ||
<canvas id="canvas" width="300" height="300"></canvas> | ||
<script> | ||
// Testing that getImageData does NOT unaccelerate the canvas | ||
var canvas = document.getElementById('canvas'); | ||
var ctx = canvas.getContext('2d', { willReadFrequently: false }); | ||
|
||
var img = document.createElement('IMG'); | ||
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,iVBORw0KGgoAAAANSUhEUgAAAAkAAAAJCAYAAADgkQYQ" + | ||
"AAAAGklEQVQYlWNgYGD4j4z/////H12MYVQRUYoAkYZrlWt0UekAAAAASUVORK5CYII="; | ||
|
||
</script> |
18 changes: 18 additions & 0 deletions
18
third_party/blink/web_tests/fast/canvas/canvas-gpu-consistency.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
<!DOCTYPE html> | ||
<canvas id="canvas" width="300" height="300"></canvas> | ||
<script> | ||
// Testing that getImageData does NOT unaccelerate the canvas | ||
var canvas = document.getElementById('canvas'); | ||
var ctx = canvas.getContext('2d', { willReadFrequently: false }); | ||
|
||
var img = document.createElement('IMG'); | ||
img.onload = function () { | ||
ctx.getImageData(0, 0, canvas.width, canvas.height); | ||
ctx.drawImage(img, 0, 0, 300, 300); | ||
} | ||
|
||
// This src image correspond to a gradient white line | ||
img.src = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAkAAAAJCAYAAADgkQYQ" + | ||
"AAAAGklEQVQYlWNgYGD4j4z/////H12MYVQRUYoAkYZrlWt0UekAAAAASUVORK5CYII="; | ||
|
||
</script> |