Modifications to GrPatherRenderer(Chain) interfaces to support clip mask manager.

R=robertphillips@google.com
Review URL: https://codereview.appspot.com/6904069

git-svn-id: http://skia.googlecode.com/svn/trunk@6741 2bbb7eff-a529-9590-31e7-b0007b416f81
diff --git a/src/gpu/GrPathRendererChain.cpp b/src/gpu/GrPathRendererChain.cpp
index 8ccafcf..6cb45fa 100644
--- a/src/gpu/GrPathRendererChain.cpp
+++ b/src/gpu/GrPathRendererChain.cpp
@@ -15,10 +15,9 @@
 
 SK_DEFINE_INST_COUNT(GrPathRendererChain)
 
-GrPathRendererChain::GrPathRendererChain(GrContext* context, UsageFlags flags)
+GrPathRendererChain::GrPathRendererChain(GrContext* context)
     : fInit(false)
-    , fOwner(context)
-    , fFlags(flags) {
+    , fOwner(context) {
 }
 
 GrPathRendererChain::~GrPathRendererChain() {
@@ -36,12 +35,41 @@
 GrPathRenderer* GrPathRendererChain::getPathRenderer(const SkPath& path,
                                                      const SkStroke& stroke,
                                                      const GrDrawTarget* target,
-                                                     bool antiAlias) {
+                                                     DrawType drawType,
+                                                     StencilSupport* stencilSupport) {
     if (!fInit) {
         this->init();
     }
+    bool antiAlias = (kColorAntiAlias_DrawType == drawType ||
+                      kStencilAndColorAntiAlias_DrawType == drawType);
+
+    GR_STATIC_ASSERT(GrPathRenderer::kNoSupport_StencilSupport <
+                     GrPathRenderer::kStencilOnly_StencilSupport);
+    GR_STATIC_ASSERT(GrPathRenderer::kStencilOnly_StencilSupport <
+                     GrPathRenderer::kNoRestriction_StencilSupport);
+    GrPathRenderer::StencilSupport minStencilSupport;
+    if (kStencilOnly_DrawType == drawType) {
+        minStencilSupport = GrPathRenderer::kStencilOnly_StencilSupport;
+    } else if (kStencilAndColor_DrawType == drawType ||
+               kStencilAndColorAntiAlias_DrawType == drawType) {
+        minStencilSupport = GrPathRenderer::kNoRestriction_StencilSupport;
+    } else {
+        minStencilSupport = GrPathRenderer::kNoSupport_StencilSupport;
+    }
+
+
     for (int i = 0; i < fChain.count(); ++i) {
         if (fChain[i]->canDrawPath(path, stroke, target, antiAlias)) {
+            if (GrPathRenderer::kNoSupport_StencilSupport != minStencilSupport) {
+                GrPathRenderer::StencilSupport support = fChain[i]->getStencilSupport(path,
+                                                                                      stroke,
+                                                                                      target);
+                if (support < minStencilSupport) {
+                    continue;
+                } else if (NULL != stencilSupport) {
+                    *stencilSupport = support;
+                }
+            }
             return fChain[i];
         }
     }
@@ -53,7 +81,7 @@
     GrGpu* gpu = fOwner->getGpu();
     bool twoSided = gpu->getCaps().twoSidedStencilSupport();
     bool wrapOp = gpu->getCaps().stencilWrapOpsSupport();
-    GrPathRenderer::AddPathRenderers(fOwner, fFlags, this);
+    GrPathRenderer::AddPathRenderers(fOwner, this);
     this->addPathRenderer(SkNEW_ARGS(GrDefaultPathRenderer,
                                      (twoSided, wrapOp)))->unref();
     fInit = true;