From 6bf0a5cb5034a7e684dcc3500e841785237ce2dd Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sun, 7 Apr 2024 19:32:43 +0200 Subject: Adding upstream version 1:115.7.0. Signed-off-by: Daniel Baumann --- .../bouncing-particles/bouncing-canvas-images.html | 26 +++++ .../bouncing-particles/bouncing-canvas-shapes.html | 18 +++ .../bouncing-particles/bouncing-css-images.html | 22 ++++ .../bouncing-particles/bouncing-css-shapes.html | 33 ++++++ .../bouncing-particles/bouncing-svg-images.html | 18 +++ .../bouncing-particles/bouncing-svg-shapes.html | 18 +++ .../bouncing-particles/bouncing-tagged-images.html | 22 ++++ .../resources/bouncing-canvas-images.js | 47 ++++++++ .../resources/bouncing-canvas-particles.js | 88 +++++++++++++++ .../resources/bouncing-canvas-shapes.js | 87 +++++++++++++++ .../resources/bouncing-css-images.js | 61 ++++++++++ .../resources/bouncing-css-shapes.js | 86 ++++++++++++++ .../resources/bouncing-particles.js | 123 +++++++++++++++++++++ .../resources/bouncing-svg-images.js | 43 +++++++ .../resources/bouncing-svg-particles.js | 67 +++++++++++ .../resources/bouncing-svg-shapes.js | 101 +++++++++++++++++ .../resources/bouncing-tagged-images.js | 106 ++++++++++++++++++ .../tests/bouncing-particles/resources/image1.jpg | Bin 0 -> 64004 bytes .../tests/bouncing-particles/resources/image2.jpg | Bin 0 -> 71981 bytes .../tests/bouncing-particles/resources/image3.jpg | Bin 0 -> 71319 bytes .../tests/bouncing-particles/resources/image4.jpg | Bin 0 -> 96373 bytes .../tests/bouncing-particles/resources/image5.jpg | Bin 0 -> 135674 bytes 22 files changed, 966 insertions(+) create mode 100644 third_party/webkit/PerformanceTests/MotionMark/tests/bouncing-particles/bouncing-canvas-images.html create mode 100644 third_party/webkit/PerformanceTests/MotionMark/tests/bouncing-particles/bouncing-canvas-shapes.html create mode 100644 third_party/webkit/PerformanceTests/MotionMark/tests/bouncing-particles/bouncing-css-images.html create mode 100644 third_party/webkit/PerformanceTests/MotionMark/tests/bouncing-particles/bouncing-css-shapes.html create mode 100644 third_party/webkit/PerformanceTests/MotionMark/tests/bouncing-particles/bouncing-svg-images.html create mode 100644 third_party/webkit/PerformanceTests/MotionMark/tests/bouncing-particles/bouncing-svg-shapes.html create mode 100644 third_party/webkit/PerformanceTests/MotionMark/tests/bouncing-particles/bouncing-tagged-images.html create mode 100644 third_party/webkit/PerformanceTests/MotionMark/tests/bouncing-particles/resources/bouncing-canvas-images.js create mode 100644 third_party/webkit/PerformanceTests/MotionMark/tests/bouncing-particles/resources/bouncing-canvas-particles.js create mode 100644 third_party/webkit/PerformanceTests/MotionMark/tests/bouncing-particles/resources/bouncing-canvas-shapes.js create mode 100644 third_party/webkit/PerformanceTests/MotionMark/tests/bouncing-particles/resources/bouncing-css-images.js create mode 100644 third_party/webkit/PerformanceTests/MotionMark/tests/bouncing-particles/resources/bouncing-css-shapes.js create mode 100644 third_party/webkit/PerformanceTests/MotionMark/tests/bouncing-particles/resources/bouncing-particles.js create mode 100644 third_party/webkit/PerformanceTests/MotionMark/tests/bouncing-particles/resources/bouncing-svg-images.js create mode 100644 third_party/webkit/PerformanceTests/MotionMark/tests/bouncing-particles/resources/bouncing-svg-particles.js create mode 100644 third_party/webkit/PerformanceTests/MotionMark/tests/bouncing-particles/resources/bouncing-svg-shapes.js create mode 100644 third_party/webkit/PerformanceTests/MotionMark/tests/bouncing-particles/resources/bouncing-tagged-images.js create mode 100644 third_party/webkit/PerformanceTests/MotionMark/tests/bouncing-particles/resources/image1.jpg create mode 100644 third_party/webkit/PerformanceTests/MotionMark/tests/bouncing-particles/resources/image2.jpg create mode 100644 third_party/webkit/PerformanceTests/MotionMark/tests/bouncing-particles/resources/image3.jpg create mode 100644 third_party/webkit/PerformanceTests/MotionMark/tests/bouncing-particles/resources/image4.jpg create mode 100644 third_party/webkit/PerformanceTests/MotionMark/tests/bouncing-particles/resources/image5.jpg (limited to 'third_party/webkit/PerformanceTests/MotionMark/tests/bouncing-particles') diff --git a/third_party/webkit/PerformanceTests/MotionMark/tests/bouncing-particles/bouncing-canvas-images.html b/third_party/webkit/PerformanceTests/MotionMark/tests/bouncing-particles/bouncing-canvas-images.html new file mode 100644 index 0000000000..864c19adcd --- /dev/null +++ b/third_party/webkit/PerformanceTests/MotionMark/tests/bouncing-particles/bouncing-canvas-images.html @@ -0,0 +1,26 @@ + + + + + + + + + + + + + + + + + + + + + diff --git a/third_party/webkit/PerformanceTests/MotionMark/tests/bouncing-particles/bouncing-canvas-shapes.html b/third_party/webkit/PerformanceTests/MotionMark/tests/bouncing-particles/bouncing-canvas-shapes.html new file mode 100644 index 0000000000..c759d45c08 --- /dev/null +++ b/third_party/webkit/PerformanceTests/MotionMark/tests/bouncing-particles/bouncing-canvas-shapes.html @@ -0,0 +1,18 @@ + + + + + + + + + + + + + + + + + + diff --git a/third_party/webkit/PerformanceTests/MotionMark/tests/bouncing-particles/bouncing-css-images.html b/third_party/webkit/PerformanceTests/MotionMark/tests/bouncing-particles/bouncing-css-images.html new file mode 100644 index 0000000000..058de486de --- /dev/null +++ b/third_party/webkit/PerformanceTests/MotionMark/tests/bouncing-particles/bouncing-css-images.html @@ -0,0 +1,22 @@ + + + + + + + + +
+ + + + + + + + + diff --git a/third_party/webkit/PerformanceTests/MotionMark/tests/bouncing-particles/bouncing-css-shapes.html b/third_party/webkit/PerformanceTests/MotionMark/tests/bouncing-particles/bouncing-css-shapes.html new file mode 100644 index 0000000000..0c1248f490 --- /dev/null +++ b/third_party/webkit/PerformanceTests/MotionMark/tests/bouncing-particles/bouncing-css-shapes.html @@ -0,0 +1,33 @@ + + + + + + + + +
+ + + + + + + + + diff --git a/third_party/webkit/PerformanceTests/MotionMark/tests/bouncing-particles/bouncing-svg-images.html b/third_party/webkit/PerformanceTests/MotionMark/tests/bouncing-particles/bouncing-svg-images.html new file mode 100644 index 0000000000..2b6a0b9db5 --- /dev/null +++ b/third_party/webkit/PerformanceTests/MotionMark/tests/bouncing-particles/bouncing-svg-images.html @@ -0,0 +1,18 @@ + + + + + + + + + + + + + + + + + + diff --git a/third_party/webkit/PerformanceTests/MotionMark/tests/bouncing-particles/bouncing-svg-shapes.html b/third_party/webkit/PerformanceTests/MotionMark/tests/bouncing-particles/bouncing-svg-shapes.html new file mode 100644 index 0000000000..a821231672 --- /dev/null +++ b/third_party/webkit/PerformanceTests/MotionMark/tests/bouncing-particles/bouncing-svg-shapes.html @@ -0,0 +1,18 @@ + + + + + + + + + + + + + + + + + + diff --git a/third_party/webkit/PerformanceTests/MotionMark/tests/bouncing-particles/bouncing-tagged-images.html b/third_party/webkit/PerformanceTests/MotionMark/tests/bouncing-particles/bouncing-tagged-images.html new file mode 100644 index 0000000000..f67f14ad36 --- /dev/null +++ b/third_party/webkit/PerformanceTests/MotionMark/tests/bouncing-particles/bouncing-tagged-images.html @@ -0,0 +1,22 @@ + + + + + + + + + + + + + + + +
+ + diff --git a/third_party/webkit/PerformanceTests/MotionMark/tests/bouncing-particles/resources/bouncing-canvas-images.js b/third_party/webkit/PerformanceTests/MotionMark/tests/bouncing-particles/resources/bouncing-canvas-images.js new file mode 100644 index 0000000000..5fba5ad761 --- /dev/null +++ b/third_party/webkit/PerformanceTests/MotionMark/tests/bouncing-particles/resources/bouncing-canvas-images.js @@ -0,0 +1,47 @@ +(function() { + +BouncingCanvasImage = Utilities.createSubclass(BouncingCanvasParticle, + function(stage) + { + BouncingCanvasParticle.call(this, stage, "image"); + this._imageElement = stage.imageElement; + }, { + + _draw: function() + { + this.context.save(); + this.applyRotation(); + this.context.drawImage(this._imageElement, 0, 0, this.size.x, this.size.y); + this.context.restore(); + } +}); + +BouncingCanvasImagesStage = Utilities.createSubclass(BouncingCanvasParticlesStage, + function() + { + BouncingCanvasParticlesStage.call(this); + }, { + + initialize: function(benchmark, options) + { + BouncingCanvasParticlesStage.prototype.initialize.call(this, benchmark, options); + var imageSrc = options["imageSrc"] || "resources/yin-yang.svg"; + this.imageElement = document.querySelector(".hidden[src=\"" + imageSrc + "\"]"); + }, + + createParticle: function() + { + return new BouncingCanvasImage(this); + } +}); + +BouncingCanvasImagesBenchmark = Utilities.createSubclass(Benchmark, + function(options) + { + Benchmark.call(this, new BouncingCanvasImagesStage(), options); + } +); + +window.benchmarkClass = BouncingCanvasImagesBenchmark; + +})(); diff --git a/third_party/webkit/PerformanceTests/MotionMark/tests/bouncing-particles/resources/bouncing-canvas-particles.js b/third_party/webkit/PerformanceTests/MotionMark/tests/bouncing-particles/resources/bouncing-canvas-particles.js new file mode 100644 index 0000000000..0a76ba05c3 --- /dev/null +++ b/third_party/webkit/PerformanceTests/MotionMark/tests/bouncing-particles/resources/bouncing-canvas-particles.js @@ -0,0 +1,88 @@ +BouncingCanvasParticle = Utilities.createSubclass(BouncingParticle, + function(stage, shape) + { + BouncingParticle.call(this, stage); + this.context = stage.context; + this._shape = shape; + this._clip = stage.clip; + }, { + + applyRotation: function() + { + if (this._shape == "circle") + return; + + this.context.translate(this.size.x / 2, this.size.y / 2); + this.context.rotate(this.rotater.degree() * Math.PI / 180); + this.context.translate(-this.size.x / 2, -this.size.y / 2); + }, + + applyClipping: function() + { + var clipPoints = BouncingCanvasParticle.clips[this._clip]; + if (!clipPoints) + return; + + this.context.beginPath(); + clipPoints.forEach(function(point, index) { + var point = this.size.multiply(point); + if (!index) + this.context.moveTo(point.x, point.y); + else + this.context.lineTo(point.x, point.y); + }, this); + + this.context.closePath(); + this.context.clip(); + }, + + _draw: function() + { + throw "Not implemented"; + }, + + animate: function(timeDelta) + { + BouncingParticle.prototype.animate.call(this, timeDelta); + this.context.save(); + this.context.translate(this.position.x, this.position.y); + this._draw(); + this.context.restore(); + } +}); + +BouncingCanvasParticle.clips = { + star: [ + new Point(0.50, 0.00), + new Point(0.38, 0.38), + new Point(0.00, 0.38), + new Point(0.30, 0.60), + new Point(0.18, 1.00), + new Point(0.50, 0.75), + new Point(0.82, 1.00), + new Point(0.70, 0.60), + new Point(1.00, 0.38), + new Point(0.62, 0.38) + ] +}; + +BouncingCanvasParticlesStage = Utilities.createSubclass(BouncingParticlesStage, + function() + { + BouncingParticlesStage.call(this); + }, { + + initialize: function(benchmark, options) + { + BouncingParticlesStage.prototype.initialize.call(this, benchmark, options); + this.context = this.element.getContext("2d"); + }, + + animate: function(timeDelta) + { + this.context.clearRect(0, 0, this.size.x, this.size.y); + this.particles.forEach(function(particle) { + particle.animate(timeDelta); + }); + } +}); diff --git a/third_party/webkit/PerformanceTests/MotionMark/tests/bouncing-particles/resources/bouncing-canvas-shapes.js b/third_party/webkit/PerformanceTests/MotionMark/tests/bouncing-particles/resources/bouncing-canvas-shapes.js new file mode 100644 index 0000000000..49a31cf40d --- /dev/null +++ b/third_party/webkit/PerformanceTests/MotionMark/tests/bouncing-particles/resources/bouncing-canvas-shapes.js @@ -0,0 +1,87 @@ +(function() { + +BouncingCanvasShape = Utilities.createSubclass(BouncingCanvasParticle, + function(stage) + { + BouncingCanvasParticle.call(this, stage, stage.shape); + this._fill = stage.fill; + this._color0 = Stage.randomColor(); + this._color1 = Stage.randomColor(); + }, { + + _applyFill: function() + { + switch (this._fill) { + case "gradient": + var gradient = this.context.createLinearGradient(0, 0, this.size.width, 0); + gradient.addColorStop(0, this._color0); + gradient.addColorStop(1, this._color1); + this.context.fillStyle = gradient; + break; + + case "solid": + default: + this.context.fillStyle = this._color0; + break; + } + }, + + _drawShape: function() + { + this.context.beginPath(); + + switch (this._shape) { + case "rect": + this.context.rect(0, 0, this.size.width, this.size.height); + break; + + case "circle": + default: + var center = this.size.center; + var radius = Math.min(this.size.x, this.size.y) / 2; + this.context.arc(center.x, center.y, radius, 0, Math.PI * 2, true); + break; + } + + this.context.fill(); + }, + + _draw: function() + { + this.context.save(); + this._applyFill(); + this.applyRotation(); + this.applyClipping(); + this._drawShape(); + this.context.restore(); + } +}); + +BouncingCanvasShapesStage = Utilities.createSubclass(BouncingCanvasParticlesStage, + function () + { + BouncingCanvasParticlesStage.call(this); + }, { + + initialize: function(benchmark, options) + { + BouncingCanvasParticlesStage.prototype.initialize.call(this, benchmark, options); + this.parseShapeParameters(options); + }, + + createParticle: function() + { + return new BouncingCanvasShape(this); + } +}); + +BouncingCanvasShapesBenchmark = Utilities.createSubclass(Benchmark, + function(options) + { + Benchmark.call(this, new BouncingCanvasShapesStage(), options); + } +); + +window.benchmarkClass = BouncingCanvasShapesBenchmark; + +})(); \ No newline at end of file diff --git a/third_party/webkit/PerformanceTests/MotionMark/tests/bouncing-particles/resources/bouncing-css-images.js b/third_party/webkit/PerformanceTests/MotionMark/tests/bouncing-particles/resources/bouncing-css-images.js new file mode 100644 index 0000000000..ce9a48c276 --- /dev/null +++ b/third_party/webkit/PerformanceTests/MotionMark/tests/bouncing-particles/resources/bouncing-css-images.js @@ -0,0 +1,61 @@ +(function() { + +BouncingCssImage = Utilities.createSubclass(BouncingParticle, + function(stage) + { + BouncingParticle.call(this, stage); + + this.element = document.createElement("img"); + this.element.style.width = this.size.x + "px"; + this.element.style.height = this.size.y + "px"; + this.element.setAttribute("src", stage.imageSrc); + + stage.element.appendChild(this.element); + this._move(); + }, { + + _move: function() + { + this.element.style.transform = "translate(" + this.position.x + "px," + this.position.y + "px) " + this.rotater.rotateZ(); + }, + + animate: function(timeDelta) + { + BouncingParticle.prototype.animate.call(this, timeDelta); + this._move(); + } +}); + +BouncingCssImagesStage = Utilities.createSubclass(BouncingParticlesStage, + function() + { + BouncingParticlesStage.call(this); + }, { + + initialize: function(benchmark, options) + { + BouncingParticlesStage.prototype.initialize.call(this, benchmark, options); + this.imageSrc = options["imageSrc"] || "../resources/yin-yang.svg"; + }, + + createParticle: function() + { + return new BouncingCssImage(this); + }, + + particleWillBeRemoved: function(particle) + { + particle.element.remove(); + } +}); + +BouncingCssImagesBenchmark = Utilities.createSubclass(Benchmark, + function(options) + { + Benchmark.call(this, new BouncingCssImagesStage(), options); + } +); + +window.benchmarkClass = BouncingCssImagesBenchmark; + +})(); diff --git a/third_party/webkit/PerformanceTests/MotionMark/tests/bouncing-particles/resources/bouncing-css-shapes.js b/third_party/webkit/PerformanceTests/MotionMark/tests/bouncing-particles/resources/bouncing-css-shapes.js new file mode 100644 index 0000000000..a1f81863f9 --- /dev/null +++ b/third_party/webkit/PerformanceTests/MotionMark/tests/bouncing-particles/resources/bouncing-css-shapes.js @@ -0,0 +1,86 @@ +(function() { + +BouncingCssShape = Utilities.createSubclass(BouncingParticle, + function(stage) + { + BouncingParticle.call(this, stage); + + this.element = this._createSpan(stage); + + switch (stage.fill) { + case "solid": + default: + this.element.style.backgroundColor = Stage.randomColor(); + break; + + case "gradient": + this.element.style.background = "linear-gradient(" + Stage.randomColor() + ", " + Stage.randomColor() + ")"; + break; + } + + if (stage.blend) + this.element.style.mixBlendMode = Stage.randomStyleMixBlendMode(); + + // Some browsers have not un-prefixed the css filter yet. + if (stage.filter) + Utilities.setElementPrefixedProperty(this.element, "filter", Stage.randomStyleFilter()); + + this._move(); + }, { + + _createSpan: function(stage) + { + var span = document.createElement("span"); + span.className = stage.shape + " " + stage.clip; + span.style.width = this.size.x + "px"; + span.style.height = this.size.y + "px"; + stage.element.appendChild(span); + return span; + }, + + _move: function() + { + this.element.style.transform = "translate(" + this.position.x + "px," + this.position.y + "px)" + this.rotater.rotateZ(); + }, + + animate: function(timeDelta) + { + BouncingParticle.prototype.animate.call(this, timeDelta); + this.rotater.next(timeDelta); + this._move(); + } +}); + +BouncingCssShapesStage = Utilities.createSubclass(BouncingParticlesStage, + function() + { + BouncingParticlesStage.call(this); + }, { + + initialize: function(benchmark, options) + { + BouncingParticlesStage.prototype.initialize.call(this, benchmark, options); + this.parseShapeParameters(options); + }, + + createParticle: function() + { + return new BouncingCssShape(this); + }, + + particleWillBeRemoved: function(particle) + { + particle.element.remove(); + } +}); + +BouncingCssShapesBenchmark = Utilities.createSubclass(Benchmark, + function(options) + { + Benchmark.call(this, new BouncingCssShapesStage(), options); + } +); + +window.benchmarkClass = BouncingCssShapesBenchmark; + +})(); diff --git a/third_party/webkit/PerformanceTests/MotionMark/tests/bouncing-particles/resources/bouncing-particles.js b/third_party/webkit/PerformanceTests/MotionMark/tests/bouncing-particles/resources/bouncing-particles.js new file mode 100644 index 0000000000..27e02a7085 --- /dev/null +++ b/third_party/webkit/PerformanceTests/MotionMark/tests/bouncing-particles/resources/bouncing-particles.js @@ -0,0 +1,123 @@ +function BouncingParticle(stage) +{ + this._stageSize = stage.size; + this.size = stage.particleSize; + + this.position = Stage.randomPosition(stage.size.subtract(stage.particleSize)); + this._angle = Stage.randomAngle(); + this._velocity = Stage.randomVelocity(stage.maxVelocity); + this.rotater = Stage.randomRotater(); +} + +BouncingParticle.prototype = +{ + get center() + { + return this.position.add(this.size.center); + }, + + animate: function(timeDelta) + { + this.position = this.position.move(this._angle, this._velocity, timeDelta); + this.rotater.next(timeDelta); + + // If particle is going to move off right side + if (this.position.x + this.size.x > this._stageSize.x) { + // If direction is East-South, go West-South. + if (this._angle >= 0 && this._angle < Math.PI / 2) + this._angle = Math.PI - this._angle; + // If angle is East-North, go West-North. + else if (this._angle > Math.PI / 2 * 3) + this._angle = this._angle - (this._angle - Math.PI / 2 * 3) * 2; + // Make sure the particle does not go outside the stage boundaries. + this.position.x = this._stageSize.x - this.size.x; + } + + // If particle is going to move off left side + if (this.position.x < 0) { + // If angle is West-South, go East-South. + if (this._angle > Math.PI / 2 && this._angle < Math.PI) + this._angle = Math.PI - this._angle; + // If angle is West-North, go East-North. + else if (this._angle > Math.PI && this._angle < Math.PI / 2 * 3) + this._angle = this._angle + (Math.PI / 2 * 3 - this._angle) * 2; + // Make sure the particle does not go outside the stage boundaries. + this.position.x = 0; + } + + // If particle is going to move off bottom side + if (this.position.y + this.size.y > this._stageSize.y) { + // If direction is South, go North. + if (this._angle > 0 && this._angle < Math.PI) + this._angle = Math.PI * 2 - this._angle; + // Make sure the particle does not go outside the stage boundaries. + this.position.y = this._stageSize.y - this.size.y; + } + + // If particle is going to move off top side + if (this.position.y < 0) { + // If direction is North, go South. + if (this._angle > Math.PI && this._angle < Math.PI * 2) + this._angle = this._angle - (this._angle - Math.PI) * 2; + // Make sure the particle does not go outside the stage boundaries. + this.position.y = 0; + } + } +} + +BouncingParticlesStage = Utilities.createSubclass(Stage, + function() + { + Stage.call(this); + this.particles = []; + }, { + + initialize: function(benchmark, options) + { + Stage.prototype.initialize.call(this, benchmark, options); + this.particleSize = new Point(parseInt(options["particleWidth"]) || 10, parseInt(options["particleHeight"]) || 10); + this.maxVelocity = Math.max(parseInt(options["maxVelocity"]) || 500, 100); + }, + + parseShapeParameters: function(options) + { + this.shape = options["shape"] || "circle"; + this.fill = options["fill"] || "solid"; + this.clip = options["clip"] || ""; + this.blend = options["blend"] || false; + this.filter = options["filter"] || false; + }, + + animate: function(timeDelta) + { + this.particles.forEach(function(particle) { + particle.animate(timeDelta); + }); + }, + + tune: function(count) + { + if (count == 0) + return; + + if (count > 0) { + for (var i = 0; i < count; ++i) + this.particles.push(this.createParticle()); + return; + } + + count = Math.min(-count, this.particles.length); + + if (typeof(this.particleWillBeRemoved) == "function") { + for (var i = 0; i < count; ++i) + this.particleWillBeRemoved(this.particles[this.particles.length - 1 - i]); + } + + this.particles.splice(-count, count); + }, + + complexity: function() + { + return this.particles.length; + } +}); diff --git a/third_party/webkit/PerformanceTests/MotionMark/tests/bouncing-particles/resources/bouncing-svg-images.js b/third_party/webkit/PerformanceTests/MotionMark/tests/bouncing-particles/resources/bouncing-svg-images.js new file mode 100644 index 0000000000..2239557312 --- /dev/null +++ b/third_party/webkit/PerformanceTests/MotionMark/tests/bouncing-particles/resources/bouncing-svg-images.js @@ -0,0 +1,43 @@ +(function() { + +BouncingSvgImage = Utilities.createSubclass(BouncingSvgParticle, + function(stage) + { + BouncingSvgParticle.call(this, stage, "image"); + + var attrs = { x: 0, y: 0, width: this.size.x, height: this.size.y }; + var xlinkAttrs = { href: stage.imageSrc }; + this.element = Utilities.createSVGElement("image", attrs, xlinkAttrs, stage.element); + this._move(); + } +); + +BouncingSvgImagesStage = Utilities.createSubclass(BouncingSvgParticlesStage, + function() + { + BouncingSvgParticlesStage.call(this); + }, { + + initialize: function(benchmark, options) + { + BouncingSvgParticlesStage.prototype.initialize.call(this, benchmark, options); + this.imageSrc = options["imageSrc"] || "resources/yin-yang.svg"; + }, + + createParticle: function() + { + return new BouncingSvgImage(this); + } +}); + +BouncingSvgImagesBenchmark = Utilities.createSubclass(Benchmark, + function(options) + { + Benchmark.call(this, new BouncingSvgImagesStage(), options); + } +); + +window.benchmarkClass = BouncingSvgImagesBenchmark; + +})(); + diff --git a/third_party/webkit/PerformanceTests/MotionMark/tests/bouncing-particles/resources/bouncing-svg-particles.js b/third_party/webkit/PerformanceTests/MotionMark/tests/bouncing-particles/resources/bouncing-svg-particles.js new file mode 100644 index 0000000000..0988c42d8e --- /dev/null +++ b/third_party/webkit/PerformanceTests/MotionMark/tests/bouncing-particles/resources/bouncing-svg-particles.js @@ -0,0 +1,67 @@ +BouncingSvgParticle = Utilities.createSubclass(BouncingParticle, + function(stage, shape) + { + BouncingParticle.call(this, stage); + this._shape = shape; + }, { + + _applyClipping: function(stage) + { + if (stage.clip != "star") + return; + + stage.ensureClipStarIsCreated(); + this.element.setAttribute("clip-path", "url(#star-clip)"); + }, + + _move: function() + { + var transform = "translate(" + this.position.x + ", " + this.position.y + ")"; + if (this._shape != "circle") + transform += this.rotater.rotate(this.size.center); + this.element.setAttribute("transform", transform); + }, + + animate: function(timeDelta) + { + BouncingParticle.prototype.animate.call(this, timeDelta); + this._move(); + } +}); + +BouncingSvgParticlesStage = Utilities.createSubclass(BouncingParticlesStage, + function() + { + BouncingParticlesStage.call(this); + }, { + + _createDefs: function() + { + return Utilities.createSVGElement("defs", {}, {}, this.element); + }, + + _ensureDefsIsCreated: function() + { + return this.element.querySelector("defs") || this._createDefs(); + }, + + _createClipStar: function() + { + var attrs = { id: "star-clip", clipPathUnits: "objectBoundingBox" }; + var clipPath = Utilities.createSVGElement("clipPath", attrs, {}, this._ensureDefsIsCreated()); + + attrs = { d: "M.50,0L.38,.38L0,.38L.30,.60L.18,1L.50,.75L.82,1L.70,.60L1,.38L.62,.38z" }; + Utilities.createSVGElement("path", attrs, {}, clipPath); + return clipPath; + }, + + ensureClipStarIsCreated: function() + { + return this.element.querySelector("#star-clip") || this._createClipStar(); + }, + + particleWillBeRemoved: function(particle) + { + particle.element.remove(); + } +}); diff --git a/third_party/webkit/PerformanceTests/MotionMark/tests/bouncing-particles/resources/bouncing-svg-shapes.js b/third_party/webkit/PerformanceTests/MotionMark/tests/bouncing-particles/resources/bouncing-svg-shapes.js new file mode 100644 index 0000000000..14c917cc31 --- /dev/null +++ b/third_party/webkit/PerformanceTests/MotionMark/tests/bouncing-particles/resources/bouncing-svg-shapes.js @@ -0,0 +1,101 @@ +(function() { + +BouncingSvgShape = Utilities.createSubclass(BouncingSvgParticle, + function(stage) + { + BouncingSvgParticle.call(this, stage, stage.shape); + this._fill = stage.fill; + + this._createShape(stage); + this._applyClipping(stage); + this._applyFill(stage); + + this._move(); + }, { + + _createShape: function(stage) + { + switch (this._shape) { + case "rect": + var attrs = { x: 0, y: 0, width: this.size.x, height: this.size.y }; + this.element = Utilities.createSVGElement("rect", attrs, {}, stage.element); + break; + + case "circle": + default: + var attrs = { cx: this.size.x / 2, cy: this.size.y / 2, r: Math.min(this.size.x, this.size.y) / 2 }; + this.element = Utilities.createSVGElement("circle", attrs, {}, stage.element); + break; + } + }, + + _applyFill: function(stage) + { + switch (this._fill) { + case "gradient": + var gradient = stage.createGradient(2); + this.element.setAttribute("fill", "url(#" + gradient.getAttribute("id") + ")"); + break; + + case "solid": + default: + this.element.setAttribute("fill", Stage.randomColor()); + break; + } + } +}); + +BouncingSvgShapesStage = Utilities.createSubclass(BouncingSvgParticlesStage, + function() + { + BouncingSvgParticlesStage.call(this); + }, { + + initialize: function(benchmark, options) + { + BouncingSvgParticlesStage.prototype.initialize.call(this, benchmark, options); + this.parseShapeParameters(options); + this._gradientsCount = 0; + }, + + createGradient: function(stops) + { + var attrs = { id: "gradient-" + ++this._gradientsCount }; + var gradient = Utilities.createSVGElement("linearGradient", attrs, {}, this._ensureDefsIsCreated()); + + for (var i = 0; i < stops; ++i) { + attrs = { offset: i * 100 / (stops - 1) + "%", 'stop-color': Stage.randomColor() }; + Utilities.createSVGElement("stop", attrs, {}, gradient); + } + + return gradient; + }, + + createParticle: function() + { + return new BouncingSvgShape(this); + }, + + particleWillBeRemoved: function(particle) + { + BouncingSvgParticlesStage.prototype.particleWillBeRemoved.call(this, particle); + + var fill = particle.element.getAttribute("fill"); + if (fill.indexOf("url(#") != 0) + return; + + var gradient = this.element.querySelector(fill.substring(4, fill.length - 1)); + this._ensureDefsIsCreated().removeChild(gradient); + } +}); + +BouncingSvgShapesBenchmark = Utilities.createSubclass(Benchmark, + function(options) + { + Benchmark.call(this, new BouncingSvgShapesStage(), options); + } +); + +window.benchmarkClass = BouncingSvgShapesBenchmark; + +})(); diff --git a/third_party/webkit/PerformanceTests/MotionMark/tests/bouncing-particles/resources/bouncing-tagged-images.js b/third_party/webkit/PerformanceTests/MotionMark/tests/bouncing-particles/resources/bouncing-tagged-images.js new file mode 100644 index 0000000000..1ef6a091d2 --- /dev/null +++ b/third_party/webkit/PerformanceTests/MotionMark/tests/bouncing-particles/resources/bouncing-tagged-images.js @@ -0,0 +1,106 @@ +(function() { + +BouncingTaggedImage = Utilities.createSubclass(BouncingParticle, + function(stage) + { + BouncingParticle.call(this, stage); + + this.element = document.createElement("img"); + this.element.style.width = this.size.x + "px"; + this.element.style.height = this.size.y + "px"; + this.element.setAttribute("src", Stage.randomElementInArray(stage.images).src); + + stage.element.appendChild(this.element); + this._move(); + }, { + + _move: function() + { + this.element.style.transform = "translate(" + this.position.x + "px," + this.position.y + "px) " + this.rotater.rotateZ(); + }, + + animate: function(timeDelta) + { + BouncingParticle.prototype.animate.call(this, timeDelta); + this._move(); + } +}); + +BouncingTaggedImagesStage = Utilities.createSubclass(BouncingParticlesStage, + + function() + { + BouncingParticlesStage.call(this); + }, { + + imageSrcs: [ + "image1", + "image2", + "image3", + "image4", + "image5", + ], + images: [], + + initialize: function(benchmark, options) + { + BouncingParticlesStage.prototype.initialize.call(this, benchmark, options); + + var lastPromise; + var images = this.images; + this.imageSrcs.forEach(function(imageSrc) { + var promise = this._loadImage("resources/" + imageSrc + ".jpg"); + if (!lastPromise) + lastPromise = promise; + else { + lastPromise = lastPromise.then(function(img) { + images.push(img); + return promise; + }); + } + }, this); + + lastPromise.then(function(img) { + images.push(img); + benchmark.readyPromise.resolve(); + }); + }, + + _loadImage: function(src) { + var img = new Image; + var promise = new SimplePromise; + + img.onload = function(e) { + promise.resolve(e.target); + }; + + img.src = src; + return promise; + }, + + createParticle: function() + { + return new BouncingTaggedImage(this); + }, + + particleWillBeRemoved: function(particle) + { + particle.element.remove(); + } +}); + +BouncingTaggedImagesBenchmark = Utilities.createSubclass(Benchmark, + function(options) + { + Benchmark.call(this, new BouncingTaggedImagesStage(), options); + }, { + + waitUntilReady: function() { + this.readyPromise = new SimplePromise; + return this.readyPromise; + } +}); + +window.benchmarkClass = BouncingTaggedImagesBenchmark; + +})(); diff --git a/third_party/webkit/PerformanceTests/MotionMark/tests/bouncing-particles/resources/image1.jpg b/third_party/webkit/PerformanceTests/MotionMark/tests/bouncing-particles/resources/image1.jpg new file mode 100644 index 0000000000..ea7a4c1303 Binary files /dev/null and b/third_party/webkit/PerformanceTests/MotionMark/tests/bouncing-particles/resources/image1.jpg differ diff --git a/third_party/webkit/PerformanceTests/MotionMark/tests/bouncing-particles/resources/image2.jpg b/third_party/webkit/PerformanceTests/MotionMark/tests/bouncing-particles/resources/image2.jpg new file mode 100644 index 0000000000..697272dcb0 Binary files /dev/null and b/third_party/webkit/PerformanceTests/MotionMark/tests/bouncing-particles/resources/image2.jpg differ diff --git a/third_party/webkit/PerformanceTests/MotionMark/tests/bouncing-particles/resources/image3.jpg b/third_party/webkit/PerformanceTests/MotionMark/tests/bouncing-particles/resources/image3.jpg new file mode 100644 index 0000000000..6e5964e7a9 Binary files /dev/null and b/third_party/webkit/PerformanceTests/MotionMark/tests/bouncing-particles/resources/image3.jpg differ diff --git a/third_party/webkit/PerformanceTests/MotionMark/tests/bouncing-particles/resources/image4.jpg b/third_party/webkit/PerformanceTests/MotionMark/tests/bouncing-particles/resources/image4.jpg new file mode 100644 index 0000000000..806f548c44 Binary files /dev/null and b/third_party/webkit/PerformanceTests/MotionMark/tests/bouncing-particles/resources/image4.jpg differ diff --git a/third_party/webkit/PerformanceTests/MotionMark/tests/bouncing-particles/resources/image5.jpg b/third_party/webkit/PerformanceTests/MotionMark/tests/bouncing-particles/resources/image5.jpg new file mode 100644 index 0000000000..d7971f6bcb Binary files /dev/null and b/third_party/webkit/PerformanceTests/MotionMark/tests/bouncing-particles/resources/image5.jpg differ -- cgit v1.2.3