aboutsummaryrefslogtreecommitdiffhomepage
path: root/include/effects/SkTransparentShader.h
diff options
context:
space:
mode:
authorGravatar commit-bot@chromium.org <commit-bot@chromium.org@2bbb7eff-a529-9590-31e7-b0007b416f81>2014-04-16 10:16:39 +0000
committerGravatar commit-bot@chromium.org <commit-bot@chromium.org@2bbb7eff-a529-9590-31e7-b0007b416f81>2014-04-16 10:16:39 +0000
commit001f4ed2fb62ecdc98ce2884d925de11b7516d23 (patch)
tree1acb3cdef582b7a33a97e6c6631c62320ca39331 /include/effects/SkTransparentShader.h
parentd1061e254af7fa8267dc1a5ed444d1c4b1743b6d (diff)
Extract most of the mutable state of SkShader into a separate Context object.
SkShader currently stores some state during draw calls via setContext(...). Move that mutable state into a separate SkShader::Context class that is constructed on demand for the duration of the draw. Calls to setContext() are replaced with createContext() which returns a context corresponding to the shader object or NULL if the parameters to createContext are invalid. TEST=out/Debug/dm BUG=skia:1976 R=scroggo@google.com, skyostil@chromium.org, tomhudson@chromium.org, senorblanco@chromium.org, reed@google.com, bungeman@google.com Author: dominikg@chromium.org Review URL: https://codereview.chromium.org/207683004 git-svn-id: http://skia.googlecode.com/svn/trunk@14216 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'include/effects/SkTransparentShader.h')
-rw-r--r--include/effects/SkTransparentShader.h30
1 files changed, 20 insertions, 10 deletions
diff --git a/include/effects/SkTransparentShader.h b/include/effects/SkTransparentShader.h
index 7428d442e3..790e5ae9fd 100644
--- a/include/effects/SkTransparentShader.h
+++ b/include/effects/SkTransparentShader.h
@@ -14,21 +14,31 @@ class SK_API SkTransparentShader : public SkShader {
public:
SkTransparentShader() {}
- virtual uint32_t getFlags() SK_OVERRIDE;
- virtual bool setContext(const SkBitmap& device,
- const SkPaint& paint,
- const SkMatrix& matrix) SK_OVERRIDE;
- virtual void shadeSpan(int x, int y, SkPMColor[], int count) SK_OVERRIDE;
- virtual void shadeSpan16(int x, int y, uint16_t span[], int count) SK_OVERRIDE;
+ virtual SkShader::Context* createContext(const SkBitmap& device, const SkPaint& paint,
+ const SkMatrix& matrix, 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);
+ virtual ~TransparentShaderContext();
+
+ virtual uint32_t getFlags() const SK_OVERRIDE;
+ virtual void shadeSpan(int x, int y, SkPMColor[], int count) SK_OVERRIDE;
+ virtual void shadeSpan16(int x, int y, uint16_t span[], int count) SK_OVERRIDE;
+
+ private:
+ const SkBitmap* fDevice;
+
+ typedef SkShader::Context INHERITED;
+ };
SK_TO_STRING_OVERRIDE()
SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkTransparentShader)
private:
- // these are a cache from the call to setContext()
- const SkBitmap* fDevice;
- uint8_t fAlpha;
-
SkTransparentShader(SkReadBuffer& buffer) : INHERITED(buffer) {}
typedef SkShader INHERITED;