Rename this.image to this._image

This commit is contained in:
Antoine Vandecreme 2015-11-09 17:57:39 -05:00
parent 760aaa7dca
commit 954cbbdc46

View File

@ -103,7 +103,7 @@
* @throws {Error} * @throws {Error}
*/ */
getImageInfo: function (url) { getImageInfo: function (url) {
var image = this.image = new Image(); var image = this._image = new Image();
var _this = this; var _this = this;
if (this.crossOriginPolicy) { if (this.crossOriginPolicy) {
@ -228,32 +228,32 @@
*/ */
_buildLevels: function () { _buildLevels: function () {
var levels = [{ var levels = [{
url: this.image.src, url: this._image.src,
width: this.image.naturalWidth, width: this._image.naturalWidth,
height: this.image.naturalHeight height: this._image.naturalHeight
}]; }];
if (!this.buildPyramid || !$.supportsCanvas || !this.useCanvas) { if (!this.buildPyramid || !$.supportsCanvas || !this.useCanvas) {
// We don't need the image anymore. Allows it to be GC. // We don't need the image anymore. Allows it to be GC.
delete this.image; delete this._image;
return levels; return levels;
} }
var currentWidth = this.image.naturalWidth; var currentWidth = this._image.naturalWidth;
var currentHeight = this.image.naturalHeight; var currentHeight = this._image.naturalHeight;
var bigCanvas = document.createElement("canvas"); var bigCanvas = document.createElement("canvas");
var bigContext = bigCanvas.getContext("2d"); var bigContext = bigCanvas.getContext("2d");
bigCanvas.width = currentWidth; bigCanvas.width = currentWidth;
bigCanvas.height = currentHeight; bigCanvas.height = currentHeight;
bigContext.drawImage(this.image, 0, 0, currentWidth, currentHeight); bigContext.drawImage(this._image, 0, 0, currentWidth, currentHeight);
// We cache the context of the highest level because the browser // We cache the context of the highest level because the browser
// is a lot faster at downsampling something it already has // is a lot faster at downsampling something it already has
// downsampled before. // downsampled before.
levels[0].context2D = bigContext; levels[0].context2D = bigContext;
// We don't need the image anymore. Allows it to be GC. // We don't need the image anymore. Allows it to be GC.
delete this.image; delete this._image;
if ($.isCanvasTainted(bigCanvas)) { if ($.isCanvasTainted(bigCanvas)) {
// If the canvas is tainted, we can't compute the pyramid. // If the canvas is tainted, we can't compute the pyramid.