diff --git a/src/core/sprites/Sprite.js b/src/core/sprites/Sprite.js index 291dbc9..6a60a81 100644 --- a/src/core/sprites/Sprite.js +++ b/src/core/sprites/Sprite.js @@ -91,9 +91,9 @@ // call texture setter this.texture = texture || Texture.EMPTY; - this.textureDirty = true; this.vertexData = new Float32Array(16); this._transformID = -1; + this._textureID = -1; } // constructor @@ -161,7 +161,7 @@ this._texture = value; this.cachedTint = 0xFFFFFF; - this.textureDirty = true; + this._textureID = -1; if (value) { @@ -186,7 +186,7 @@ */ Sprite.prototype._onTextureUpdate = function () { - this.textureDirty = true; + this._textureID = -1; // so if _width is 0 then width was not set.. if (this._width) @@ -210,13 +210,13 @@ */ Sprite.prototype.calculateVertices = function () { - if(this._transformID === this.transform._worldID && !this.textureDirty) + if(this._transformID === this.transform._worldID && this._textureID === this._texture._updateID) { return; } this._transformID = this.transform._worldID; - this.textureDirty = false; + this._textureID = this._texture._updateID; // set the vertex data diff --git a/src/core/sprites/Sprite.js b/src/core/sprites/Sprite.js index 291dbc9..6a60a81 100644 --- a/src/core/sprites/Sprite.js +++ b/src/core/sprites/Sprite.js @@ -91,9 +91,9 @@ // call texture setter this.texture = texture || Texture.EMPTY; - this.textureDirty = true; this.vertexData = new Float32Array(16); this._transformID = -1; + this._textureID = -1; } // constructor @@ -161,7 +161,7 @@ this._texture = value; this.cachedTint = 0xFFFFFF; - this.textureDirty = true; + this._textureID = -1; if (value) { @@ -186,7 +186,7 @@ */ Sprite.prototype._onTextureUpdate = function () { - this.textureDirty = true; + this._textureID = -1; // so if _width is 0 then width was not set.. if (this._width) @@ -210,13 +210,13 @@ */ Sprite.prototype.calculateVertices = function () { - if(this._transformID === this.transform._worldID && !this.textureDirty) + if(this._transformID === this.transform._worldID && this._textureID === this._texture._updateID) { return; } this._transformID = this.transform._worldID; - this.textureDirty = false; + this._textureID = this._texture._updateID; // set the vertex data diff --git a/src/core/text/Text.js b/src/core/text/Text.js index 4e21f7f..ad60a2e 100644 --- a/src/core/text/Text.js +++ b/src/core/text/Text.js @@ -410,9 +410,6 @@ texture.baseTexture.emit('update', texture.baseTexture); - // make sure to flag the texture as dirty.. - this.textureDirty = true; - this.dirty = false; }; diff --git a/src/core/sprites/Sprite.js b/src/core/sprites/Sprite.js index 291dbc9..6a60a81 100644 --- a/src/core/sprites/Sprite.js +++ b/src/core/sprites/Sprite.js @@ -91,9 +91,9 @@ // call texture setter this.texture = texture || Texture.EMPTY; - this.textureDirty = true; this.vertexData = new Float32Array(16); this._transformID = -1; + this._textureID = -1; } // constructor @@ -161,7 +161,7 @@ this._texture = value; this.cachedTint = 0xFFFFFF; - this.textureDirty = true; + this._textureID = -1; if (value) { @@ -186,7 +186,7 @@ */ Sprite.prototype._onTextureUpdate = function () { - this.textureDirty = true; + this._textureID = -1; // so if _width is 0 then width was not set.. if (this._width) @@ -210,13 +210,13 @@ */ Sprite.prototype.calculateVertices = function () { - if(this._transformID === this.transform._worldID && !this.textureDirty) + if(this._transformID === this.transform._worldID && this._textureID === this._texture._updateID) { return; } this._transformID = this.transform._worldID; - this.textureDirty = false; + this._textureID = this._texture._updateID; // set the vertex data diff --git a/src/core/text/Text.js b/src/core/text/Text.js index 4e21f7f..ad60a2e 100644 --- a/src/core/text/Text.js +++ b/src/core/text/Text.js @@ -410,9 +410,6 @@ texture.baseTexture.emit('update', texture.baseTexture); - // make sure to flag the texture as dirty.. - this.textureDirty = true; - this.dirty = false; }; diff --git a/src/core/textures/Texture.js b/src/core/textures/Texture.js index c9b0a28..94ed7e8 100644 --- a/src/core/textures/Texture.js +++ b/src/core/textures/Texture.js @@ -132,6 +132,9 @@ * @memberof PIXI.Texture# * @protected */ + + + this._updateID = 0; } Texture.prototype = Object.create(EventEmitter.prototype); @@ -238,6 +241,8 @@ */ Texture.prototype.onBaseTextureLoaded = function (baseTexture) { + this._updateID++; + // TODO this code looks confusing.. boo to abusing getters and setterss! if (this.noFrame) { @@ -250,6 +255,7 @@ this.baseTexture.on('update', this.onBaseTextureUpdated, this); this.emit('update', this); + }; /** @@ -259,6 +265,8 @@ */ Texture.prototype.onBaseTextureUpdated = function (baseTexture) { + this._updateID++; + this._frame.width = baseTexture.width; this._frame.height = baseTexture.height; @@ -319,6 +327,8 @@ } this._uvs.set(this._frame, this.baseTexture, this.rotate); + + this._updateID++; }; /**