Add GrPaint::*StageEnabled() and GrDrawState::stageEnabled() functions.
These wrap the question of "is this stage of the shader enabled?" so that
we can change the semantics - previously iff there was a texture, now
if there is a texture OR a GrCustomStage, soon (post-cl 6306097) iff there
is a GrCustomStage, which at that point will hold whatever texture is
necessary.

http://codereview.appspot.com/6306104/



git-svn-id: http://skia.googlecode.com/svn/trunk@4325 2bbb7eff-a529-9590-31e7-b0007b416f81
diff --git a/src/gpu/GrContext.cpp b/src/gpu/GrContext.cpp
index a49bf99..e157a8a 100644
--- a/src/gpu/GrContext.cpp
+++ b/src/gpu/GrContext.cpp
@@ -893,7 +893,7 @@
     SK_TRACE_EVENT0("GrContext::drawRectToRect");
 
     // srcRect refers to paint's first texture
-    if (NULL == paint.getTexture(0)) {
+    if (!paint.isTextureStageEnabled(0)) {
         drawRect(paint, dstRect, -1, dstMatrix);
         return;
     }
@@ -1590,9 +1590,9 @@
 
     for (int i = 0; i < GrPaint::kMaxTextures; ++i) {
         int s = i + GrPaint::kFirstTextureStage;
-        fDrawState->setTexture(s, paint.getTexture(i));
         ASSERT_OWNED_RESOURCE(paint.getTexture(i));
-        if (paint.getTexture(i)) {
+        if (paint.isTextureStageEnabled(i)) {
+            fDrawState->setTexture(s, paint.getTexture(i));
             *fDrawState->sampler(s) = paint.getTextureSampler(i);
         }
     }
@@ -1601,9 +1601,9 @@
 
     for (int i = 0; i < GrPaint::kMaxMasks; ++i) {
         int s = i + GrPaint::kFirstMaskStage;
-        fDrawState->setTexture(s, paint.getMask(i));
         ASSERT_OWNED_RESOURCE(paint.getMask(i));
-        if (paint.getMask(i)) {
+        if (paint.isMaskStageEnabled(i)) {
+            fDrawState->setTexture(s, paint.getMask(i));
             *fDrawState->sampler(s) = paint.getMaskSampler(i);
         }
     }