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.
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@190917 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/PerformanceTests/Animometer/runner/resources/tests.js b/PerformanceTests/Animometer/runner/resources/tests.js
index 6328ea7..597f963 100644
--- a/PerformanceTests/Animometer/runner/resources/tests.js
+++ b/PerformanceTests/Animometer/runner/resources/tests.js
@@ -167,6 +167,18 @@
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"
},
diff --git a/PerformanceTests/Animometer/tests/simple/resources/simple-canvas-paths.js b/PerformanceTests/Animometer/tests/simple/resources/simple-canvas-paths.js
index 9253c3d..3b0d96c 100644
--- a/PerformanceTests/Animometer/tests/simple/resources/simple-canvas-paths.js
+++ b/PerformanceTests/Animometer/tests/simple/resources/simple-canvas-paths.js
@@ -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 @@
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 @@
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":
diff --git a/PerformanceTests/ChangeLog b/PerformanceTests/ChangeLog
index e79c336..eb6d6a8 100644
--- a/PerformanceTests/ChangeLog
+++ b/PerformanceTests/ChangeLog
@@ -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