mirror of
https://github.com/scratchfoundation/paper.js.git
synced 2025-01-19 06:00:56 -05:00
Clean up _getCachedBounds() code.
This commit is contained in:
parent
8cec512cc2
commit
238f577e6f
1 changed files with 8 additions and 4 deletions
|
@ -829,7 +829,8 @@ var Item = Base.extend(Callback, /** @lends Item# */{
|
|||
// See if we can cache these bounds. We only cache the bounds
|
||||
// transformed with the internally stored _matrix, (the default if no
|
||||
// matrix is passed).
|
||||
var cache = (!matrix || matrix.equals(this._matrix)) && getter;
|
||||
var _matrix = this._matrix,
|
||||
cache = (!matrix || matrix.equals(_matrix)) && getter;
|
||||
// Set up a boundsCache structure that keeps track of items that keep
|
||||
// cached bounds that depend on this item. We store this in our parent,
|
||||
// for multiple reasons:
|
||||
|
@ -861,10 +862,13 @@ var Item = Base.extend(Callback, /** @lends Item# */{
|
|||
// If the result of concatinating the passed matrix with our internal
|
||||
// one is an identity transformation, set it to null for faster
|
||||
// processing
|
||||
var identity = this._matrix.isIdentity();
|
||||
if (_matrix.isIdentity())
|
||||
_matrix = null;
|
||||
matrix = !matrix || matrix.isIdentity()
|
||||
? identity ? null : this._matrix
|
||||
: identity ? matrix : matrix.clone().concatenate(this._matrix);
|
||||
? _matrix
|
||||
: _matrix
|
||||
? matrix.clone().concatenate(_matrix)
|
||||
: matrix;
|
||||
// If we're caching bounds on this item, pass it on as cacheItem, so the
|
||||
// children can setup the _boundsCache structures for it.
|
||||
var bounds = this._getBounds(getter, matrix, cache ? this : cacheItem);
|
||||
|
|
Loading…
Reference in a new issue