Remove SkShader virtual method validContext

patch from issue 267923005

BUG=skia:
R=scroggo@google.com

Author: reed@google.com

Review URL: https://codereview.chromium.org/261773005

git-svn-id: http://skia.googlecode.com/svn/trunk@14573 2bbb7eff-a529-9590-31e7-b0007b416f81
diff --git a/include/core/SkColorShader.h b/include/core/SkColorShader.h
index f993959..be59627 100644
--- a/include/core/SkColorShader.h
+++ b/include/core/SkColorShader.h
@@ -27,8 +27,6 @@
 
     virtual bool isOpaque() const SK_OVERRIDE;
 
-    virtual SkShader::Context* createContext(const ContextRec&, void* storage) const SK_OVERRIDE;
-
     virtual size_t contextSize() const SK_OVERRIDE {
         return sizeof(ColorShaderContext);
     }
@@ -64,6 +62,7 @@
 protected:
     SkColorShader(SkReadBuffer&);
     virtual void flatten(SkWriteBuffer&) const SK_OVERRIDE;
+    virtual Context* onCreateContext(const ContextRec&, void* storage) const SK_OVERRIDE;
 
 private:
     SkColor     fColor;         // ignored if fInheritColor is true
diff --git a/include/core/SkComposeShader.h b/include/core/SkComposeShader.h
index ac3c32b..cfb03b9 100644
--- a/include/core/SkComposeShader.h
+++ b/include/core/SkComposeShader.h
@@ -34,8 +34,6 @@
     SkComposeShader(SkShader* sA, SkShader* sB, SkXfermode* mode = NULL);
     virtual ~SkComposeShader();
 
-    virtual bool validContext(const ContextRec&, SkMatrix* totalInverse = NULL) const SK_OVERRIDE;
-    virtual SkShader::Context* createContext(const ContextRec&, void*) const SK_OVERRIDE;
     virtual size_t contextSize() const SK_OVERRIDE;
 
     class ComposeShaderContext : public SkShader::Context {
@@ -70,6 +68,7 @@
 protected:
     SkComposeShader(SkReadBuffer& );
     virtual void flatten(SkWriteBuffer&) const SK_OVERRIDE;
+    virtual Context* onCreateContext(const ContextRec&, void*) const SK_OVERRIDE;
 
 private:
     SkShader*   fShaderA;
diff --git a/include/core/SkEmptyShader.h b/include/core/SkEmptyShader.h
index d1a067f..7de3bc1 100644
--- a/include/core/SkEmptyShader.h
+++ b/include/core/SkEmptyShader.h
@@ -1,4 +1,3 @@
-
 /*
  * Copyright 2011 Google Inc.
  *
@@ -6,13 +5,13 @@
  * found in the LICENSE file.
  */
 
-
-
 #ifndef SkEmptyShader_DEFINED
 #define SkEmptyShader_DEFINED
 
 #include "SkShader.h"
 
+// TODO: move this to private, as there is a public factory on SkShader
+
 /**
  *  \class SkEmptyShader
  *  A Shader that always draws nothing. Its createContext always returns NULL.
@@ -27,21 +26,16 @@
         return sizeof(SkShader::Context);
     }
 
-    virtual bool validContext(const ContextRec&, SkMatrix* totalInverse = NULL) const SK_OVERRIDE {
-        return false;
-    }
-
-    virtual SkShader::Context* createContext(const ContextRec&, void*) const SK_OVERRIDE {
-        // validContext returns false.
-        return NULL;
-    }
-
     SK_TO_STRING_OVERRIDE()
     SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkEmptyShader)
 
 protected:
     SkEmptyShader(SkReadBuffer& buffer) : INHERITED(buffer) {}
 
+    virtual SkShader::Context* onCreateContext(const ContextRec&, void*) const SK_OVERRIDE {
+        return NULL;
+    }
+
 private:
     typedef SkShader INHERITED;
 };
diff --git a/include/core/SkShader.h b/include/core/SkShader.h
index bcb229d..0417306 100644
--- a/include/core/SkShader.h
+++ b/include/core/SkShader.h
@@ -213,20 +213,10 @@
     };
 
     /**
-     *  Subclasses should be sure to call their INHERITED::validContext() if
-     *  they override this method.
-     */
-    virtual bool validContext(const ContextRec&, SkMatrix* totalInverse = NULL) const;
-
-    /**
      *  Create the actual object that does the shading.
-     *  Returns NULL if validContext() returns false.
      *  Size of storage must be >= contextSize.
-     *  Your subclass must also override contextSize() if it overrides createContext().
-     *
-     *  Base class implementation returns NULL.
      */
-    virtual Context* createContext(const ContextRec&, void* storage) const;
+    Context* createContext(const ContextRec&, void* storage) const;
 
     /**
      *  Return the size of a Context returned by createContext.
@@ -374,6 +364,11 @@
     //////////////////////////////////////////////////////////////////////////
     //  Factory methods for stock shaders
 
+    /**
+     *  Call this to create a new "empty" shader, that will not draw anything.
+     */
+    static SkShader* CreateEmptyShader();
+
     /** Call this to create a new shader that will draw with the specified bitmap.
      *
      *  If the bitmap cannot be used (e.g. has no pixels, or its dimensions
@@ -409,14 +404,19 @@
     SK_DEFINE_FLATTENABLE_TYPE(SkShader)
 
 protected:
-
     SkShader(SkReadBuffer& );
     virtual void flatten(SkWriteBuffer&) const SK_OVERRIDE;
 
-private:
-    SkMatrix            fLocalMatrix;
+    bool computeTotalInverse(const ContextRec&, SkMatrix* totalInverse) const;
 
-    bool computeTotalInverse(const SkMatrix& matrix, SkMatrix* totalInverse) const;
+    /**
+     *  Your subclass must also override contextSize() if it overrides onCreateContext().
+     *  Base class impl returns NULL.
+     */
+    virtual Context* onCreateContext(const ContextRec&, void* storage) const;
+
+private:
+    SkMatrix fLocalMatrix;
 
     typedef SkFlattenable INHERITED;
 };