Add canvas path fill tests
authorjonlee@apple.com <jonlee@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 13 Oct 2015 02:10:08 +0000 (02:10 +0000)
committerjonlee@apple.com <jonlee@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 13 Oct 2015 02:10:08 +0000 (02:10 +0000)
https://bugs.webkit.org/show_bug.cgi?id=150071
<rdar://problem/23082001>

Reviewed by Dean Jackson.

* Animometer/runner/resources/tests.js: Add new pathTypes for path fills.
* Animometer/tests/simple/resources/simple-canvas-paths.js:
(CanvasLinePoint): Add basic point for a line, and call lineTo.
(SimpleCanvasPathFillStage): Add a new stage similar to SimpleCanvasPathStrokeStage.
(CanvasPathBenchmark.prototype.createStage): Add the tests.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@190917 268f45cc-cd09-0410-ab3c-d52691b4dbfc

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

index 6328ea7..597f963 100644 (file)
@@ -167,6 +167,18 @@ Suites.push(new Suite("Basic canvas path suite",
             name: "Canvas rects"
         },
         {
+            url: "simple/simple-canvas-paths.html?pathType=lineFill",
+            name: "Canvas line path, fill"
+        },
+        {
+            url: "simple/simple-canvas-paths.html?pathType=quadraticFill",
+            name: "Canvas quadratic path, fill"
+        },
+        {
+            url: "simple/simple-canvas-paths.html?pathType=bezierFill",
+            name: "Canvas bezier path, fill"
+        },
+        {
             url: "simple/simple-canvas-paths.html?&pathType=arcToFill",
             name: "Canvas arcTo segments, fill"
         },
index 9253c3d..3b0d96c 100644 (file)
@@ -1,5 +1,12 @@
 // === PAINT OBJECTS ===
 
+function CanvasLinePoint(stage, coordinateMaximum) {
+    this._point = stage.randomPosition(new Point(Math.min(stage.size.x, coordinateMaximum), Math.min(stage.size.y, coordinateMaximum)));
+}
+CanvasLinePoint.prototype.draw = function(context) {
+    context.lineTo(this._point.x, this._point.y);
+};
+
 function CanvasQuadraticSegment(stage) {
     var maxSize = stage.randomInt(20, 200);
     var toCenter = stage.randomPosition(stage.size).subtract(new Point(maxSize/2, maxSize/2));
@@ -142,6 +149,22 @@ SimpleCanvasPathStrokeStage.prototype.animate = function() {
     context.stroke();
 }
 
+function SimpleCanvasPathFillStage(element, options, canvasObject) {
+    SimpleCanvasStage.call(this, element, options, canvasObject);
+}
+SimpleCanvasPathFillStage.prototype = Object.create(SimpleCanvasStage.prototype);
+SimpleCanvasPathFillStage.prototype.constructor = SimpleCanvasPathFillStage;
+SimpleCanvasPathFillStage.prototype.animate = function() {
+    var context = this.context;
+    context.fillStyle = this.randomColor();
+    context.beginPath();
+    context.moveTo(0,0);
+    this._objects.forEach(function(object) {
+        object.draw(context);
+    });
+    context.fill();
+}
+
 // === BENCHMARK ===
 
 function CanvasPathBenchmark(suite, test, options, recordTable, progressBar) {
@@ -166,6 +189,12 @@ CanvasPathBenchmark.prototype.createStage = function(element)
         return new SimpleCanvasStage(element, this._options, CanvasArcSegment);
     case "rect":
         return new SimpleCanvasStage(element, this._options, CanvasRect);
+    case "lineFill":
+        return new SimpleCanvasPathFillStage(element, this._options, CanvasLinePoint);
+    case "quadraticFill":
+        return new SimpleCanvasPathFillStage(element, this._options, CanvasQuadraticPoint);
+    case "bezierFill":
+        return new SimpleCanvasPathFillStage(element, this._options, CanvasBezierPoint);
     case "arcToFill":
         return new SimpleCanvasStage(element, this._options, CanvasArcToSegmentFill);
     case "arcFill":
index e79c336..eb6d6a8 100644 (file)
@@ -1,5 +1,19 @@
 2015-10-12  Jon Lee  <jonlee@apple.com>
 
+        Add canvas path fill tests
+        https://bugs.webkit.org/show_bug.cgi?id=150071
+        <rdar://problem/23082001>
+
+        Reviewed by Dean Jackson.
+
+        * Animometer/runner/resources/tests.js: Add new pathTypes for path fills.
+        * Animometer/tests/simple/resources/simple-canvas-paths.js:
+        (CanvasLinePoint): Add basic point for a line, and call lineTo.
+        (SimpleCanvasPathFillStage): Add a new stage similar to SimpleCanvasPathStrokeStage.
+        (CanvasPathBenchmark.prototype.createStage): Add the tests.
+
+2015-10-12  Jon Lee  <jonlee@apple.com>
+
         Add canvas path tests
         https://bugs.webkit.org/show_bug.cgi?id=150067
         rdar://problem/23081463