diff options
author | 2014-05-05 18:39:18 +0000 | |
---|---|---|
committer | 2014-05-05 18:39:18 +0000 | |
commit | ce56d965069c1649afe14319cb239e6ad670682a (patch) | |
tree | c9d656d7eeb1cc623fb7f0e0c32725ee11cf4bf5 /include | |
parent | 58e428729b8819c35092684034983973ed43ebb2 (diff) |
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
Diffstat (limited to 'include')
-rw-r--r-- | include/core/SkColorShader.h | 3 | ||||
-rw-r--r-- | include/core/SkComposeShader.h | 3 | ||||
-rw-r--r-- | include/core/SkEmptyShader.h | 18 | ||||
-rw-r--r-- | include/core/SkShader.h | 30 | ||||
-rw-r--r-- | include/effects/SkPerlinNoiseShader.h | 2 | ||||
-rw-r--r-- | include/effects/SkTransparentShader.h | 5 |
6 files changed, 27 insertions, 34 deletions
diff --git a/include/core/SkColorShader.h b/include/core/SkColorShader.h index f993959715..be59627bc6 100644 --- a/include/core/SkColorShader.h +++ b/include/core/SkColorShader.h @@ -27,8 +27,6 @@ public: 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 @@ public: 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 ac3c32b731..cfb03b9fc0 100644 --- a/include/core/SkComposeShader.h +++ b/include/core/SkComposeShader.h @@ -34,8 +34,6 @@ public: 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 @@ public: 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 d1a067f432..7de3bc1f8f 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 @@ public: 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 bcb229d767..041730633a 100644 --- a/include/core/SkShader.h +++ b/include/core/SkShader.h @@ -213,20 +213,10 @@ public: }; /** - * 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 @@ public: ////////////////////////////////////////////////////////////////////////// // 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 @@ public: 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; + + /** + * Your subclass must also override contextSize() if it overrides onCreateContext(). + * Base class impl returns NULL. + */ + virtual Context* onCreateContext(const ContextRec&, void* storage) const; - bool computeTotalInverse(const SkMatrix& matrix, SkMatrix* totalInverse) const; +private: + SkMatrix fLocalMatrix; typedef SkFlattenable INHERITED; }; diff --git a/include/effects/SkPerlinNoiseShader.h b/include/effects/SkPerlinNoiseShader.h index 2766df0a78..5082a07f3b 100644 --- a/include/effects/SkPerlinNoiseShader.h +++ b/include/effects/SkPerlinNoiseShader.h @@ -72,7 +72,6 @@ public: } - virtual SkShader::Context* createContext(const ContextRec&, void* storage) const SK_OVERRIDE; virtual size_t contextSize() const SK_OVERRIDE; class PerlinNoiseShaderContext : public SkShader::Context { @@ -104,6 +103,7 @@ public: protected: SkPerlinNoiseShader(SkReadBuffer&); virtual void flatten(SkWriteBuffer&) const SK_OVERRIDE; + virtual Context* onCreateContext(const ContextRec&, void* storage) const SK_OVERRIDE; private: SkPerlinNoiseShader(SkPerlinNoiseShader::Type type, SkScalar baseFrequencyX, diff --git a/include/effects/SkTransparentShader.h b/include/effects/SkTransparentShader.h index 55513eb532..d9a3e5d7a1 100644 --- a/include/effects/SkTransparentShader.h +++ b/include/effects/SkTransparentShader.h @@ -14,8 +14,6 @@ class SK_API SkTransparentShader : public SkShader { public: SkTransparentShader() {} - virtual SkShader::Context* createContext(const ContextRec&, void* storage) const - SK_OVERRIDE; virtual size_t contextSize() const SK_OVERRIDE; class TransparentShaderContext : public SkShader::Context { @@ -36,6 +34,9 @@ public: SK_TO_STRING_OVERRIDE() SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkTransparentShader) +protected: + virtual Context* onCreateContext(const ContextRec&, void* storage) const SK_OVERRIDE; + private: SkTransparentShader(SkReadBuffer& buffer) : INHERITED(buffer) {} |