Commit b852f746 authored by junchao.han@intel.com's avatar junchao.han@intel.com

add SVG zoom/scroll case to perf test

This case contains SVG zoom/scroll animation including 20 frames zoom in, 
20 frames scroll and 20 frames zoom out. Final result is total time used to 
animate these 60 frames.

Review URL: https://codereview.chromium.org/1267093002

git-svn-id: svn://svn.chromium.org/blink/trunk@201291 bbb929c8-8fbe-4397-9dbb-9b2b20218538
parent b1dc59f8
<!DOCTYPE html>
<div>
<object id="svg-content" data="resources/Cowboy.svg" width="400px" height="400px" type="image/svg+xml">
</object>
</div>
<script src="../resources/runner.js"></script>
<script>
var svgContent;
var startTime;
var loop_iterations = 5;
var ANIMATION_ITERATIONS = 5;
var animation_loop;
var offset;
var state;
var delta;
var results = [];
var now = function(){
return window.performance ? performance.now() : Date.now();
};
var init = function(){
animation_loop = ANIMATION_ITERATIONS;
offset = 0;
state = 'zoomin';
delta = 1;
startTime = now();
requestAnimationFrame(step);
};
var step = function(){
animation_loop--;
if (animation_loop==0){
animation_loop = ANIMATION_ITERATIONS;
switch(state){
case 'zoomin':
state='scroll';
delta = 0;
break;
case 'scroll':
state='zoomout';
delta = 2;
break;
case 'zoomout':
loop_iterations--;
results.push(now()-startTime);
if (loop_iterations>0)
init();
else{
PerfTestRunner.logStatistics(results, 'ms', "Time:");
if (testRunner) testRunner.notifyDone();
}
return;
}
}
switch(state){
case 'zoomin':
delta += 0.2;
svgContent.style.transform='matrix('+delta+',0,0,'+delta+',0,0)';
break;
case 'scroll':
if (animation_loop>ANIMATION_ITERATIONS/2) delta += 80;
else delta -= 80;
svgContent.style.transform='matrix(2,0,0,2,'+delta+',0)';
break;
case 'zoomout':
delta -= 0.2;
svgContent.style.transform='matrix('+delta+',0,0,'+delta+',0,0)';
break;
}
requestAnimationFrame(step);
};
window.onload = function(){
svgContent = document.getElementById('svg-content').contentDocument.documentElement;
init();
}
</script>
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