Skip to content

Commit

Permalink
don't render changes made after canvasSource.pause()
Browse files Browse the repository at this point in the history
  • Loading branch information
ansis committed Apr 10, 2019
1 parent 6f8feba commit 95dc749
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 7 deletions.
10 changes: 5 additions & 5 deletions src/source/canvas_source.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,6 @@ class CanvasSource extends ImageSource {
play: () => void;
pause: () => void;
_playing: boolean;
_dirty: boolean;

/**
* @private
Expand Down Expand Up @@ -131,8 +130,10 @@ class CanvasSource extends ImageSource {
};

this.pause = function() {
this._playing = false;
this._dirty = true;
if (this._playing) {
this.prepare();
this._playing = false;
}
};

this._finishLoading();
Expand Down Expand Up @@ -201,9 +202,8 @@ class CanvasSource extends ImageSource {

if (!this.texture) {
this.texture = new Texture(context, this.canvas, gl.RGBA, { premultiply: true });
} else if (resize || this._playing || this._dirty) {
} else if (resize || this._playing) {
this.texture.update(this.canvas, { premultiply: true });
this._dirty = false;
}

for (const w in this.tiles) {
Expand Down
2 changes: 1 addition & 1 deletion test/integration/render-tests/canvas/update/style.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
},
"operations": [
["wait"],
["updateFakeCanvas", "canvas", "./image/1.png"]
["updateFakeCanvas", "canvas", "./image/1.png", "./image/0.png"]
]
}
},
Expand Down
5 changes: 4 additions & 1 deletion test/suite_implementation.js
Original file line number Diff line number Diff line change
Expand Up @@ -158,10 +158,13 @@ module.exports = function(style, options, _callback) { // eslint-disable-line im
map._render();
applyOperations(map, operations.slice(1), callback);
} else if (operation[0] === 'updateFakeCanvas') {
updateFakeCanvas(window.document, options.addFakeCanvas.id, operation[2]);
const canvasSource = map.getSource(operation[1]);
canvasSource.play();
// update before pause should be rendered
updateFakeCanvas(window.document, options.addFakeCanvas.id, operation[2]);
canvasSource.pause();
// update after pause should not be rendered
updateFakeCanvas(window.document, options.addFakeCanvas.id, operation[3]);
map._render();
applyOperations(map, operations.slice(1), callback);
} else if (operation[0] === 'setStyle') {
Expand Down

0 comments on commit 95dc749

Please sign in to comment.