From ac2518556d5d6494461043438832ceee35cd93b2 Mon Sep 17 00:00:00 2001 From: "jonlee@apple.com" Date: Tue, 13 Oct 2015 02:12:11 +0000 Subject: [PATCH] Add canvas line dash test https://bugs.webkit.org/show_bug.cgi?id=150078 Reviewed by Dean Jackson. * Animometer/runner/resources/tests.js: Add line dash test. * Animometer/tests/simple/resources/simple-canvas-paths.js: (CanvasLineDashStage): Create a new stage with a default dash pattern and stroke style. Maintain a step which will animate the dash. (CanvasLineDashStage.prototype.animate): Render the line path with the dash. Increment the dash offset to animate. (CanvasPathBenchmark.prototype.createStage): Add the test. git-svn-id: https://svn.webkit.org/repository/webkit/trunk@190921 268f45cc-cd09-0410-ab3c-d52691b4dbfc --- .../Animometer/runner/resources/tests.js | 4 ++++ .../simple/resources/simple-canvas-paths.js | 23 +++++++++++++++++++ PerformanceTests/ChangeLog | 16 +++++++++++++ 3 files changed, 43 insertions(+) diff --git a/PerformanceTests/Animometer/runner/resources/tests.js b/PerformanceTests/Animometer/runner/resources/tests.js index 085b903513c9..1f715ffbc16c 100644 --- a/PerformanceTests/Animometer/runner/resources/tests.js +++ b/PerformanceTests/Animometer/runner/resources/tests.js @@ -162,6 +162,10 @@ Suites.push(new Suite("Basic canvas path suite", url: "simple/simple-canvas-paths.html?pathType=linePath&lineJoin=miter", name: "Canvas line path, miter join" }, + { + url: "simple/simple-canvas-paths.html?pathType=linePath&lineDash=1", + name: "Canvas line path with dash pattern" + }, { url: "simple/simple-canvas-paths.html?pathType=quadratic", name: "Canvas quadratic segments" diff --git a/PerformanceTests/Animometer/tests/simple/resources/simple-canvas-paths.js b/PerformanceTests/Animometer/tests/simple/resources/simple-canvas-paths.js index 5b5f755e170c..37215ea48ed8 100644 --- a/PerformanceTests/Animometer/tests/simple/resources/simple-canvas-paths.js +++ b/PerformanceTests/Animometer/tests/simple/resources/simple-canvas-paths.js @@ -221,6 +221,27 @@ function CanvasLinePathStage(element, options) CanvasLinePathStage.prototype = Object.create(SimpleCanvasPathStrokeStage.prototype); CanvasLinePathStage.prototype.constructor = CanvasLinePathStage; +function CanvasLineDashStage(element, options) +{ + SimpleCanvasStage.call(this, element, options, CanvasLinePoint); + this.context.setLineDash([1, 2, 3, 4, 5, 6, 7, 8, 9, 10]); + this.context.lineWidth = 1; + this.context.strokeStyle = "#000"; + this._step = 0; +} +CanvasLineDashStage.prototype = Object.create(SimpleCanvasStage.prototype); +CanvasLineDashStage.prototype.constructor = CanvasLineDashStage; +CanvasLineDashStage.prototype.animate = function() { + var context = this.context; + context.lineDashOffset = this._step++; + context.beginPath(); + context.moveTo(0,0); + this._objects.forEach(function(object) { + object.draw(context); + }); + context.stroke(); +}; + // === BENCHMARK === function CanvasPathBenchmark(suite, test, options, recordTable, progressBar) { @@ -236,6 +257,8 @@ CanvasPathBenchmark.prototype.createStage = function(element) case "linePath": { if ("lineJoin" in this._options) return new CanvasLinePathStage(element, this._options); + if ("lineDash" in this._options) + return new CanvasLineDashStage(element, this._options); break; } case "quadratic": diff --git a/PerformanceTests/ChangeLog b/PerformanceTests/ChangeLog index 286e6d0f50fa..0463633a274f 100644 --- a/PerformanceTests/ChangeLog +++ b/PerformanceTests/ChangeLog @@ -1,3 +1,19 @@ +2015-10-12 Jon Lee + + Add canvas line dash test + https://bugs.webkit.org/show_bug.cgi?id=150078 + + + Reviewed by Dean Jackson. + + * Animometer/runner/resources/tests.js: Add line dash test. + * Animometer/tests/simple/resources/simple-canvas-paths.js: + (CanvasLineDashStage): Create a new stage with a default dash pattern and stroke style. + Maintain a step which will animate the dash. + (CanvasLineDashStage.prototype.animate): Render the line path with the dash. Increment + the dash offset to animate. + (CanvasPathBenchmark.prototype.createStage): Add the test. + 2015-10-12 Jon Lee Add canvas line path tests -- 2.36.0