From 0d57c7577fd68836677735f1644933415ccb1151 Mon Sep 17 00:00:00 2001 From: Asturur Date: Fri, 16 Mar 2018 04:37:52 +0100 Subject: [PATCH 1/5] added dirty to apply filter --- src/shapes/image.class.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/shapes/image.class.js b/src/shapes/image.class.js index 512fdd710bb..6bf2b91281e 100644 --- a/src/shapes/image.class.js +++ b/src/shapes/image.class.js @@ -424,6 +424,9 @@ filters = filters || this.filters || []; filters = filters.filter(function(filter) { return filter; }); + if (this.group) { + this.set('dirty'); + } if (filters.length === 0) { this._element = this._originalElement; this._filteredEl = null; From 0076a58c7a87931f93ba8297343463b881282a2c Mon Sep 17 00:00:00 2001 From: Asturur Date: Fri, 16 Mar 2018 04:39:20 +0100 Subject: [PATCH 2/5] applied to resize filter too --- src/shapes/image.class.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/shapes/image.class.js b/src/shapes/image.class.js index 6bf2b91281e..feb137976bb 100644 --- a/src/shapes/image.class.js +++ b/src/shapes/image.class.js @@ -389,6 +389,9 @@ scaleX = this.scaleX * retinaScaling, scaleY = this.scaleY * retinaScaling, elementToFilter = this._filteredEl || this._originalElement; + if (this.group) { + this.set('dirty', true); + } if (!filter || (scaleX > minimumScale && scaleY > minimumScale)) { this._element = elementToFilter; this._filterScalingX = 1; @@ -425,7 +428,7 @@ filters = filters || this.filters || []; filters = filters.filter(function(filter) { return filter; }); if (this.group) { - this.set('dirty'); + this.set('dirty', true); } if (filters.length === 0) { this._element = this._originalElement; From f6baf307410df215cf196d26bba6bacc76601ae8 Mon Sep 17 00:00:00 2001 From: Asturur Date: Fri, 16 Mar 2018 04:44:32 +0100 Subject: [PATCH 3/5] applied to resize filter too --- test/unit/image.js | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/test/unit/image.js b/test/unit/image.js index b886b296379..539dee879b2 100644 --- a/test/unit/image.js +++ b/test/unit/image.js @@ -645,4 +645,27 @@ done(); }); }); + + QUnit.test('apply filters set the image dirty', function(assert) { + var done = assert.async(); + createImageObject(function(image) { + assert.equal(image.dirty, false, 'false apply filter dirty is false'); + image.applyFilters(); + assert.equal(image.dirty, true, 'After apply filter dirty is true'); + done(); + }); + }); + + QUnit.test('apply filters set the image dirty and also the group', function(assert) { + var done = assert.async(); + createImageObject(function(image) { + var group = new fabric.Group([image]); + assert.equal(image.dirty, false, 'false apply filter dirty is false'); + assert.equal(group.dirty, false, 'false apply filter dirty is false'); + image.applyFilters(); + assert.equal(image.dirty, true, 'After apply filter dirty is true'); + assert.equal(group.dirty, true, 'After apply filter dirty is true'); + done(); + }); + }); })(); From 2b9a2655566e9187cc90ad4a58dc2cb42a4e0607 Mon Sep 17 00:00:00 2001 From: Asturur Date: Sat, 17 Mar 2018 05:59:11 +0100 Subject: [PATCH 4/5] fixed test --- test/unit/image.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/unit/image.js b/test/unit/image.js index 539dee879b2..0864681396b 100644 --- a/test/unit/image.js +++ b/test/unit/image.js @@ -646,12 +646,12 @@ }); }); - QUnit.test('apply filters set the image dirty', function(assert) { + QUnit.test('apply filters do not set the image dirty if not in group', function(assert) { var done = assert.async(); createImageObject(function(image) { assert.equal(image.dirty, false, 'false apply filter dirty is false'); image.applyFilters(); - assert.equal(image.dirty, true, 'After apply filter dirty is true'); + assert.equal(image.dirty, false, 'After apply filter dirty is true'); done(); }); }); From 06e4f9a1dc51c48e7b3b82015a83b9970aa53300 Mon Sep 17 00:00:00 2001 From: Asturur Date: Sat, 17 Mar 2018 06:04:21 +0100 Subject: [PATCH 5/5] fixed tests --- test/unit/image.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/test/unit/image.js b/test/unit/image.js index 0864681396b..6eb1bc5ea48 100644 --- a/test/unit/image.js +++ b/test/unit/image.js @@ -649,6 +649,7 @@ QUnit.test('apply filters do not set the image dirty if not in group', function(assert) { var done = assert.async(); createImageObject(function(image) { + image.dirty = false; assert.equal(image.dirty, false, 'false apply filter dirty is false'); image.applyFilters(); assert.equal(image.dirty, false, 'After apply filter dirty is true'); @@ -660,6 +661,8 @@ var done = assert.async(); createImageObject(function(image) { var group = new fabric.Group([image]); + image.dirty = false; + group.dirty = false; assert.equal(image.dirty, false, 'false apply filter dirty is false'); assert.equal(group.dirty, false, 'false apply filter dirty is false'); image.applyFilters();