From 0ae324c52880f9d600c53a084ebef7386ca52a24 Mon Sep 17 00:00:00 2001 From: Florin Malita Date: Tue, 23 Jul 2019 09:48:04 -0400 Subject: [PATCH] [sksg] Fix setVisible() invalidation Changes in visibility should generate damage. TBR= Change-Id: Ide7b660719b86bc9843d3dcfebeb6e39076879fb Reviewed-on: https://skia-review.googlesource.com/c/skia/+/229279 Reviewed-by: Florin Malita Reviewed-by: Mike Reed Commit-Queue: Florin Malita --- modules/sksg/src/SkSGRenderNode.cpp | 5 +++++ modules/sksg/tests/SGTest.cpp | 9 +++++++++ 2 files changed, 14 insertions(+) diff --git a/modules/sksg/src/SkSGRenderNode.cpp b/modules/sksg/src/SkSGRenderNode.cpp index 557383c52b..8f4cfdc846 100644 --- a/modules/sksg/src/SkSGRenderNode.cpp +++ b/modules/sksg/src/SkSGRenderNode.cpp @@ -29,6 +29,11 @@ bool RenderNode::isVisible() const { } void RenderNode::setVisible(bool v) { + if (v == this->isVisible()) { + return; + } + + this->invalidate(); fNodeFlags = v ? (fNodeFlags & ~kInvisible_Flag) : (fNodeFlags | kInvisible_Flag); } diff --git a/modules/sksg/tests/SGTest.cpp b/modules/sksg/tests/SGTest.cpp index 84928e6a5f..61e4609333 100644 --- a/modules/sksg/tests/SGTest.cpp +++ b/modules/sksg/tests/SGTest.cpp @@ -326,6 +326,15 @@ static void inval_test3(skiatest::Reporter* reporter) { &damage); } + { + // Visibility change -> full inval. + group->setVisible(false); + std::vector damage = { { 50, 75, 350, 175} }; + check_inval(reporter, root, + SkRect::MakeLTRB(50, 75, 350, 175), + SkRect::MakeLTRB(50, 75, 350, 175), + &damage); + } } static void inval_group_remove(skiatest::Reporter* reporter) {