Make GrReducedClip's gen ID only apply to the element list

Renames fGenID to fElementsGenID and designates this value as
undefined when when the element list is empty.

BUG=skia:
GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=2244223004

Review-Url: https://codereview.chromium.org/2244223004
diff --git a/src/gpu/GrReducedClip.cpp b/src/gpu/GrReducedClip.cpp
index 132936c..251155b 100644
--- a/src/gpu/GrReducedClip.cpp
+++ b/src/gpu/GrReducedClip.cpp
@@ -316,15 +316,6 @@
     }
     *requiresAA = numAAElements > 0;
 
-    if (0 == result->count()) {
-        if (initialState == InitialTriState::kAllIn) {
-            *resultGenID = SkClipStack::kWideOpenGenID;
-        } else {
-            *resultGenID = SkClipStack::kEmptyGenID;
-        }
-    }
-
-    SkASSERT(SkClipStack::kInvalidGenID != *resultGenID);
     SkASSERT(InitialTriState::kUnknown != initialState);
     return static_cast<GrReducedClip::InitialState>(initialState);
 }
@@ -338,11 +329,6 @@
 */
 GrReducedClip::GrReducedClip(const SkClipStack& stack, const SkRect& queryBounds) {
     SkASSERT(!queryBounds.isEmpty());
-
-    // The clip established by the element list might be cached based on the last
-    // generation id. When we make early returns, we do not know what was the generation
-    // id that lead to the state. Make a conservative guess.
-    fGenID = stack.getTopmostGenID();
     fHasIBounds = false;
 
     if (stack.isWideOpen()) {
@@ -387,6 +373,7 @@
 
         // Implement the clip with an AA rect element.
         fElements.addToHead(stackBounds, SkRegion::kReplace_Op, true/*doAA*/);
+        fElementsGenID = stack.getTopmostGenID();
         fRequiresAA = true;
 
         fInitialState = InitialState::kAllOut;
@@ -406,6 +393,6 @@
 
     // Now that we have determined the bounds to use and filtered out the trivial cases, call the
     // helper that actually walks the stack.
-    fInitialState = reduced_stack_walker(stack, tighterQuery, fIBounds, &fElements, &fGenID,
+    fInitialState = reduced_stack_walker(stack, tighterQuery, fIBounds, &fElements, &fElementsGenID,
                                          &fRequiresAA);
 }