Rename textureCache to tileTextureCache

This commit is contained in:
Tom Payne
2012-07-17 22:56:31 +02:00
parent 7dc2884498
commit db59dfd5a2
2 changed files with 10 additions and 9 deletions

View File

@@ -128,7 +128,7 @@ ol.webgl.Map = function(target, opt_values) {
* @private * @private
* @type {Object.<string, WebGLTexture>} * @type {Object.<string, WebGLTexture>}
*/ */
this.textureCache_ = {}; this.tileTextureCache_ = {};
/** /**
* @private * @private
@@ -185,7 +185,7 @@ ol.webgl.Map.prototype.disposeInternal = function() {
goog.object.forEach(this.shaderCache_, function(shader) { goog.object.forEach(this.shaderCache_, function(shader) {
gl.deleteShader(shader); gl.deleteShader(shader);
}); });
goog.object.forEach(this.textureCache_, function(texture) { goog.object.forEach(this.tileTextureCache_, function(texture) {
gl.deleteTexture(texture); gl.deleteTexture(texture);
}); });
} }
@@ -256,12 +256,13 @@ ol.webgl.Map.prototype.getShader = function(shaderObject) {
/** /**
* @param {Image} image Image. * @param {ol.Tile} tile Tile.
* @return {WebGLTexture} Texture. * @return {WebGLTexture} Texture.
*/ */
ol.webgl.Map.prototype.getTexture = function(image) { ol.webgl.Map.prototype.getTileTexture = function(tile) {
if (image.src in this.textureCache_) { var image = tile.getImage();
return this.textureCache_[image.src]; if (image.src in this.tileTextureCache_) {
return this.tileTextureCache_[image.src];
} else { } else {
var gl = this.getGL(); var gl = this.getGL();
var texture = gl.createTexture(); var texture = gl.createTexture();
@@ -276,7 +277,7 @@ ol.webgl.Map.prototype.getTexture = function(image) {
goog.webgl.CLAMP_TO_EDGE); goog.webgl.CLAMP_TO_EDGE);
gl.texParameteri(goog.webgl.TEXTURE_2D, goog.webgl.TEXTURE_WRAP_T, gl.texParameteri(goog.webgl.TEXTURE_2D, goog.webgl.TEXTURE_WRAP_T,
goog.webgl.CLAMP_TO_EDGE); goog.webgl.CLAMP_TO_EDGE);
this.textureCache_[image.src] = texture; this.tileTextureCache_[image.src] = texture;
return texture; return texture;
} }
}; };
@@ -361,7 +362,7 @@ ol.webgl.Map.prototype.handleWebGLContextLost = function(event) {
event.preventDefault(); event.preventDefault();
this.shaderCache_ = {}; this.shaderCache_ = {};
this.programCache_ = {}; this.programCache_ = {};
this.textureCache_ = {}; this.tileTextureCache_ = {};
goog.object.forEach(this.layerRenderers, function(layerRenderer) { goog.object.forEach(this.layerRenderers, function(layerRenderer) {
layerRenderer.handleWebGLContextLost(); layerRenderer.handleWebGLContextLost();
}); });

View File

@@ -305,7 +305,7 @@ ol.webgl.TileLayerRenderer.prototype.redraw = function() {
2 / tileBoundsSize.height, 2 / tileBoundsSize.height,
1); 1);
gl.uniformMatrix4fv(this.locations_.uMatrix, false, uMatrix); gl.uniformMatrix4fv(this.locations_.uMatrix, false, uMatrix);
gl.bindTexture(goog.webgl.TEXTURE_2D, map.getTexture(tile.getImage())); gl.bindTexture(goog.webgl.TEXTURE_2D, map.getTileTexture(tile));
gl.activeTexture(goog.webgl.TEXTURE0); gl.activeTexture(goog.webgl.TEXTURE0);
gl.drawArrays(goog.webgl.TRIANGLE_STRIP, 0, 4); gl.drawArrays(goog.webgl.TRIANGLE_STRIP, 0, 4);
} else { } else {