Skip to content

Commit

Permalink
Upgrade shelf-pack and shrink atlases to final size
Browse files Browse the repository at this point in the history
  • Loading branch information
jfirebaugh committed Aug 29, 2017
1 parent 4919476 commit 363fc47
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 14 deletions.
1 change: 1 addition & 0 deletions flow-typed/shelf-pack.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ declare module "@mapbox/shelf-pack" {

pack(bins: Array<{w: number, h: number}>, options?: {inPlace: boolean}): Array<Bin>;
packOne(w: number, h: number, id?: number|string): Bin;
shrink(): void;

ref(bin: Bin): number;
unref(bin: Bin): number;
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"dependencies": {
"@mapbox/gl-matrix": "^0.0.1",
"@mapbox/point-geometry": "^0.1.0",
"@mapbox/shelf-pack": "^3.0.0",
"@mapbox/shelf-pack": "^3.1.0",
"@mapbox/tiny-sdf": "^1.1.0",
"@mapbox/unitbezier": "^0.0.0",
"@mapbox/vector-tile": "^1.3.0",
Expand Down
10 changes: 5 additions & 5 deletions src/render/glyph_atlas.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,11 +61,11 @@ function makeGlyphAtlas(stacks: {[string]: {[number]: ?StyleGlyph}}): GlyphAtlas
}
}

// pack.shrink();
// resizeAlphaImage(image, {
// width: pack.w,
// height: pack.h
// });
pack.shrink();
AlphaImage.resize(image, {
width: pack.w,
height: pack.h
});

return {image, positions};
}
Expand Down
10 changes: 5 additions & 5 deletions src/render/image_atlas.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,11 +86,11 @@ function makeImageAtlas(images: {[string]: StyleImage}): ImageAtlas {
positions[id] = imagePosition(bin, src);
}

// pack.shrink();
// resizeImageData(image, {
// width: pack.w,
// height: pack.h
// });
pack.shrink();
RGBAImage.resize(image, {
width: pack.w,
height: pack.h
});

return {image, positions};
}
Expand Down
1 change: 1 addition & 0 deletions src/render/texture.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ class Texture {

const {gl} = this;
gl.bindTexture(gl.TEXTURE_2D, this.texture);
gl.pixelStorei(gl.UNPACK_ALIGNMENT, 1);

if (this.format === gl.RGBA) {
gl.pixelStorei(gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL, (true: any));
Expand Down
6 changes: 3 additions & 3 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@
version "0.1.0"
resolved "https://registry.yarnpkg.com/@mapbox/point-geometry/-/point-geometry-0.1.0.tgz#8a83f9335c7860effa2eeeca254332aa0aeed8f2"

"@mapbox/shelf-pack@^3.0.0":
version "3.0.0"
resolved "https://registry.yarnpkg.com/@mapbox/shelf-pack/-/shelf-pack-3.0.0.tgz#44e284c8336eeda1e9dbbb1d61954c70e26e5766"
"@mapbox/shelf-pack@^3.1.0":
version "3.1.0"
resolved "https://registry.yarnpkg.com/@mapbox/shelf-pack/-/shelf-pack-3.1.0.tgz#1edea9c0bf6715b217171ba60646c201af520f6a"

"@mapbox/tiny-sdf@^1.1.0":
version "1.1.0"
Expand Down

0 comments on commit 363fc47

Please sign in to comment.