summaryrefslogtreecommitdiffstats
path: root/third_party/webkit/PerformanceTests/MotionMark/tests/dom
diff options
context:
space:
mode:
Diffstat (limited to 'third_party/webkit/PerformanceTests/MotionMark/tests/dom')
-rw-r--r--third_party/webkit/PerformanceTests/MotionMark/tests/dom/compositing-transforms.html24
-rw-r--r--third_party/webkit/PerformanceTests/MotionMark/tests/dom/focus.html51
-rw-r--r--third_party/webkit/PerformanceTests/MotionMark/tests/dom/leaves.html26
-rw-r--r--third_party/webkit/PerformanceTests/MotionMark/tests/dom/particles.html24
-rw-r--r--third_party/webkit/PerformanceTests/MotionMark/tests/dom/resources/compositing-transforms.js66
-rw-r--r--third_party/webkit/PerformanceTests/MotionMark/tests/dom/resources/dom-particles.js73
-rw-r--r--third_party/webkit/PerformanceTests/MotionMark/tests/dom/resources/focus.js166
-rw-r--r--third_party/webkit/PerformanceTests/MotionMark/tests/dom/resources/leaves.js48
8 files changed, 478 insertions, 0 deletions
diff --git a/third_party/webkit/PerformanceTests/MotionMark/tests/dom/compositing-transforms.html b/third_party/webkit/PerformanceTests/MotionMark/tests/dom/compositing-transforms.html
new file mode 100644
index 0000000000..6d5b0bf5e6
--- /dev/null
+++ b/third_party/webkit/PerformanceTests/MotionMark/tests/dom/compositing-transforms.html
@@ -0,0 +1,24 @@
+<!DOCTYPE html>
+<html>
+<head>
+ <meta charset="utf-8">
+ <link rel="stylesheet" type="text/css" href="../resources/stage.css">
+ <style>
+ img {
+ position: absolute;
+ width: 80px;
+ height: 80px;
+ }
+ </style>
+</head>
+<body>
+ <div id="stage"></div>
+ <script src="../../resources/strings.js"></script>
+ <script src="../../resources/extensions.js"></script>
+ <script src="../../resources/statistics.js"></script>
+ <script src="../resources/math.js"></script>
+ <script src="../resources/main.js"></script>
+ <script src="../bouncing-particles/resources/bouncing-particles.js"></script>
+ <script src="resources/compositing-transforms.js"></script>
+</body>
+</html>
diff --git a/third_party/webkit/PerformanceTests/MotionMark/tests/dom/focus.html b/third_party/webkit/PerformanceTests/MotionMark/tests/dom/focus.html
new file mode 100644
index 0000000000..02264d746f
--- /dev/null
+++ b/third_party/webkit/PerformanceTests/MotionMark/tests/dom/focus.html
@@ -0,0 +1,51 @@
+<!DOCTYPE html>
+<html>
+<head>
+ <meta charset="utf-8">
+ <link rel="stylesheet" type="text/css" href="../resources/stage.css">
+ <style type="text/css">
+
+ #stage {
+ background-color: #201A1F;
+ z-index: -10000;
+ }
+
+ #stage > div {
+ position: absolute;
+ overflow: hidden;
+ }
+ #stage div div {
+ position: absolute;
+ background-color: #DEDADD;
+ border-radius: 50%;
+ }
+
+ #center-text {
+ font-size: 90%;
+ transform: translate3d(-50%, -50%, 0);
+ }
+
+ #center-text span {
+ position: absolute;
+ color: #201A1F;
+ font-weight: 400;
+ font-size: 2em;
+ top: 50%;
+ left: 50%;
+ transform: translate(-50%, -50%);
+ }
+
+ </style>
+</head>
+<body>
+ <div id="stage">
+ <div id="center-text"><div><span>focus</span></div></div>
+ </div>
+ <script src="../../resources/strings.js"></script>
+ <script src="../../resources/extensions.js"></script>
+ <script src="../../resources/statistics.js"></script>
+ <script src="../resources/math.js"></script>
+ <script src="../resources/main.js"></script>
+ <script src="resources/focus.js"></script>
+</body>
+</html>
diff --git a/third_party/webkit/PerformanceTests/MotionMark/tests/dom/leaves.html b/third_party/webkit/PerformanceTests/MotionMark/tests/dom/leaves.html
new file mode 100644
index 0000000000..625882ebef
--- /dev/null
+++ b/third_party/webkit/PerformanceTests/MotionMark/tests/dom/leaves.html
@@ -0,0 +1,26 @@
+<!DOCTYPE html>
+<html>
+<head>
+ <meta charset="utf-8">
+ <link rel="stylesheet" type="text/css" href="../resources/stage.css">
+ <style>
+ #stage {
+ background-color: #23282B;
+ }
+ #stage img {
+ position: absolute;
+ }
+ </style>
+</head>
+<body>
+ <div id="stage"></div>
+ <script src="../../resources/strings.js"></script>
+ <script src="../../resources/extensions.js"></script>
+ <script src="../../resources/statistics.js"></script>
+ <script src="../resources/math.js"></script>
+ <script src="../resources/main.js"></script>
+ <script src="../master/resources/particles.js"></script>
+ <script src="../master/resources/leaves.js"></script>
+ <script src="resources/leaves.js"></script>
+</body>
+</html>
diff --git a/third_party/webkit/PerformanceTests/MotionMark/tests/dom/particles.html b/third_party/webkit/PerformanceTests/MotionMark/tests/dom/particles.html
new file mode 100644
index 0000000000..fdc09399c9
--- /dev/null
+++ b/third_party/webkit/PerformanceTests/MotionMark/tests/dom/particles.html
@@ -0,0 +1,24 @@
+<!DOCTYPE html>
+<html>
+<head>
+ <meta charset="utf-8">
+ <link rel="stylesheet" type="text/css" href="../resources/stage.css">
+ <style>
+ #stage div {
+ position: absolute;
+ -webkit-mask-image: url(../resources/star.svg);
+ mask: url(../resources/star.svg#star-mask);
+ }
+ </style>
+</head>
+<body>
+ <div id="stage"></div>
+ <script src="../../resources/strings.js"></script>
+ <script src="../../resources/extensions.js"></script>
+ <script src="../../resources/statistics.js"></script>
+ <script src="../resources/math.js"></script>
+ <script src="../resources/main.js"></script>
+ <script src="../master/resources/particles.js"></script>
+ <script src="resources/dom-particles.js"></script>
+</body>
+</html>
diff --git a/third_party/webkit/PerformanceTests/MotionMark/tests/dom/resources/compositing-transforms.js b/third_party/webkit/PerformanceTests/MotionMark/tests/dom/resources/compositing-transforms.js
new file mode 100644
index 0000000000..9fd401eeeb
--- /dev/null
+++ b/third_party/webkit/PerformanceTests/MotionMark/tests/dom/resources/compositing-transforms.js
@@ -0,0 +1,66 @@
+(function() {
+
+BouncingCompositedImage = 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);
+
+ if (stage.useFilters)
+ this.element.style.filter = "hue-rotate(" + Stage.randomAngle() + "rad)";
+
+ stage.element.appendChild(this.element);
+ this._move();
+ }, {
+
+ _move: function()
+ {
+ this.element.style.transform = "translate3d(" + this.position.x + "px," + this.position.y + "px, 0) " + this.rotater.rotateZ();
+ },
+
+ animate: function(timeDelta)
+ {
+ BouncingParticle.prototype.animate.call(this, timeDelta);
+ this._move();
+ }
+});
+
+CompositingTransformsStage = 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";
+ this.useFilters = options["filters"] == "yes";
+ },
+
+ createParticle: function()
+ {
+ return new BouncingCompositedImage(this);
+ },
+
+ particleWillBeRemoved: function(particle)
+ {
+ particle.element.remove();
+ }
+});
+
+CompositedTransformsBenchmark = Utilities.createSubclass(Benchmark,
+ function(options)
+ {
+ Benchmark.call(this, new CompositingTransformsStage(), options);
+ }
+);
+
+window.benchmarkClass = CompositedTransformsBenchmark;
+
+})();
diff --git a/third_party/webkit/PerformanceTests/MotionMark/tests/dom/resources/dom-particles.js b/third_party/webkit/PerformanceTests/MotionMark/tests/dom/resources/dom-particles.js
new file mode 100644
index 0000000000..471444b2e7
--- /dev/null
+++ b/third_party/webkit/PerformanceTests/MotionMark/tests/dom/resources/dom-particles.js
@@ -0,0 +1,73 @@
+(function() {
+
+DOMParticle = Utilities.createSubclass(Particle,
+ function(stage)
+ {
+ this.element = document.createElement("div");
+ stage.element.appendChild(this.element);
+
+ Particle.call(this, stage);
+ }, {
+
+ reset: function()
+ {
+ Particle.prototype.reset.call(this);
+
+ this.position = Stage.randomElementInArray(this.stage.emitLocation);
+
+ var angle = Stage.randomInt(0, this.stage.emitSteps) / this.stage.emitSteps * Math.PI * 2 + Stage.dateCounterValue(100) * this.stage.emissionSpin;
+ this.velocity = new Point(Math.sin(angle), Math.cos(angle))
+ .multiply(Stage.random(.5, 2.5));
+
+ this.element.style.width = this.size.x + "px";
+ this.element.style.height = this.size.y + "px";
+ this.stage.colorOffset = (this.stage.colorOffset + 1) % 360;
+ this.element.style.backgroundColor = "hsl(" + this.stage.colorOffset + ", 70%, 45%)";
+ },
+
+ move: function()
+ {
+ this.element.style.transform = "translate(" + this.position.x + "px, " + this.position.y + "px)" + this.rotater.rotateZ();
+ }
+});
+
+DOMParticleStage = Utilities.createSubclass(ParticlesStage,
+ function()
+ {
+ ParticlesStage.call(this);
+ }, {
+
+ initialize: function(benchmark)
+ {
+ ParticlesStage.prototype.initialize.call(this, benchmark);
+ this.emissionSpin = Stage.random(0, 3);
+ this.emitSteps = Stage.randomInt(4, 6);
+ this.emitLocation = [
+ new Point(this.size.x * .25, this.size.y * .333),
+ new Point(this.size.x * .5, this.size.y * .25),
+ new Point(this.size.x * .75, this.size.y * .333)
+ ];
+ this.colorOffset = Stage.randomInt(0, 359);
+ },
+
+ createParticle: function()
+ {
+ return new DOMParticle(this);
+ },
+
+ willRemoveParticle: function(particle)
+ {
+ particle.element.remove();
+ }
+});
+
+DOMParticleBenchmark = Utilities.createSubclass(Benchmark,
+ function(options)
+ {
+ Benchmark.call(this, new DOMParticleStage(), options);
+ }
+);
+
+window.benchmarkClass = DOMParticleBenchmark;
+
+})();
diff --git a/third_party/webkit/PerformanceTests/MotionMark/tests/dom/resources/focus.js b/third_party/webkit/PerformanceTests/MotionMark/tests/dom/resources/focus.js
new file mode 100644
index 0000000000..d7722cdff4
--- /dev/null
+++ b/third_party/webkit/PerformanceTests/MotionMark/tests/dom/resources/focus.js
@@ -0,0 +1,166 @@
+(function() {
+
+var maxVerticalOffset = 50;
+var minimumDiameter = 30;
+var centerDiameter = 90;
+var sizeVariance = 60;
+var travelDistance = 50;
+
+var opacityMultiplier = 30;
+
+var FocusElement = Utilities.createClass(
+ function(stage)
+ {
+ var size = minimumDiameter + sizeVariance;
+
+ // Size and blurring are a function of depth.
+ this._depth = Pseudo.random();
+ var distance = Utilities.lerp(this._depth, 0, sizeVariance);
+ size -= distance;
+
+ var top = Stage.random(0, stage.size.height - size) - stage.maxBlurValue * 3;
+ var left = Stage.random(0, stage.size.width - size) - stage.maxBlurValue * 3;
+
+ this.container = document.createElement('div');
+ this.container.style.width = (size + stage.maxBlurValue * 6) + "px";
+ this.container.style.height = (size + stage.maxBlurValue * 6) + "px";
+ this.container.style.top = top + "px";
+ this.container.style.left = left + "px";
+ this.container.style.zIndex = Math.round((1 - this._depth) * 10);
+
+ this.particle = Utilities.createElement("div", {}, this.container);
+ this.particle.style.width = size + "px";
+ this.particle.style.height = size + "px";
+ this.particle.style.top = (stage.maxBlurValue * 3) + "px";
+ this.particle.style.left = (stage.maxBlurValue * 3) + "px";
+
+ var depthMultiplier = Utilities.lerp(1 - this._depth, 0.8, 1);
+ this._sinMultiplier = Pseudo.random() * Stage.randomSign() * depthMultiplier * travelDistance;
+ this._cosMultiplier = Pseudo.random() * Stage.randomSign() * depthMultiplier * travelDistance;
+ }, {
+
+ hide: function()
+ {
+ this.container.style.display = "none";
+ },
+
+ show: function()
+ {
+ this.container.style.display = "block";
+ },
+
+ animate: function(stage, sinFactor, cosFactor)
+ {
+ var top = sinFactor * this._sinMultiplier;
+ var left = cosFactor * this._cosMultiplier;
+
+ Utilities.setElementPrefixedProperty(this.container, "filter", "blur(" + stage.getBlurValue(this._depth) + "px) opacity(" + stage.getOpacityValue(this._depth) + "%)");
+ this.container.style.transform = "translate3d(" + left + "%, " + top + "%, 0)";
+ }
+});
+
+var FocusStage = Utilities.createSubclass(Stage,
+ function()
+ {
+ Stage.call(this);
+ }, {
+
+ movementDuration: 2500,
+ focusDuration: 1000,
+
+ centerObjectDepth: 0.0,
+
+ minBlurValue: 1.5,
+ maxBlurValue: 15,
+ maxCenterObjectBlurValue: 5,
+
+ initialize: function(benchmark, options)
+ {
+ Stage.prototype.initialize.call(this, benchmark, options);
+
+ this._testElements = [];
+ this._focalPoint = 0.5;
+ this._offsetIndex = 0;
+
+ this._centerElement = document.getElementById("center-text");
+ this._centerElement.style.width = (centerDiameter + this.maxCenterObjectBlurValue * 6) + "px";
+ this._centerElement.style.height = (centerDiameter + this.maxCenterObjectBlurValue * 6) + "px";
+ this._centerElement.style.zIndex = Math.round(10 * this.centerObjectDepth);
+
+ var particle = document.querySelector("#center-text div");
+ particle.style.width = centerDiameter + "px";
+ particle.style.height = centerDiameter + "px";
+ particle.style.top = (this.maxCenterObjectBlurValue * 3) + "px";
+ particle.style.left = (this.maxCenterObjectBlurValue * 3) + "px";
+
+ var blur = this.getBlurValue(this.centerObjectDepth, true);
+ Utilities.setElementPrefixedProperty(this._centerElement, "filter", "blur(" + blur + "px)");
+ },
+
+ complexity: function()
+ {
+ return 1 + this._offsetIndex;
+ },
+
+ tune: function(count)
+ {
+ if (count == 0)
+ return;
+
+ if (count < 0) {
+ this._offsetIndex = Math.max(0, this._offsetIndex + count);
+ for (var i = this._offsetIndex; i < this._testElements.length; ++i)
+ this._testElements[i].hide();
+ return;
+ }
+
+ var newIndex = this._offsetIndex + count;
+ for (var i = this._testElements.length; i < newIndex; ++i) {
+ var obj = new FocusElement(this);
+ this._testElements.push(obj);
+ this.element.appendChild(obj.container);
+ }
+ for (var i = this._offsetIndex; i < newIndex; ++i)
+ this._testElements[i].show();
+ this._offsetIndex = newIndex;
+ },
+
+ animate: function()
+ {
+ var time = this._benchmark.timestamp;
+ var sinFactor = Math.sin(time / this.movementDuration);
+ var cosFactor = Math.cos(time / this.movementDuration);
+
+ var focusProgress = 0.5 + 0.5 * Math.sin(time / this.focusDuration);
+ this._focalPoint = focusProgress;
+
+ Utilities.setElementPrefixedProperty(this._centerElement, "filter", "blur(" + this.getBlurValue(this.centerObjectDepth, true) + "px)");
+
+ for (var i = 0; i < this._offsetIndex; ++i)
+ this._testElements[i].animate(this, sinFactor, cosFactor);
+ },
+
+ getBlurValue: function(depth, isCenter)
+ {
+ if (isCenter)
+ return 1 + Math.abs(depth - this._focalPoint) * (this.maxCenterObjectBlurValue - 1);
+
+ return Utilities.lerp(Math.abs(depth - this._focalPoint), this.minBlurValue, this.maxBlurValue);
+ },
+
+ getOpacityValue: function(depth)
+ {
+ return Math.max(1, opacityMultiplier * (1 - Math.abs(depth - this._focalPoint)));
+ },
+});
+
+var FocusBenchmark = Utilities.createSubclass(Benchmark,
+ function(options)
+ {
+ Benchmark.call(this, new FocusStage(), options);
+ }
+);
+
+window.benchmarkClass = FocusBenchmark;
+
+}());
diff --git a/third_party/webkit/PerformanceTests/MotionMark/tests/dom/resources/leaves.js b/third_party/webkit/PerformanceTests/MotionMark/tests/dom/resources/leaves.js
new file mode 100644
index 0000000000..604c973667
--- /dev/null
+++ b/third_party/webkit/PerformanceTests/MotionMark/tests/dom/resources/leaves.js
@@ -0,0 +1,48 @@
+Leaf = Utilities.createSubclass(Particle,
+ function(stage)
+ {
+ this.element = document.createElement("img");
+ this.element.setAttribute("src", Stage.randomElementInArray(stage.images).src);
+ stage.element.appendChild(this.element);
+
+ Particle.call(this, stage);
+ }, {
+
+ sizeMinimum: 20,
+ sizeRange: 40,
+
+ reset: function()
+ {
+ Particle.prototype.reset.call(this);
+ this.element.style.width = this.size.x + "px";
+ this.element.style.height = this.size.y + "px";
+ this._opacity = .01;
+ this._opacityRate = 0.02 * Stage.random(1, 6);
+ this._position = new Point(Stage.random(0, this.maxPosition.x), Stage.random(-this.size.height, this.maxPosition.y));
+ this._velocity = new Point(Stage.random(-6, -2), .1 * this.size.y + Stage.random(-1, 1));
+ },
+
+ animate: function(timeDelta)
+ {
+ this.rotater.next(timeDelta);
+
+ this._position.x += this._velocity.x + 8 * this.stage.focusX;
+ this._position.y += this._velocity.y;
+ this._opacity += this._opacityRate;
+ if (this._opacity > 1) {
+ this._opacity = 1;
+ this._opacityRate *= -1;
+ } else if (this._opacity < 0 || this._position.y > this.stage.size.height)
+ this.reset();
+
+ if (this._position.x < -this.size.width || this._position.x > this.stage.size.width)
+ this._position.x = this._position.x - Math.sign(this._position.x) * (this.size.width + this.stage.size.width);
+ this.move();
+ },
+
+ move: function()
+ {
+ this.element.style.transform = "translate(" + this._position.x + "px, " + this._position.y + "px)" + this.rotater.rotateZ();
+ this.element.style.opacity = this._opacity;
+ }
+});