Duck type img
This commit is contained in:
parent
c601e020b7
commit
ce814e8a71
1 changed files with 19 additions and 31 deletions
|
@ -63,34 +63,7 @@ PIXI.BaseTexture = function(source, scaleMode)
|
||||||
|
|
||||||
if(!source)return;
|
if(!source)return;
|
||||||
|
|
||||||
if(this.source instanceof Image || this.source instanceof HTMLImageElement)
|
if(this.source.complete || this.source.getContext)
|
||||||
{
|
|
||||||
if(this.source.complete)
|
|
||||||
{
|
|
||||||
this.hasLoaded = true;
|
|
||||||
this.width = this.source.width;
|
|
||||||
this.height = this.source.height;
|
|
||||||
|
|
||||||
PIXI.texturesToUpdate.push(this);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
|
|
||||||
var scope = this;
|
|
||||||
this.source.onload = function() {
|
|
||||||
|
|
||||||
scope.hasLoaded = true;
|
|
||||||
scope.width = scope.source.width;
|
|
||||||
scope.height = scope.source.height;
|
|
||||||
|
|
||||||
// add it to somewhere...
|
|
||||||
PIXI.texturesToUpdate.push(scope);
|
|
||||||
scope.dispatchEvent( { type: 'loaded', content: scope } );
|
|
||||||
};
|
|
||||||
//this.image.src = imageUrl;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
{
|
||||||
this.hasLoaded = true;
|
this.hasLoaded = true;
|
||||||
this.width = this.source.width;
|
this.width = this.source.width;
|
||||||
|
@ -98,6 +71,22 @@ PIXI.BaseTexture = function(source, scaleMode)
|
||||||
|
|
||||||
PIXI.texturesToUpdate.push(this);
|
PIXI.texturesToUpdate.push(this);
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
|
||||||
|
var scope = this;
|
||||||
|
this.source.onload = function() {
|
||||||
|
|
||||||
|
scope.hasLoaded = true;
|
||||||
|
scope.width = scope.source.width;
|
||||||
|
scope.height = scope.source.height;
|
||||||
|
|
||||||
|
// add it to somewhere...
|
||||||
|
PIXI.texturesToUpdate.push(scope);
|
||||||
|
scope.dispatchEvent( { type: 'loaded', content: scope } );
|
||||||
|
};
|
||||||
|
//this.image.src = imageUrl;
|
||||||
|
}
|
||||||
|
|
||||||
this.imageUrl = null;
|
this.imageUrl = null;
|
||||||
this._powerOf2 = false;
|
this._powerOf2 = false;
|
||||||
|
@ -117,10 +106,9 @@ PIXI.BaseTexture.prototype.constructor = PIXI.BaseTexture;
|
||||||
*/
|
*/
|
||||||
PIXI.BaseTexture.prototype.destroy = function()
|
PIXI.BaseTexture.prototype.destroy = function()
|
||||||
{
|
{
|
||||||
if(this.source instanceof Image)
|
if(this.imageUrl)
|
||||||
{
|
{
|
||||||
if (this.imageUrl in PIXI.BaseTextureCache)
|
delete PIXI.BaseTextureCache[this.imageUrl];
|
||||||
delete PIXI.BaseTextureCache[this.imageUrl];
|
|
||||||
this.imageUrl = null;
|
this.imageUrl = null;
|
||||||
this.source.src = null;
|
this.source.src = null;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue