Adding check to see if already loaded images taints the canvas

This commit is contained in:
Måns Beckman
2015-09-23 19:38:12 +02:00
parent dd8422c8a0
commit 0a28c4282e
+2 -2
View File
@@ -426,7 +426,7 @@ ol.style.IconImage_ = function(image, src, size, crossOrigin, imageState) {
* @type {boolean} * @type {boolean}
*/ */
this.tainting_ = false; this.tainting_ = false;
if (this.imageState_ == ol.style.ImageState.LOADED)this.determineTainting_();
}; };
goog.inherits(ol.style.IconImage_, goog.events.EventTarget); goog.inherits(ol.style.IconImage_, goog.events.EventTarget);
@@ -456,8 +456,8 @@ ol.style.IconImage_.get = function(image, src, size, crossOrigin, imageState) {
*/ */
ol.style.IconImage_.prototype.determineTainting_ = function() { ol.style.IconImage_.prototype.determineTainting_ = function() {
var context = ol.dom.createCanvasContext2D(1, 1); var context = ol.dom.createCanvasContext2D(1, 1);
context.drawImage(this.image_, 0, 0);
try { try {
context.drawImage(this.image_, 0, 0);
context.getImageData(0, 0, 1, 1); context.getImageData(0, 0, 1, 1);
} catch (e) { } catch (e) {
this.tainting_ = true; this.tainting_ = true;