Improve global matrix cache invalidation performance (#1563)

This commit is contained in:
Samuel Asensi 2018-10-13 19:53:45 +02:00 committed by Jürg Lehni
parent 70e58162f0
commit 54b20c0268

View file

@ -1247,12 +1247,20 @@ new function() { // Injection scope for various item event handlers
// If there's a cached global matrix for this item, check if all its // If there's a cached global matrix for this item, check if all its
// parents also have one. If it's missing in any of its parents, it // parents also have one. If it's missing in any of its parents, it
// means the child's cached version isn't valid anymore. // means the child's cached version isn't valid anymore.
// For better performance, we also use the occasion of this loop to
// clear cached version of items parents.
var parent = this._parent; var parent = this._parent;
var parents = [];
while (parent) { while (parent) {
if (!parent._globalMatrix) { if (!parent._globalMatrix) {
matrix = null; matrix = null;
// Also clear global matrix of item's parents.
for (var i = 0, l = parents.length; i < l; i++) {
parents[i]._globalMatrix = null;
}
break; break;
} }
parents.push(parent);
parent = parent._parent; parent = parent._parent;
} }
} }