Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(302)

Side by Side Diff: third_party/WebKit/PerformanceTests/Canvas/draw-video-to-hw-accelerated-canvas-2d.html

Issue 2399013003: Tweaking the draw-video-to-hw-accelerated-canvas-2d to stay on GPU (Closed)
Patch Set: Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 <!DOCTYPE html> 1 <!DOCTYPE html>
2 <html> 2 <html>
3 <body> 3 <body>
4 <video id="video" loop></video> 4 <video id="video" loop></video>
5 <script src="../resources/runner.js"></script> 5 <script src="../resources/runner.js"></script>
6 <script src="resources/canvas_runner.js"></script> 6 <script src="resources/canvas_runner.js"></script>
7 <script> 7 <script>
8 var videoElement = document.getElementById("video"); 8 var videoElement = document.getElementById("video");
9 var destCanvas2D = document.createElement("canvas"); 9 var destCanvas2D = document.createElement("canvas");
10 var destCtx2D = destCanvas2D.getContext("2d"); 10 var destCtx2D = destCanvas2D.getContext("2d");
11 var dummyCanvas2D = document.createElement("canvas"); 11 var dummyCanvas2D = document.createElement("canvas");
12 var dummyCtx2D = dummyCanvas2D.getContext("2d"); 12 var dummyCtx2D = dummyCanvas2D.getContext("2d");
13 13
14 dummyCanvas2D.width = 1;
15 dummyCanvas2D.height = 1;
16
17 function setSize(width, height) { 14 function setSize(width, height) {
18 destCanvas2D.width = width; 15 destCanvas2D.width = width;
19 destCanvas2D.height = height; 16 destCanvas2D.height = height;
17 dummyCanvas2D.width = width;
18 dummyCanvas2D.height = height;
20 } 19 }
21 20
22 function startPerfTest() { 21 function startPerfTest() {
23 CanvasRunner.start({ 22 CanvasRunner.start({
24 description: "This bench test checks the speed on drawing Video element to HW accelerated Canvas2D(1024x1024).", 23 description: "This bench test checks the speed on drawing Video element to HW accelerated Canvas2D(1024x1024).",
25 doRun: doRun, 24 doRun: doRun,
26 ensureComplete: ensureComplete}); 25 ensureComplete: ensureComplete});
27 } 26 }
28 27
29 function doRun() { 28 function doRun() {
30 // draw Video 29 // draw Video
31 destCtx2D.drawImage(videoElement, 0, 0); 30 destCtx2D.drawImage(videoElement, 0, 0);
32 } 31 }
33 32
34 function ensureComplete() { 33 function ensureComplete() {
35 // Using destCanvas2D as a source image is just to flush out the content whe n 34 // Using destCanvas2D as a source image is just to flush out the content whe n
36 // accelerated 2D canvas is in use. 35 // accelerated 2D canvas is in use.
36 // dummyCtx2D must also be accelerated to prevent destCanvas2D from becoming
37 // non-accelerated due to the DisableAccelerationToAvoidReadbacks heuristic.
37 dummyCtx2D.drawImage(destCanvas2D, 0, 0, 1, 1, 0, 0, 1, 1); 38 dummyCtx2D.drawImage(destCanvas2D, 0, 0, 1, 1, 0, 0, 1, 1);
38 } 39 }
39 40
40 window.onload = function () { 41 window.onload = function () {
41 // It should use setMinimumAccelerated2dCanvasSize() to enable accelerated C anvas for a specified size 42 // It should use setMinimumAccelerated2dCanvasSize() to enable accelerated C anvas for a specified size
42 // but this API is not available in JS or WebPage. Assume the threshold size is 256x257 43 // but this API is not available in JS or WebPage. Assume the threshold size is 256x257
43 // and the dest canvas is HW accelerated Canvas when setting its size to 102 4x1024. 44 // and the dest canvas is HW accelerated Canvas when setting its size to 102 4x1024.
44 setSize(1024, 1024); 45 setSize(1024, 1024);
45 46
46 videoElement.src = "resources/bear-1280x720.mp4"; 47 videoElement.src = "resources/bear-1280x720.mp4";
47 if(!videoElement.canPlayType('video/mp4').replace(/no/, '')) { 48 if(!videoElement.canPlayType('video/mp4').replace(/no/, '')) {
48 CanvasRunner.logFatalError("video/mp4 is unsupported"); 49 CanvasRunner.logFatalError("video/mp4 is unsupported");
49 }; 50 };
50 CanvasRunner.startPlayingAndWaitForVideo(videoElement, startPerfTest); 51 CanvasRunner.startPlayingAndWaitForVideo(videoElement, startPerfTest);
51 } 52 }
52 53
53 </script> 54 </script>
54 </body> 55 </body>
55 </html> 56 </html>
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698