[sksg] Fix inval tracking in Group::removeChild()
TBR=
Change-Id: If3536f8be9d379402cde18c0482108fcf5ae01bb
Reviewed-on: https://skia-review.googlesource.com/158822
Reviewed-by: Florin Malita <fmalita@chromium.org>
Commit-Queue: Florin Malita <fmalita@chromium.org>
diff --git a/modules/sksg/src/SkSGGroup.cpp b/modules/sksg/src/SkSGGroup.cpp
index 4841714..df696c4 100644
--- a/modules/sksg/src/SkSGGroup.cpp
+++ b/modules/sksg/src/SkSGGroup.cpp
@@ -43,6 +43,7 @@
fChildren.erase(std::remove(fChildren.begin(), fChildren.end(), node), fChildren.end());
SkASSERT(fChildren.size() == origSize - 1);
+ this->unobserveInval(node);
this->invalidate();
}
diff --git a/modules/sksg/tests/SGTest.cpp b/modules/sksg/tests/SGTest.cpp
index e098171..1b6e4f9 100644
--- a/modules/sksg/tests/SGTest.cpp
+++ b/modules/sksg/tests/SGTest.cpp
@@ -191,9 +191,21 @@
}
}
+static void inval_group_remove(skiatest::Reporter* reporter) {
+ auto draw = sksg::Draw::Make(sksg::Rect::Make(SkRect::MakeWH(100, 100)),
+ sksg::Color::Make(SK_ColorBLACK));
+ auto grp = sksg::Group::Make();
+
+ // Readding the child should not trigger asserts.
+ grp->addChild(draw);
+ grp->removeChild(draw);
+ grp->addChild(draw);
+}
+
DEF_TEST(SGInvalidation, reporter) {
inval_test1(reporter);
inval_test2(reporter);
+ inval_group_remove(reporter);
}
#endif // !defined(SK_BUILD_FOR_GOOGLE3)