Skip to content

Commit

Permalink
Ensure images always fade in completely, remove "raster-fade-duration"
Browse files Browse the repository at this point in the history
  • Loading branch information
Lucas Wojciechowski committed Nov 3, 2016
1 parent 401089b commit e3711c2
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
5 changes: 2 additions & 3 deletions js/render/draw_raster.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ function drawRasterTile(painter, sourceCache, layer, coord) {
gl.uniform3fv(program.u_spin_weights, spinWeights(layer.paint['raster-hue-rotate']));

const parentTile = tile.sourceCache && tile.sourceCache.findLoadedParent(coord, 0, {}),
opacities = getOpacities(tile, parentTile, layer, painter.transform);
opacities = getOpacities(tile, parentTile, layer, painter.transform, painter.style.rasterFadeDuration);

let parentScaleBy, parentTL;

Expand Down Expand Up @@ -103,9 +103,8 @@ function saturationFactor(saturation) {
-saturation;
}

function getOpacities(tile, parentTile, layer, transform) {
function getOpacities(tile, parentTile, layer, transform, fadeDuration) {
const opacities = [1, 0];
const fadeDuration = layer.paint['raster-fade-duration'];

if (tile.sourceCache && fadeDuration > 0) {
const now = Date.now();
Expand Down
2 changes: 2 additions & 0 deletions js/source/image_source.js
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,8 @@ class ImageSource extends Evented {
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.LINEAR);
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.LINEAR);
gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, gl.RGBA, gl.UNSIGNED_BYTE, image);
this.map.animationLoop.set(this.tile.timeAdded + this.map.style.rasterFadeDuration - Date.now());

} else if (image instanceof window.HTMLVideoElement) {
gl.bindTexture(gl.TEXTURE_2D, this.tile.texture);
gl.texSubImage2D(gl.TEXTURE_2D, 0, 0, 0, gl.RGBA, gl.UNSIGNED_BYTE, image);
Expand Down

0 comments on commit e3711c2

Please sign in to comment.