From 5cd1ca13c5d2e2ad8cd3dbd2b9c53a69598c8c73 Mon Sep 17 00:00:00 2001 From: Samuel Asensi Date: Sat, 13 Oct 2018 14:41:38 +0200 Subject: [PATCH] Fix item global matrix error (#1562) Bug happen when item is drawn after an empty symbol that should be drawn in a separate canvas context (partial opacity or special blend mode). As bounds are empty, symbol drawing process is interrupted but its global matrix is not removed from the stack. Closes #1561 --- src/item/Item.js | 6 +++++- test/tests/Item_Bounds.js | 9 +++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/src/item/Item.js b/src/item/Item.js index 031b0233..3dfbd4db 100644 --- a/src/item/Item.js +++ b/src/item/Item.js @@ -4327,8 +4327,12 @@ new function() { // Injection scope for hit-test functions shared with project // Apply the parent's global matrix to the calculation of correct // bounds. var bounds = this.getStrokeBounds(viewMatrix); - if (!bounds.width || !bounds.height) + if (!bounds.width || !bounds.height) { + // Item won't be drawn so its global matrix need to be removed + // from the stack (#1561). + matrices.pop(); return; + } // Store previous offset and save the main context, so we can // draw onto it later. prevOffset = param.offset; diff --git a/test/tests/Item_Bounds.js b/test/tests/Item_Bounds.js index b4a3ff59..f0b8ae03 100644 --- a/test/tests/Item_Bounds.js +++ b/test/tests/Item_Bounds.js @@ -789,3 +789,12 @@ test('group.internalBounds with child and child.applyMatrix = false (#1250)', fu equals(group.internalBounds, new Rectangle(0, 0, 250, 250), 'group.internalBounds after scaling item1'); }); + +test('#1561 item._globalMatrix on item after empty symbol', function(){ + var symbol = new SymbolItem(new Path()); + symbol.opacity = 0.5; + symbol.skew(10); + var item = new Path.Circle(new Point(0,0), 10); + view.update(); + equals(item._globalMatrix, new Matrix()); +});