diff --git a/src/core/display/DisplayObject.js b/src/core/display/DisplayObject.js index 20e778c..02be192 100644 --- a/src/core/display/DisplayObject.js +++ b/src/core/display/DisplayObject.js @@ -24,6 +24,13 @@ this.scale = new math.Point(1, 1); /** + * The skew of the object. + * + * @member {Point} + */ + this.skew = new math.Point(0, 0); + + /** * The pivot point of the displayObject that it rotates around * * @member {Point} @@ -98,7 +105,8 @@ * @member {number} * @private */ - this._sr = 0; + this._srB = 0; + this._srC = 0; /** * cached cos rotation @@ -106,7 +114,8 @@ * @member {number} * @private */ - this._cr = 1; + this._crA = 1; + this._crD = 1; /** * The original, cached bounds of the object @@ -133,12 +142,20 @@ this._mask = null; /** - * Cached internal flag. + * Used internally to optimize updateTransform. * - * @member {boolean} + * @member {number} * @private */ - this._cacheIsDirty = false; + this._cachedRotX = 0; + + /** + * Used internally to optimize updateTransform. + * + * @member {number} + * @private + */ + this._cachedRotY = 0; } // constructor @@ -288,26 +305,35 @@ var wt = this.worldTransform; // temporary matrix variables - var a, b, c, d, tx, ty; + var a, b, c, d, tx, ty, + rotY = this.rotation + this.skew.y, + rotX = this.rotation + this.skew.x; // so if rotation is between 0 then we can simplify the multiplication process.. - if (this.rotation % math.PI_2) + if (rotY % math.PI_2 || rotX % math.PI_2) { // check to see if the rotation is the same as the previous render. This means we only need to use sin and cos when rotation actually changes - if (this.rotation !== this.rotationCache) + if (rotX !== this._cachedRotX || rotY !== this._cachedRotY) { - this.rotationCache = this.rotation; - this._sr = Math.sin(this.rotation); - this._cr = Math.cos(this.rotation); + // cache new values + this._cachedRotX = rotX; + this._cachedRotY = rotY; + + // recalculate expensive ops + this._crA = Math.cos(rotY); + this._srB = Math.sin(rotY); + + this._srC = Math.sin(-rotX); + this._crD = Math.cos(rotX); } // get the matrix values of the displayobject based on its transform properties.. - a = this._cr * this.scale.x; - b = this._sr * this.scale.x; - c = -this._sr * this.scale.y; - d = this._cr * this.scale.y; - tx = this.position.x; - ty = this.position.y; + a = this._crA * this.scale.x; + b = this._srB * this.scale.x; + c = this._srC * this.scale.y; + d = this._crD * this.scale.y; + tx = this.position.x; + ty = this.position.y; // check for pivot.. not often used so geared towards that fact! if (this.pivot.x || this.pivot.y)