diff options
author | commit-bot@chromium.org <commit-bot@chromium.org@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2014-05-01 19:31:31 +0000 |
---|---|---|
committer | commit-bot@chromium.org <commit-bot@chromium.org@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2014-05-01 19:31:31 +0000 |
commit | 131e138f57d72cde1c1549ba33301b2d5ea5c3e9 (patch) | |
tree | 52f694d3334bedaef7fb91d00beaca766403a3d3 | |
parent | 086e5ddc4c8c51d84e930fe4cdbc7eeba64d72f8 (diff) | |
download | include-131e138f57d72cde1c1549ba33301b2d5ea5c3e9.tar.gz |
create struct to hold all the params passed around for shader::context
BUG=skia:
R=scroggo@google.com, dominikg@chromium.org
Author: reed@google.com
Review URL: https://codereview.chromium.org/264843006
git-svn-id: http://skia.googlecode.com/svn/trunk/include@14514 2bbb7eff-a529-9590-31e7-b0007b416f81
-rw-r--r-- | core/SkColorShader.h | 8 | ||||
-rw-r--r-- | core/SkComposeShader.h | 9 | ||||
-rw-r--r-- | core/SkEmptyShader.h | 6 | ||||
-rw-r--r-- | core/SkShader.h | 28 | ||||
-rw-r--r-- | effects/SkPerlinNoiseShader.h | 7 | ||||
-rw-r--r-- | effects/SkTransparentShader.h | 6 |
6 files changed, 31 insertions, 33 deletions
diff --git a/core/SkColorShader.h b/core/SkColorShader.h index 9e19a71..f993959 100644 --- a/core/SkColorShader.h +++ b/core/SkColorShader.h @@ -27,10 +27,7 @@ public: virtual bool isOpaque() const SK_OVERRIDE; - virtual SkShader::Context* createContext(const SkBitmap& device, - const SkPaint& paint, - const SkMatrix& matrix, - void* storage) const SK_OVERRIDE; + virtual SkShader::Context* createContext(const ContextRec&, void* storage) const SK_OVERRIDE; virtual size_t contextSize() const SK_OVERRIDE { return sizeof(ColorShaderContext); @@ -38,8 +35,7 @@ public: class ColorShaderContext : public SkShader::Context { public: - ColorShaderContext(const SkColorShader& shader, const SkBitmap& device, - const SkPaint& paint, const SkMatrix& matrix); + ColorShaderContext(const SkColorShader& shader, const ContextRec&); virtual uint32_t getFlags() const SK_OVERRIDE; virtual uint8_t getSpan16Alpha() const SK_OVERRIDE; diff --git a/core/SkComposeShader.h b/core/SkComposeShader.h index d42da0c..ac3c32b 100644 --- a/core/SkComposeShader.h +++ b/core/SkComposeShader.h @@ -34,18 +34,15 @@ public: SkComposeShader(SkShader* sA, SkShader* sB, SkXfermode* mode = NULL); virtual ~SkComposeShader(); - virtual bool validContext(const SkBitmap&, const SkPaint&, - const SkMatrix&, SkMatrix* totalInverse = NULL) const SK_OVERRIDE; - virtual SkShader::Context* createContext(const SkBitmap&, const SkPaint&, - const SkMatrix&, void*) const SK_OVERRIDE; + 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 { public: // When this object gets destroyed, it will call contextA and contextB's destructor // but it will NOT free the memory. - ComposeShaderContext(const SkComposeShader&, const SkBitmap&, - const SkPaint&, const SkMatrix&, + ComposeShaderContext(const SkComposeShader&, const ContextRec&, SkShader::Context* contextA, SkShader::Context* contextB); SkShader::Context* getShaderContextA() const { return fShaderContextA; } diff --git a/core/SkEmptyShader.h b/core/SkEmptyShader.h index 7494eff..d1a067f 100644 --- a/core/SkEmptyShader.h +++ b/core/SkEmptyShader.h @@ -27,13 +27,11 @@ public: return sizeof(SkShader::Context); } - virtual bool validContext(const SkBitmap&, const SkPaint&, - const SkMatrix&, SkMatrix* totalInverse = NULL) const SK_OVERRIDE { + virtual bool validContext(const ContextRec&, SkMatrix* totalInverse = NULL) const SK_OVERRIDE { return false; } - virtual SkShader::Context* createContext(const SkBitmap&, const SkPaint&, - const SkMatrix&, void*) const SK_OVERRIDE { + virtual SkShader::Context* createContext(const ContextRec&, void*) const SK_OVERRIDE { // validContext returns false. return NULL; } diff --git a/core/SkShader.h b/core/SkShader.h index b0a7fd9..32707d7 100644 --- a/core/SkShader.h +++ b/core/SkShader.h @@ -119,10 +119,26 @@ public: */ virtual bool isOpaque() const { return false; } + /** + * ContextRec acts as a parameter bundle for creating Contexts. + */ + struct ContextRec { + ContextRec() : fDevice(NULL), fPaint(NULL), fMatrix(NULL) {} + ContextRec(const ContextRec& other) + : fDevice(other.fDevice), fPaint(other.fPaint), fMatrix(other.fMatrix) {} + ContextRec(const SkBitmap& device, const SkPaint& paint, const SkMatrix& matrix) + : fDevice(&device) + , fPaint(&paint) + , fMatrix(&matrix) {} + + const SkBitmap* fDevice; // the bitmap we are drawing into + const SkPaint* fPaint; // the current paint associated with the draw + const SkMatrix* fMatrix; // the current matrix in the canvas + }; + class Context : public ::SkNoncopyable { public: - Context(const SkShader& shader, const SkBitmap& device, - const SkPaint& paint, const SkMatrix& matrix); + Context(const SkShader& shader, const ContextRec&); virtual ~Context(); @@ -200,8 +216,7 @@ public: * Subclasses should be sure to call their INHERITED::validContext() if * they override this method. */ - virtual bool validContext(const SkBitmap& device, const SkPaint& paint, - const SkMatrix& matrix, SkMatrix* totalInverse = NULL) const; + virtual bool validContext(const ContextRec&, SkMatrix* totalInverse = NULL) const; /** * Create the actual object that does the shading. @@ -211,10 +226,7 @@ public: * * Base class implementation returns NULL. */ - virtual Context* createContext(const SkBitmap& device, - const SkPaint& paint, - const SkMatrix& matrix, - void* storage) const; + virtual Context* createContext(const ContextRec&, void* storage) const; /** * Return the size of a Context returned by createContext. diff --git a/effects/SkPerlinNoiseShader.h b/effects/SkPerlinNoiseShader.h index 5b27029..2766df0 100644 --- a/effects/SkPerlinNoiseShader.h +++ b/effects/SkPerlinNoiseShader.h @@ -72,15 +72,12 @@ public: } - virtual SkShader::Context* createContext( - const SkBitmap& device, const SkPaint& paint, - const SkMatrix& matrix, void* storage) const SK_OVERRIDE; + virtual SkShader::Context* createContext(const ContextRec&, void* storage) const SK_OVERRIDE; virtual size_t contextSize() const SK_OVERRIDE; class PerlinNoiseShaderContext : public SkShader::Context { public: - PerlinNoiseShaderContext(const SkPerlinNoiseShader& shader, const SkBitmap& device, - const SkPaint& paint, const SkMatrix& matrix); + PerlinNoiseShaderContext(const SkPerlinNoiseShader& shader, const ContextRec&); virtual ~PerlinNoiseShaderContext() {} virtual void shadeSpan(int x, int y, SkPMColor[], int count) SK_OVERRIDE; diff --git a/effects/SkTransparentShader.h b/effects/SkTransparentShader.h index 790e5ae..55513eb 100644 --- a/effects/SkTransparentShader.h +++ b/effects/SkTransparentShader.h @@ -14,15 +14,13 @@ class SK_API SkTransparentShader : public SkShader { public: SkTransparentShader() {} - virtual SkShader::Context* createContext(const SkBitmap& device, const SkPaint& paint, - const SkMatrix& matrix, void* storage) const + virtual SkShader::Context* createContext(const ContextRec&, void* storage) const SK_OVERRIDE; virtual size_t contextSize() const SK_OVERRIDE; class TransparentShaderContext : public SkShader::Context { public: - TransparentShaderContext(const SkTransparentShader& shader, const SkBitmap& device, - const SkPaint& paint, const SkMatrix& matrix); + TransparentShaderContext(const SkTransparentShader& shader, const ContextRec&); virtual ~TransparentShaderContext(); virtual uint32_t getFlags() const SK_OVERRIDE; |