Merge pull request #7136 from ahocevar/empty-image
Use data URI instead of whole empty image
This commit is contained in:
@@ -60,7 +60,7 @@ ol.inherits(ol.ImageTile, ol.Tile);
|
||||
ol.ImageTile.prototype.disposeInternal = function() {
|
||||
if (this.state == ol.TileState.LOADING) {
|
||||
this.unlistenImage_();
|
||||
this.image_.src = ol.ImageTile.blankImage.toDataURL('image/png');
|
||||
this.image_.src = ol.ImageTile.blankImageUrl;
|
||||
}
|
||||
if (this.interimTile) {
|
||||
this.interimTile.dispose();
|
||||
@@ -97,7 +97,7 @@ ol.ImageTile.prototype.getKey = function() {
|
||||
ol.ImageTile.prototype.handleImageError_ = function() {
|
||||
this.state = ol.TileState.ERROR;
|
||||
this.unlistenImage_();
|
||||
this.image_ = ol.ImageTile.blankImage;
|
||||
this.image_.src = ol.ImageTile.blankImageUrl;
|
||||
this.changed();
|
||||
};
|
||||
|
||||
@@ -149,12 +149,12 @@ ol.ImageTile.prototype.unlistenImage_ = function() {
|
||||
|
||||
|
||||
/**
|
||||
* A blank image.
|
||||
* @type {HTMLCanvasElement}
|
||||
* Data URI for a blank image.
|
||||
* @type {string}
|
||||
*/
|
||||
ol.ImageTile.blankImage = (function() {
|
||||
ol.ImageTile.blankImageUrl = (function() {
|
||||
var ctx = ol.dom.createCanvasContext2D(1, 1);
|
||||
ctx.fillStyle = 'rgba(0,0,0,0)';
|
||||
ctx.fillRect(0, 0, 1, 1);
|
||||
return ctx.canvas;
|
||||
return ctx.canvas.toDataURL('image/png');
|
||||
})();
|
||||
|
||||
@@ -72,7 +72,7 @@ describe('ol.ImageTile', function() {
|
||||
var state = tile.getState();
|
||||
if (state == ol.TileState.ERROR) {
|
||||
expect(state).to.be(ol.TileState.ERROR);
|
||||
expect(tile.image_).to.be(ol.ImageTile.blankImage);
|
||||
expect(tile.image_.src).to.be(ol.ImageTile.blankImageUrl);
|
||||
done();
|
||||
}
|
||||
});
|
||||
@@ -94,7 +94,7 @@ describe('ol.ImageTile', function() {
|
||||
expect(tile.getState()).to.be(ol.TileState.LOADING);
|
||||
tile.dispose();
|
||||
expect(tile.getState()).to.be(ol.TileState.ABORT);
|
||||
expect(tile.getImage().src).to.be(ol.ImageTile.blankImage.toDataURL('image/png'));
|
||||
expect(tile.getImage().src).to.be(ol.ImageTile.blankImageUrl);
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user