Don't attempt to use stencil on wrapped, stencil-less targets

We can't attach stencil to a wrapped render target. If we find
ourselves rendering to one that doesn't have stencil already, don't
issue any ops that use stencil.

Bug: chromium:1196353
Bug: skia:11943
Change-Id: I9db93f31a4f8556103be72eb708755e4eaf78136
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/399839
Commit-Queue: Chris Dalton <csmartdalton@google.com>
Reviewed-by: Robert Phillips <robertphillips@google.com>
diff --git a/src/gpu/GrClipStack.cpp b/src/gpu/GrClipStack.cpp
index 5461bcd..4058395 100644
--- a/src/gpu/GrClipStack.cpp
+++ b/src/gpu/GrClipStack.cpp
@@ -1352,8 +1352,8 @@
         // Disable analytic clips when there are user stencil settings to ensure the clip is
         // respected in the stencil buffer.
         remainingAnalyticFPs = 0;
-        // If we have user stencil settings, we shouldn't be avoiding the stencil buffer anyways.
-        SkASSERT(!context->priv().caps()->avoidStencilBuffers());
+        // If we have user stencil settings, stencil needs to be supported.
+        SkASSERT(rtc->asRenderTargetProxy()->canUseStencil(*context->priv().caps()));
     }
 
     // If window rectangles are supported, we can use them to exclude inner bounds of difference ops
@@ -1469,8 +1469,8 @@
     // Now rasterize any remaining elements, either to the stencil or a SW mask. All elements are
     // flattened into a single mask.
     if (!elementsForMask.empty()) {
-        bool stencilUnavailable = context->priv().caps()->avoidStencilBuffers() ||
-                                  rtc->wrapsVkSecondaryCB();
+        bool stencilUnavailable =
+                !rtc->asRenderTargetProxy()->canUseStencil(*context->priv().caps());
 
         bool hasSWMask = false;
         if ((rtc->numSamples() <= 1 && maskRequiresAA) || stencilUnavailable) {