Merge pull request #1539 from twpayne/vector-api-image-canvas-revision

[vector-api] Remember rendered revision in ol.source.ImageCanvas
This commit is contained in:
Tom Payne
2014-01-16 09:43:15 -08:00
2 changed files with 16 additions and 0 deletions

View File

@@ -35,6 +35,12 @@ ol.source.ImageCanvas = function(options) {
*/
this.canvas_ = null;
/**
* @private
* @type {number}
*/
this.renderedRevision_ = 0;
/**
* @private
* @type {number}
@@ -55,6 +61,7 @@ ol.source.ImageCanvas.prototype.getImage =
var canvas = this.canvas_;
if (!goog.isNull(canvas) &&
this.renderedRevision_ == this.getRevision() &&
canvas.getResolution() == resolution &&
canvas.getPixelRatio() == pixelRatio &&
ol.extent.containsExtent(canvas.getExtent(), extent)) {
@@ -74,6 +81,7 @@ ol.source.ImageCanvas.prototype.getImage =
this.getAttributions(), canvasElement);
}
this.canvas_ = canvas;
this.renderedRevision_ = this.getRevision();
return canvas;
};

View File

@@ -74,6 +74,12 @@ ol.source.ImageWMS = function(opt_options) {
*/
this.image_ = null;
/**
* @private
* @type {number}
*/
this.renderedRevision_ = 0;
/**
* @private
* @type {number}
@@ -112,6 +118,7 @@ ol.source.ImageWMS.prototype.getImage =
var image = this.image_;
if (!goog.isNull(image) &&
this.renderedRevision_ == this.getRevision() &&
image.getResolution() == resolution &&
image.getPixelRatio() == pixelRatio &&
ol.extent.containsExtent(image.getExtent(), extent)) {
@@ -190,6 +197,7 @@ ol.source.ImageWMS.prototype.getImage =
this.image_ = new ol.Image(extent, resolution, pixelRatio,
this.getAttributions(), url, this.crossOrigin_);
this.renderedRevision_ = this.getRevision();
return this.image_;
};