Make 0-texture GrCustomStages work.

Review URL: http://codereview.appspot.com/6448080/



git-svn-id: http://skia.googlecode.com/svn/trunk@4858 2bbb7eff-a529-9590-31e7-b0007b416f81
diff --git a/src/gpu/gl/GrGpuGL.cpp b/src/gpu/gl/GrGpuGL.cpp
index 68f7a9a..26018bf 100644
--- a/src/gpu/gl/GrGpuGL.cpp
+++ b/src/gpu/gl/GrGpuGL.cpp
@@ -2135,13 +2135,15 @@
 
 void GrGpuGL::flushBoundTextureAndParams(int stage) {
     GrDrawState* drawState = this->drawState();
-    // FIXME: Assuming one texture maximum per custom stage
+    // FIXME: Assuming at most one texture per custom stage
     const GrCustomStage* customStage = drawState->sampler(stage)->getCustomStage();
     GrGLTexture* nextTexture =  static_cast<GrGLTexture*>(customStage->texture(0));
-    // Currently we always use the texture params from the GrSamplerState. Soon custom stages
-    // will provide their own params.
-    const GrTextureParams& texParams = drawState->getSampler(stage).getTextureParams();
-    this->flushBoundTextureAndParams(stage, texParams, nextTexture);
+    if (NULL != nextTexture) {
+        // Currently we always use the texture params from the GrSamplerState. Soon custom stages
+        // will provide their own params.
+        const GrTextureParams& texParams = drawState->getSampler(stage).getTextureParams();
+        this->flushBoundTextureAndParams(stage, texParams, nextTexture);
+    }
 }
 
 void GrGpuGL::flushBoundTextureAndParams(int stage,