summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorcommit-bot@chromium.org <commit-bot@chromium.org@2bbb7eff-a529-9590-31e7-b0007b416f81>2014-05-05 18:39:18 +0000
committercommit-bot@chromium.org <commit-bot@chromium.org@2bbb7eff-a529-9590-31e7-b0007b416f81>2014-05-05 18:39:18 +0000
commit08a3eed60c27d0ab0e3059769a4b3470435bd348 (patch)
tree24995edc18f8984712ddc398c332ec17e2901b1d
parentd2b8224663697e9ce19c97862eaf783b1e9e1151 (diff)
downloadinclude-08a3eed60c27d0ab0e3059769a4b3470435bd348.tar.gz
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/include@14573 2bbb7eff-a529-9590-31e7-b0007b416f81
-rw-r--r--core/SkColorShader.h3
-rw-r--r--core/SkComposeShader.h3
-rw-r--r--core/SkEmptyShader.h18
-rw-r--r--core/SkShader.h30
-rw-r--r--effects/SkPerlinNoiseShader.h2
-rw-r--r--effects/SkTransparentShader.h5
6 files changed, 27 insertions, 34 deletions
diff --git a/core/SkColorShader.h b/core/SkColorShader.h
index f993959..be59627 100644
--- a/core/SkColorShader.h
+++ b/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/core/SkComposeShader.h b/core/SkComposeShader.h
index ac3c32b..cfb03b9 100644
--- a/core/SkComposeShader.h
+++ b/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/core/SkEmptyShader.h b/core/SkEmptyShader.h
index d1a067f..7de3bc1 100644
--- a/core/SkEmptyShader.h
+++ b/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/core/SkShader.h b/core/SkShader.h
index bcb229d..0417306 100644
--- a/core/SkShader.h
+++ b/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/effects/SkPerlinNoiseShader.h b/effects/SkPerlinNoiseShader.h
index 2766df0..5082a07 100644
--- a/effects/SkPerlinNoiseShader.h
+++ b/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/effects/SkTransparentShader.h b/effects/SkTransparentShader.h
index 55513eb..d9a3e5d 100644
--- a/effects/SkTransparentShader.h
+++ b/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) {}