1 function TemplateCanvasObject(stage)
3 // For the canvas stage, most likely you will need to create your
4 // animated object since it's only draw time thing.
6 // Fill in your object data.
9 TemplateCanvasObject.prototype._draw = function()
14 TemplateCanvasObject.prototype.animate = function(timeDelta)
16 // Redraw the animated object. The last time this animated
17 // item was drawn before 'timeDelta'.
21 // Redraw your object.
25 function TemplateCanvasStage(element, options)
27 Stage.call(this, element, options);
28 this.context = this.element.getContext("2d");
30 // Define a collection for your objects.
33 TemplateCanvasStage.prototype = Object.create(Stage.prototype);
34 TemplateCanvasStage.prototype.constructor = TemplateCanvasStage;
36 TemplateCanvasStage.prototype.tune = function(count)
38 // If count is -ve, -count elements need to be removed form the
39 // stage. If count is +ve, +count elements need to be added to
42 // Change objects in the stage.
44 // Return the number of all the elements in the stage.
45 // This number is recorded in the sampled data.
47 // Return the count of the objects in the stage.
51 TemplateCanvasStage.prototype.animate = function(timeDelta)
53 // Animate the elements such that all of them are redrawn. Most
54 // likely you will need to call TemplateCanvasObject.animate()
55 // for all your animated objects here.
57 // Loop through all your objects and ask them to animate.
60 function TemplateCanvasAnimator(benchmark)
62 Animator.call(this, benchmark);
63 this._context = benchmark._stage.context;
66 TemplateCanvasAnimator.prototype = Object.create(StageAnimator.prototype);
67 TemplateCanvasAnimator.prototype.constructor = TemplateCanvasAnimator;
69 TemplateCanvasAnimator.prototype.animate = function()
71 // Most likely you will need to clear the canvas with every redraw.
72 this._context.clearRect(0, 0, this._benchmark._stage.size.x, this._benchmark._stage.size.y);
74 // Draw scene stuff here if needed.
76 return StageAnimator.prototype.animate.call(this);
79 function TemplateCanvasBenchmark(suite, test, options, recordTable, progressBar)
81 StageBenchmark.call(this, suite, test, options, recordTable, progressBar);
84 TemplateCanvasBenchmark.prototype = Object.create(StageBenchmark.prototype);
85 TemplateCanvasBenchmark.prototype.constructor = TemplateCanvasBenchmark;
87 TemplateCanvasBenchmark.prototype.createStage = function(element)
89 // Attach the stage to the benchmark.
90 return new TemplateCanvasStage(element, this._options);
93 TemplateCanvasBenchmark.prototype.createAnimator = function()
95 // Attach the animator to the benchmark.
96 return new TemplateCanvasAnimator(this);
99 window.benchmarkClient.create = function(suite, test, options, recordTable, progressBar)
101 // This function is called from the test harness which starts the
102 // test by creating your benchmark object.
103 return new TemplateCanvasBenchmark(suite, test, options, recordTable, progressBar);