Skip to content

Commit b5b466f

Browse files
committed
Move Random methods out of Stage class
WebKit#54 This is a step towards making Stage and its sub-classes be ES6 classes. To do this the Random methods will be moved out of Stage class. A new class Random will be added to hold the random methods as static methods. This class will be put in a separate file. A production script can be used later to merge all the JS files in a single file.
1 parent f1c7edb commit b5b466f

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

57 files changed

+198
-316
lines changed

MotionMark/developer.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
<link rel="stylesheet" href="resources/runner/motionmark.css">
3434
<link rel="stylesheet" href="resources/debug-runner/motionmark.css">
3535

36+
<script src="extensions/random.js"></script>
3637
<script src="resources/strings.js"></script>
3738
<script src="resources/extensions.js"></script>
3839
<script src="resources/statistics.js"></script>

MotionMark/index.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232

3333
<link rel="stylesheet" href="resources/runner/motionmark.css">
3434

35+
<script src="extensions/random.js"></script>
3536
<script src="resources/strings.js" defer></script>
3637
<script src="resources/extensions.js" defer></script>
3738
<script src="resources/statistics.js" defer></script>

MotionMark/resources/statistics.js

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -22,29 +22,6 @@
2222
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
2323
* THE POSSIBILITY OF SUCH DAMAGE.
2424
*/
25-
Pseudo =
26-
{
27-
initialRandomSeed: 49734321,
28-
randomSeed: 49734321,
29-
30-
resetRandomSeed: function()
31-
{
32-
Pseudo.randomSeed = Pseudo.initialRandomSeed;
33-
},
34-
35-
random: function()
36-
{
37-
var randomSeed = Pseudo.randomSeed;
38-
randomSeed = ((randomSeed + 0x7ed55d16) + (randomSeed << 12)) & 0xffffffff;
39-
randomSeed = ((randomSeed ^ 0xc761c23c) ^ (randomSeed >>> 19)) & 0xffffffff;
40-
randomSeed = ((randomSeed + 0x165667b1) + (randomSeed << 5)) & 0xffffffff;
41-
randomSeed = ((randomSeed + 0xd3a2646c) ^ (randomSeed << 9)) & 0xffffffff;
42-
randomSeed = ((randomSeed + 0xfd7046c5) + (randomSeed << 3)) & 0xffffffff;
43-
randomSeed = ((randomSeed ^ 0xb55a4f09) ^ (randomSeed >>> 16)) & 0xffffffff;
44-
Pseudo.randomSeed = randomSeed;
45-
return (randomSeed & 0xfffffff) / 0x10000000;
46-
}
47-
};
4825

