[sksg] More inval fiddling

Node subclasses can now control whether their bounds (changes)
contribute to damage.

Tristate:

  * Default:   The node bounds contribute to damage if the node itself was
               invalidated, observing hasSelfInval().  This is the default
               behavior.

  * ForceSelf: The node bounds contribute to damage, regardless of
               hasSelfInval().  Used for domain-boundary nodes (e.g. Draw),
               which gate blocked fragments (e.g. geometry, paint nodes).

  * BlockSelf: The node bounds do not contribute to damage, regardless of
               hasSelfInval().  Used for nodes which do not contribute
               damage directly (e.g. paints, geometry).

TBR=
Change-Id: I7c941c7ea12e14b008d846ec13108e66e34dbc73
Reviewed-on: https://skia-review.googlesource.com/91104
Reviewed-by: Florin Malita <fmalita@chromium.org>
Commit-Queue: Florin Malita <fmalita@chromium.org>
diff --git a/experimental/sksg/SkSGNode.cpp b/experimental/sksg/SkSGNode.cpp
index d3e8040..13e9864 100644
--- a/experimental/sksg/SkSGNode.cpp
+++ b/experimental/sksg/SkSGNode.cpp
@@ -127,20 +127,20 @@
         return fBounds;
     }
 
-    SkRect prevBounds;
-    if (this->hasSelfInval()) {
-        prevBounds = fBounds;
-    }
+    const auto result     = this->onRevalidate(ic, ctm);
+    const auto selfDamage = result.fReval == Damage::kForceSelf ||
+                            (this->hasSelfInval() && result.fReval != Damage::kBlockSelf);
 
-    fBounds = this->onRevalidate(ic, ctm);
-
-    if (this->hasSelfInval()) {
-        ic->inval(prevBounds, ctm);
-        if (fBounds != prevBounds) {
-            ic->inval(fBounds, ctm);
+    if (selfDamage) {
+        // old bounds
+        ic->inval(fBounds, ctm);
+        if (result.fBounds != fBounds) {
+            // new bounds
+            ic->inval(result.fBounds, ctm);
         }
     }
 
+    fBounds = result.fBounds;
     fFlags &= ~(kInvalSelf_Flag | kInvalDescendant_Flag);
 
     return fBounds;