Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Restore support for non-integer devicePixelRatio #4989

Merged
merged 2 commits into from
Jul 18, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions docs/_posts/examples/3400-01-31-add-image.html
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
style: 'mapbox://styles/mapbox/streets-v9'
});

map.on('load', () => {
map.loadImage('https://upload.wikimedia.org/wikipedia/commons/thumb/6/60/Cat_silhouette.svg/400px-Cat_silhouette.svg.png', (error, image) => {
map.on('load', function() {
map.loadImage('https://upload.wikimedia.org/wikipedia/commons/thumb/6/60/Cat_silhouette.svg/400px-Cat_silhouette.svg.png', function(error, image) {
if (error) throw error;
map.addImage('cat', image);
map.addLayer({
Expand Down
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