mapbox / mapbox-gl-js

Interactive, thoroughly customizable maps in the browser, powered by vector tiles and WebGL
https://docs.mapbox.com/mapbox-gl-js/
Other
11.2k stars 2.22k forks source link

Deduplicate images in sprite atlas #4775

Open nickidlugash opened 7 years ago

nickidlugash commented 7 years ago

@kkaefer and I chatted about the possibility of only adding unique sprite images to the atlas, and allowing multiple sprite names to reference the same location.

Spritezero can already generate spritesheets with unique sprite images only, with multiple sprite names referencing the same location on the spritesheet. If a style uses this spritesheet layout option, can we use this data to do something similar in the atlas? Or would we analyze all the images to dedup regardless of whether the spritesheet is deduped?

/cc @mapbox/gl-core

nickidlugash commented 7 years ago

@kkaefer also mentioned that we could do something similar for font stacks to avoid duplicate CJK glyphs in the atlas when multiple font stacks contain the same CJK fallback font.

kkaefer commented 7 years ago

An alternative implementation might also be to hash the content of every image, and deduplicate based on pixel identity rather than relying on information in the sprite sheet (that'd also be the approach we'd have to take for glyph atlas deduping).

nickidlugash commented 7 years ago

Main ticket for atlas improvements: https://github.com/mapbox/mapbox-gl-js/issues/141