Skip to content

Commit

Permalink
Restore support for non-integer devicePixelRatio
Browse files Browse the repository at this point in the history
  • Loading branch information
jfirebaugh committed Jul 17, 2017
1 parent 515c0b8 commit fa8f136
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/symbol/sprite_atlas.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ class SpriteAtlas extends Evented {
this.data = false;
this.texture = 0; // WebGL ID
this.filter = 0; // WebGL ID
this.width = width * browser.devicePixelRatio;
this.height = height * browser.devicePixelRatio;
this.width = Math.ceil(width * browser.devicePixelRatio);
this.height = Math.ceil(height * browser.devicePixelRatio);
this.shelfPack = new ShelfPack(this.width, this.height);
this.dirty = true;
}
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
{
"version": 8,
"metadata": {
"test": {
"width": 64,
"height": 64,
"pixelRatio": 1.1,
"operations": [
[
"addImage",
"marker",
"./image/marker.png"
],
[
"addLayer",
{
"id": "geometry",
"type": "symbol",
"source": "geometry",
"layout": {
"icon-image": "marker"
}
}
],
[
"wait"
]
]
}
},
"sources": {
"geometry": {
"type": "geojson",
"data": {
"type": "Point",
"coordinates": [0, 0]
}
}
},
"layers": []
}
5 changes: 3 additions & 2 deletions test/suite_implementation.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,9 @@ module.exports = function(style, options, _callback) {
options.operations = [["wait"]];
}
applyOperations(map, options.operations, () => {
const w = options.width * window.devicePixelRatio;
const h = options.height * window.devicePixelRatio;
const viewport = gl.getParameter(gl.VIEWPORT);
const w = viewport[2];
const h = viewport[3];

const pixels = new Uint8Array(w * h * 4);
gl.readPixels(0, 0, w, h, gl.RGBA, gl.UNSIGNED_BYTE, pixels);
Expand Down

0 comments on commit fa8f136

Please sign in to comment.