4926
Statistics =
5027
{

MotionMark/tests/3d/resources/webgl.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -136,12 +136,12 @@ WebGLStage = Utilities.createSubclass(Stage,
136136

137137
this._uniformData = new Float32Array(this._bufferSize * 6);
138138
for (var i = 0; i < this._bufferSize; ++i) {
139-
this._uniformData[i * 6 + 0] = Stage.random(0.2, 0.4);
139+
this._uniformData[i * 6 + 0] = Random.number(0.2, 0.4);
140140
this._uniformData[i * 6 + 1] = 0;
141-
this._uniformData[i * 6 + 2] = Stage.random(-0.9, 0.9);
142-
this._uniformData[i * 6 + 3] = Stage.random(-0.9, 0.9);
143-
this._uniformData[i * 6 + 4] = Stage.random(0.5, 2);
144-
this._uniformData[i * 6 + 5] = Stage.random(0, 10);
141+
this._uniformData[i * 6 + 2] = Random.number(-0.9, 0.9);
142+
this._uniformData[i * 6 + 3] = Random.number(-0.9, 0.9);
143+
this._uniformData[i * 6 + 4] = Random.number(0.5, 2);
144+
this._uniformData[i * 6 + 5] = Random.number(0, 10);
145145
}
146146
},
147147

@@ -163,8 +163,8 @@ WebGLStage = Utilities.createSubclass(Stage,
163163
gl.clear(gl.COLOR_BUFFER_BIT);
164164

165165
if (!this._startTime)
166-
this._startTime = Stage.dateCounterValue(1000);
167-
var elapsedTime = Stage.dateCounterValue(1000) - this._startTime;
166+
this._startTime = Random.dateCounterValue(1000);
167+
var elapsedTime = Random.dateCounterValue(1000) - this._startTime;
168168

169169
for (var i = 0; i < this._numTriangles; ++i) {
170170

MotionMark/tests/3d/resources/webgpu.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -206,11 +206,11 @@ WebGLStage = Utilities.createSubclass(Stage,
206206

207207
this._bindGroups = new Array(numTriangles);
208208
for (let i = 0; i < numTriangles; ++i) {
209-
uniformWriteArray[alignedUniformFloats * i + 0] = Stage.random(0.2, 0.4); // scale
210-
uniformWriteArray[alignedUniformFloats * i + 1] = Stage.random(-0.9, 0.9); // offsetX
211-
uniformWriteArray[alignedUniformFloats * i + 2] = Stage.random(-0.9, 0.9); // offsetY
212-
uniformWriteArray[alignedUniformFloats * i + 3] = Stage.random(0.5, 2); // scalar
213-
uniformWriteArray[alignedUniformFloats * i + 4] = Stage.random(0, 10); // scalarOffset
209+
uniformWriteArray[alignedUniformFloats * i + 0] = Random.number(0.2, 0.4); // scale
210+
uniformWriteArray[alignedUniformFloats * i + 1] = Random.number(-0.9, 0.9); // offsetX
211+
uniformWriteArray[alignedUniformFloats * i + 2] = Random.number(-0.9, 0.9); // offsetY
212+
uniformWriteArray[alignedUniformFloats * i + 3] = Random.number(0.5, 2); // scalar
213+
uniformWriteArray[alignedUniformFloats * i + 4] = Random.number(0, 10); // scalarOffset
214214

215215
this._bindGroups[i] = device.createBindGroup({
216216
layout: this._bindGroupLayout,
@@ -259,9 +259,9 @@ WebGLStage = Utilities.createSubclass(Stage,
259259
const device = this._device;
260260

261261
if (!this._startTime)
262-
this._startTime = Stage.dateCounterValue(1000);
262+
this._startTime = Random.dateCounterValue(1000);
263263

264-
const elapsedTimeData = new Float32Array([Stage.dateCounterValue(1000) - this._startTime]);
264+
const elapsedTimeData = new Float32Array([Random.dateCounterValue(1000) - this._startTime]);
265265

266266
// Update time uniform
267267
let mappedBuffer;

MotionMark/tests/3d/triangles-webgl.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@
8383
gl_FragColor = v_color;
8484
}
8585
</script>
86+
<script src="../../extensions/random.js"></script>
8687
<script src="../../resources/strings.js"></script>
8788
<script src="../../resources/extensions.js"></script>
8889
<script src="../../resources/statistics.js"></script>

MotionMark/tests/3d/triangles-webgpu.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
</head>
3636
<body>
3737
<canvas id="stage"></canvas>
38+
<script src="../../extensions/random.js"></script>
3839
<script src="../../resources/strings.js"></script>
3940
<script src="../../resources/extensions.js"></script>
4041
<script src="../../resources/statistics.js"></script>

MotionMark/tests/bouncing-particles/bouncing-canvas-images.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
<img class="hidden" src="../resources/yin-yang.svg">
3939
<img class="hidden" src="../resources/yin-yang.png">
4040
<canvas id="stage"></canvas>
41+
<script src="../../extensions/random.js"></script>
4142
<script src="../../resources/strings.js"></script>
4243
<script src="../../resources/extensions.js"></script>
4344
<script src="../../resources/statistics.js"></script>

MotionMark/tests/bouncing-particles/bouncing-canvas-shapes.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
</head>
3131
<body>
3232
<canvas id="stage"></canvas>
33+
<script src="../../extensions/random.js"></script>
3334
<script src="../../resources/strings.js"></script>
3435
<script src="../../resources/extensions.js"></script>
3536
<script src="../../resources/statistics.js"></script>

MotionMark/tests/bouncing-particles/bouncing-css-images.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
</head>
3636
<body>
3737
<div id="stage"></div>
38+
<script src="../../extensions/random.js"></script>
3839
<script src="../../resources/strings.js"></script>
3940
<script src="../../resources/extensions.js"></script>
4041
<script src="../../resources/statistics.js"></script>

0 commit comments

Comments
 (0)