Add canvas line dash test
authorjonlee@apple.com <jonlee@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 13 Oct 2015 02:12:11 +0000 (02:12 +0000)
committerjonlee@apple.com <jonlee@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 13 Oct 2015 02:12:11 +0000 (02:12 +0000)
https://bugs.webkit.org/show_bug.cgi?id=150078
<rdar://problem/23082347>

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

PerformanceTests/Animometer/runner/resources/tests.js
PerformanceTests/Animometer/tests/simple/resources/simple-canvas-paths.js
PerformanceTests/ChangeLog

index 085b903513c9da263fea89c9cf56c781ea08370f..1f715ffbc16c87d6c00386ff6b344f404c290468 100644 (file)
@@ -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&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"
         {
             url: "simple/simple-canvas-paths.html?pathType=quadratic",
             name: "Canvas quadratic segments"
index 5b5f755e170c6e32fae31b12b5d6f286817b8f49..37215ea48ed83b3e5053f8d26a65a221282bb2b1 100644 (file)
@@ -221,6 +221,27 @@ function CanvasLinePathStage(element, options)
 CanvasLinePathStage.prototype = Object.create(SimpleCanvasPathStrokeStage.prototype);
 CanvasLinePathStage.prototype.constructor = CanvasLinePathStage;
 
 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) {
 // === 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);
     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":
         break;
     }
     case "quadratic":
index 286e6d0f50fad7494ea3ad927b242627c62f6a95..0463633a274f6ccf88f84e71aed6bd602cea80f5 100644 (file)
@@ -1,3 +1,19 @@
+2015-10-12  Jon Lee  <jonlee@apple.com>
+
+        Add canvas line dash test
+        https://bugs.webkit.org/show_bug.cgi?id=150078
+        <rdar://problem/23082347>
+
+        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  <jonlee@apple.com>
 
         Add canvas line path tests
 2015-10-12  Jon Lee  <jonlee@apple.com>
 
         Add canvas line path tests