reed@google.com | 02f65f2 | 2012-08-06 21:20:05 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2012 Google Inc. |
| 3 | * |
| 4 | * Use of this source code is governed by a BSD-style license that can be |
| 5 | * found in the LICENSE file. |
| 6 | */ |
| 7 | |
| 8 | #ifndef SkFilterShader_DEFINED |
| 9 | #define SkFilterShader_DEFINED |
| 10 | |
| 11 | #include "SkShader.h" |
| 12 | |
| 13 | class SkColorFilter; |
| 14 | |
| 15 | class SkFilterShader : public SkShader { |
| 16 | public: |
| 17 | SkFilterShader(SkShader* shader, SkColorFilter* filter); |
| 18 | virtual ~SkFilterShader(); |
| 19 | |
commit-bot@chromium.org | 87fcd95 | 2014-04-23 19:10:51 +0000 | [diff] [blame^] | 20 | virtual bool validContext(const SkBitmap&, const SkPaint&, |
| 21 | const SkMatrix&, SkMatrix* totalInverse = NULL) const SK_OVERRIDE; |
| 22 | virtual SkShader::Context* createContext(const SkBitmap&, const SkPaint&, |
| 23 | const SkMatrix&, void* storage) const SK_OVERRIDE; |
| 24 | virtual size_t contextSize() const SK_OVERRIDE; |
| 25 | |
| 26 | class FilterShaderContext : public SkShader::Context { |
| 27 | public: |
| 28 | // Takes ownership of shaderContext and calls its destructor. |
| 29 | FilterShaderContext(const SkFilterShader& filterShader, SkShader::Context* shaderContext, |
| 30 | const SkBitmap& device, const SkPaint& paint, const SkMatrix& matrix); |
| 31 | virtual ~FilterShaderContext(); |
| 32 | |
| 33 | virtual uint32_t getFlags() const SK_OVERRIDE; |
| 34 | |
| 35 | virtual void shadeSpan(int x, int y, SkPMColor[], int count) SK_OVERRIDE; |
| 36 | virtual void shadeSpan16(int x, int y, uint16_t[], int count) SK_OVERRIDE; |
| 37 | |
| 38 | private: |
| 39 | SkShader::Context* fShaderContext; |
| 40 | |
| 41 | typedef SkShader::Context INHERITED; |
| 42 | }; |
reed@google.com | 02f65f2 | 2012-08-06 21:20:05 +0000 | [diff] [blame] | 43 | |
commit-bot@chromium.org | 0f10f7b | 2014-03-13 18:02:17 +0000 | [diff] [blame] | 44 | SK_TO_STRING_OVERRIDE() |
reed@google.com | 02f65f2 | 2012-08-06 21:20:05 +0000 | [diff] [blame] | 45 | SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkFilterShader) |
| 46 | |
| 47 | protected: |
commit-bot@chromium.org | 8b0e8ac | 2014-01-30 18:58:24 +0000 | [diff] [blame] | 48 | SkFilterShader(SkReadBuffer& ); |
| 49 | virtual void flatten(SkWriteBuffer&) const SK_OVERRIDE; |
reed@google.com | 02f65f2 | 2012-08-06 21:20:05 +0000 | [diff] [blame] | 50 | |
| 51 | private: |
| 52 | SkShader* fShader; |
| 53 | SkColorFilter* fFilter; |
| 54 | |
| 55 | typedef SkShader INHERITED; |
| 56 | }; |
| 57 | |
| 58 | #endif |