Skip to content

Commit bddc3b7

Browse files
committed
Make the Stage fill the screen, and scale Canvas size to pixel units
1 parent 806c1df commit bddc3b7

File tree

7 files changed

+28
-3
lines changed

7 files changed

+28
-3
lines changed

MotionMark/resources/runner/motionmark.css

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -387,8 +387,10 @@ body.images-loaded #intro {
387387
.frame-container {
388388
position: absolute;
389389

390+
/*
390391
top: 50%;
391392
left: 50%;
393+
*/
392394
}
393395

394396
.frame-container > iframe {
@@ -400,24 +402,36 @@ body.images-loaded #intro {
400402
}
401403

402404
body.small .frame-container {
405+
/*
403406
width: 568px;
404407
height: 320px;
405408
margin-left: -284px;
406409
margin-top: -160px;
410+
*/
411+
width: 100%;
412+
height: 100%;
407413
}
408414

409415
body.medium .frame-container {
416+
/*
410417
width: 900px;
411418
height: 600px;
412419
margin-left: -450px;
413420
margin-top: -300px;
421+
*/
422+
width: 100%;
423+
height: 100%;
414424
}
415425

416426
body.large .frame-container {
427+
/*
417428
width: 1600px;
418429
height: 800px;
419430
margin-left: -800px;
420431
margin-top: -400px;
432+
*/
433+
width: 100%;
434+
height: 100%;
421435
}
422436

423437
/* Results section */

MotionMark/tests/bouncing-particles/resources/bouncing-canvas-particles.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,7 @@ class BouncingCanvasParticlesStage extends BouncingParticlesStage {
9797
{
9898
await super.initialize(benchmark, options);
9999
this.context = this.element.getContext("2d");
100+
this.context.scale(this.devicePixelRatio, this.devicePixelRatio);
100101
}
101102

102103
animate(timeDelta)

MotionMark/tests/core/resources/canvas-stage.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ class CanvasStage extends Stage {
3636
{
3737
await super.initialize(benchmark, options);
3838
this.context = this.element.getContext("2d");
39+
this.context.scale(this.devicePixelRatio, this.devicePixelRatio);
3940
}
4041

4142
tune(count)

MotionMark/tests/core/resources/image-data.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,7 @@ class ImageDataStage extends Stage {
132132
for (var i = 0; i < this._offsetIndex; ++i) {
133133
var element = this.testElements[i];
134134
var context = element.getContext("2d");
135+
context.scale(this.devicePixelRatio, this.devicePixelRatio);
135136

136137
// Get image data
137138
var imageData = context.getImageData(0, 0, ImageDataStage.imageWidth, ImageDataStage.imageHeight);
@@ -158,7 +159,9 @@ class ImageDataStage extends Stage {
158159
context.putImageData(imageData, 0, 0);
159160
else {
160161
this._refreshElement(element);
161-
element.getContext("2d").drawImage(Stage.randomElementInArray(this.images), 0, 0, ImageDataStage.imageWidth, ImageDataStage.imageHeight);
162+
const context = element.getContext("2d");
163+
context.scale(this.devicePixelRatio, this.devicePixelRatio);
164+
context.drawImage(Stage.randomElementInArray(this.images), 0, 0, ImageDataStage.imageWidth, ImageDataStage.imageHeight);
162165
}
163166
}
164167
}

MotionMark/tests/resources/stage.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,9 +66,13 @@ class Stage {
6666
{
6767
this._benchmark = benchmark;
6868
this._element = document.getElementById("stage");
69-
this._element.setAttribute("width", document.body.offsetWidth);
70-
this._element.setAttribute("height", document.body.offsetHeight);
69+
70+
const devicePixelRatio = window.devicePixelRatio || 1;
71+
this._element.width = document.body.offsetWidth * devicePixelRatio;
72+
this._element.height = document.body.offsetHeight * devicePixelRatio;
73+
7174
this._size = GeometryHelpers.elementClientSize(this._element).subtract(Insets.elementPadding(this._element).size);
75+
this.devicePixelRatio = devicePixelRatio;
7276
}
7377

7478
get element()

MotionMark/tests/simple/resources/tiled-canvas-image.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ class TiledCanvasImageStage extends Stage {
5252
{
5353
await super.initialize(benchmark, options);
5454
this.context = this.element.getContext("2d");
55+
this.context.scale(this.devicePixelRatio, this.devicePixelRatio);
5556
this._setupTiles();
5657
}
5758

MotionMark/tests/template/resources/template-canvas.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ class TemplateCanvasStage extends Stage {
5757
{
5858
await super.initialize(benchmark, options);
5959
this.context = this.element.getContext("2d");
60+
this.context.scale(this.devicePixelRatio, this.devicePixelRatio);
6061
// Define a collection for your objects.
6162
// await any async work (e.g. image loading).
6263
}

0 commit comments

Comments
 (0)