Index: PerformanceTests/Canvas/draw-static-webgl-to-hw-accelerated-canvas-2d.html |
diff --git a/PerformanceTests/Canvas/draw-static-webgl-to-hw-accelerated-canvas-2d.html b/PerformanceTests/Canvas/draw-static-webgl-to-hw-accelerated-canvas-2d.html |
index 0170724c595ce97282eb6868de5b6741fc1d711c..b83b4fe65599a75c377310b013b8522e03d538f5 100644 |
--- a/PerformanceTests/Canvas/draw-static-webgl-to-hw-accelerated-canvas-2d.html |
+++ b/PerformanceTests/Canvas/draw-static-webgl-to-hw-accelerated-canvas-2d.html |
@@ -2,16 +2,14 @@ |
<html> |
<body> |
<script src="../resources/runner.js"></script> |
+<script src="resources/canvas_runner.js"></script> |
<script> |
var canvas2D = document.createElement("canvas"); |
var ctx2D = canvas2D.getContext("2d"); |
var canvas3D = document.createElement('canvas'); |
var gl = canvas3D.getContext('experimental-webgl'); |
if (!gl) |
- PerfTestRunner.logFatalError("\nWebGL is not supported or enabled on this platform!\n"); |
-var MEASURE_DRAW_TIMES = 1000; |
-var MAX_COUNT = 60000; |
-var count = 0; |
+ CanvasRunner.logFatalError("\nWebGL is not supported or enabled on this platform!\n"); |
function setSize(canvas2DWidth, canvas2DHeight, webglWidth, webglHeight) { |
canvas2D.width = canvas2DWidth; |
@@ -33,36 +31,27 @@ function renderWebGL(gl) { |
gl.clear(gl.COLOR_BUFFER_BIT); |
} |
-function drawWebGLToCanvas2D() { |
- var start = PerfTestRunner.now(); |
- for (var i = 0; i < MEASURE_DRAW_TIMES; i++) { |
- // draw static WebGL |
- ctx2D.drawImage(canvas3D, 0, 0); |
- } |
+function doRun() { |
+ // draw static WebGL |
+ ctx2D.drawImage(canvas3D, 0, 0); |
+} |
+ |
+function ensureComplete() { |
// Calling getImageData() is just to flush out the content when |
// accelerated 2D canvas is in use. The cost of reading 1x1 pixels is low. |
ctx2D.getImageData(0, 0, 1, 1); |
- count++; |
- |
- var elapsedTime = PerfTestRunner.now() - start; |
- PerfTestRunner.measureValueAsync(MEASURE_DRAW_TIMES * 1000 / elapsedTime); |
- if (count < MAX_COUNT) |
- requestAnimationFrame(drawWebGLToCanvas2D); |
-} |
- |
-function onCompletedRun() { |
- count = MAX_COUNT; |
} |
window.onload = function () { |
- PerfTestRunner.prepareToMeasureValuesAsync({done: onCompletedRun, unit: 'runs/s', |
- description: "This bench test checks the speed on drawing static WebGL(1024x1024) to HW accelerated Canvas2D(1024x1024)."}); |
// 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 HW accelerated Canvas when setting its size to 1024x1024. |
setSize(1024, 1024, 1024, 1024); |
renderWebGL(gl); |
- drawWebGLToCanvas2D(); |
+ CanvasRunner.start({ |
+ description: "This bench test checks the speed on drawing static WebGL(1024x1024) to HW accelerated Canvas2D(1024x1024).", |
+ doRun: doRun, |
+ ensureComplete: ensureComplete}); |
} |
</script> |