Don't generate new tiles while animating

This commit is contained in:
Tim Schaub
2013-02-06 17:47:03 -07:00
parent 4e971b6041
commit 11b8c0ff47
2 changed files with 13 additions and 7 deletions
+1 -1
View File
@@ -27,7 +27,7 @@
} }
} }
</style> </style>
<title>Full-screen example</title> <title>Vector Layer Example</title>
</head> </head>
<body> <body>
<div id="map"> <div id="map">
@@ -220,7 +220,7 @@ ol.renderer.canvas.VectorLayer.prototype.renderFrame =
*/ */
if (!this.dirty_ && this.renderedResolution_ === tileResolution && if (!this.dirty_ && this.renderedResolution_ === tileResolution &&
// TODO: extent.equals() // TODO: extent.equals()
this.renderedResolution_.toString() === tileRangeExtent.toString()) { this.renderedExtent_.toString() === tileRangeExtent.toString()) {
return; return;
} }
@@ -283,7 +283,7 @@ ol.renderer.canvas.VectorLayer.prototype.renderFrame =
tileCoord = new ol.TileCoord(z, x, y); tileCoord = new ol.TileCoord(z, x, y);
key = tileCoord.toString(); key = tileCoord.toString();
tile = this.tileCache_[key]; tile = this.tileCache_[key];
if (tile === undefined) { if (tile === undefined && !frameState.viewHints[ol.ViewHint.ANIMATING]) {
tileExtent = tileGrid.getTileCoordExtent(tileCoord); tileExtent = tileGrid.getTileCoordExtent(tileCoord);
// TODO: instead of filtering here, do this on the source and maintain // TODO: instead of filtering here, do this on the source and maintain
// a spatial index // a spatial index
@@ -320,7 +320,7 @@ ol.renderer.canvas.VectorLayer.prototype.renderFrame =
// LRU - move tile key to the end of the index // LRU - move tile key to the end of the index
goog.array.remove(this.tileCacheIndex_, key); goog.array.remove(this.tileCacheIndex_, key);
this.tileCacheIndex_.push(key); this.tileCacheIndex_.push(key);
if (tile === undefined) { if (tile === undefined && !frameState.viewHints[ol.ViewHint.ANIMATING]) {
tile = /** @type {HTMLCanvasElement} */ tile = /** @type {HTMLCanvasElement} */
this.tileArchetype_.cloneNode(false); this.tileArchetype_.cloneNode(false);
tile.getContext('2d').drawImage(sketchCanvas, tile.getContext('2d').drawImage(sketchCanvas,
@@ -333,12 +333,18 @@ ol.renderer.canvas.VectorLayer.prototype.renderFrame =
delete this.tileCache_[this.tileCacheIndex_.shift()]; delete this.tileCache_[this.tileCacheIndex_.shift()];
} }
} }
finalContext.drawImage(tile, if (tile) {
tileSize.width * (tileCoord.x - tileRange.minX), finalContext.drawImage(tile,
tileSize.height * (tileRange.maxY - tileCoord.y)); tileSize.width * (tileCoord.x - tileRange.minX),
tileSize.height * (tileRange.maxY - tileCoord.y));
} else {
// we decided not to generate a tile during animation
this.dirty_ = true;
}
} }
this.renderedResolution_ = tileResolution; this.renderedResolution_ = tileResolution;
this.renderedExtent_ = tileRangeExtent;
}; };