Skip to content

Commit

Permalink
only align raster sources to pixel grid when map is idle to prevent s…
Browse files Browse the repository at this point in the history
…haking
  • Loading branch information
Molly Lloyd committed Oct 16, 2018
1 parent 11b4228 commit 3bbdf03
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 3 deletions.
3 changes: 2 additions & 1 deletion src/render/draw_raster.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ function drawRaster(painter: Painter, sourceCache: SourceCache, layer: RasterSty
const stencilMode = StencilMode.disabled;
const colorMode = painter.colorModeForRenderPass();
const minTileZ = coords.length && coords[0].overscaledZ;
const align = !painter.options.moving && (Math.round(painter.transform.zoom) === painter.transform.zoom);

for (const coord of coords) {
// Set the lower zoom level to sublayer 0, and higher zoom levels to higher sublayers
Expand All @@ -36,7 +37,7 @@ function drawRaster(painter: Painter, sourceCache: SourceCache, layer: RasterSty
layer.paint.get('raster-opacity') === 1 ? DepthMode.ReadWrite : DepthMode.ReadOnly, gl.LESS);

const tile = sourceCache.getTile(coord);
const posMatrix = painter.transform.calculatePosMatrix(coord.toUnwrapped(), true);
const posMatrix = painter.transform.calculatePosMatrix(coord.toUnwrapped(), align);

tile.registerFadeDuration(layer.paint.get('raster-fade-duration'));

Expand Down
1 change: 1 addition & 0 deletions src/render/painter.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ type PainterOptions = {
showTileBoundaries: boolean,
rotating: boolean,
zooming: boolean,
moving: boolean,
fadeDuration: number
}

Expand Down
4 changes: 2 additions & 2 deletions src/render/program/hillshade_program.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,9 @@ const hillshadeUniformValues = (
if (layer.paint.get('hillshade-illumination-anchor') === 'viewport') {
azimuthal -= painter.transform.angle;
}

const align = !painter.options.moving && (Math.round(painter.transform.zoom) === painter.transform.zoom);
return {
'u_matrix': painter.transform.calculatePosMatrix(tile.tileID.toUnwrapped(), true),
'u_matrix': painter.transform.calculatePosMatrix(tile.tileID.toUnwrapped(), align),
'u_image': 0,
'u_latrange': getTileLatRange(painter, tile.tileID),
'u_light': [layer.paint.get('hillshade-exaggeration'), azimuthal],
Expand Down
1 change: 1 addition & 0 deletions src/ui/map.js
Original file line number Diff line number Diff line change
Expand Up @@ -1620,6 +1620,7 @@ class Map extends Camera {
showOverdrawInspector: this._showOverdrawInspector,
rotating: this.isRotating(),
zooming: this.isZooming(),
moving: this.isMoving(),
fadeDuration: this._fadeDuration
});

Expand Down

0 comments on commit 3bbdf03

Please sign in to comment.