Index: third_party/WebKit/PerformanceTests/Canvas/draw-hw-accelerated-canvas-2d-to-sw-canvas-2d.html |
diff --git a/third_party/WebKit/PerformanceTests/Canvas/draw-hw-accelerated-canvas-2d-to-sw-canvas-2d.html b/third_party/WebKit/PerformanceTests/Canvas/draw-hw-accelerated-canvas-2d-to-sw-canvas-2d.html |
new file mode 100644 |
index 0000000000000000000000000000000000000000..ec6f340cd1cd957bf3646d8c994358e1a31be18a |
--- /dev/null |
+++ b/third_party/WebKit/PerformanceTests/Canvas/draw-hw-accelerated-canvas-2d-to-sw-canvas-2d.html |
@@ -0,0 +1,57 @@ |
+<!DOCTYPE html> |
+<html> |
+<body> |
+<script src="../resources/runner.js"></script> |
+<script src="resources/canvas_runner.js"></script> |
+<script> |
+var sourceCanvas2D = document.createElement("canvas"); |
+var sourceCtx2D = sourceCanvas2D.getContext("2d"); |
+var destCanvas2D = document.createElement("canvas"); |
+var destCtx2D = destCanvas2D.getContext("2d"); |
+var dummyCanvas2D = document.createElement("canvas"); |
+var dummyCtx2D = dummyCanvas2D.getContext("2d"); |
+ |
+function setSize(sourceWidth, sourceHeight, destWidth, destHeight) { |
+ sourceCanvas2D.width = sourceWidth; |
+ sourceCanvas2D.height = sourceHeight; |
+ destCanvas2D.width = destWidth; |
+ destCanvas2D.height = destHeight; |
+ dummyCanvas2D.width = destWidth; |
+ dummyCanvas2D.height = destHeight; |
+} |
+ |
+function rand(range) { |
+ return Math.floor(Math.random() * range); |
+} |
+ |
+function fillCanvas(ctx2d, canvas2d) { |
+ ctx2d.fillStyle = "rgba(" + rand(255) + "," + rand(255) + "," + rand(255) + "," + rand(255) + ")"; |
+ ctx2d.fillRect(0, 0, canvas2d.width, canvas2d.height); |
+} |
+ |
+function doRun() { |
+ // draw static Canvas |
+ destCtx2D.drawImage(sourceCanvas2D, 0, 0); |
+} |
+ |
+function ensureComplete() { |
+ // Using destCanvas2D as a source image is just to flush out the content when |
+ // accelerated 2D canvas is in use. |
+ dummyCtx2D.drawImage(destCanvas2D, 0, 0, 1, 1, 0, 0, 1, 1); |
+} |
+ |
+window.onload = function () { |
+ // It should use setMinimumAccelerated2dCanvasSize() to enable accelerated Canvas for a specified size |
+ // but this API is not available in JS or WebPage. Assume the threshold size is 256x257 |
+ // and the dest canvas is not HW accelerated Canvas when setting its size to 200x200. |
+ setSize(1024, 1024, 200, 200); |
+ fillCanvas(sourceCtx2D, sourceCanvas2D); |
+ CanvasRunner.start({ |
+ description: "This bench test checks the speed on drawing static 2d Canvas(1024x1024) to a canvas that is initially not accelerated (200x200).", |
+ doRun: doRun, |
+ ensureComplete: ensureComplete}); |
+} |
+ |
+</script> |
+</body> |
+</html> |