blob: 4ef45772482bf0cf6d7e06730bd9dc0378ac8fc0 [file] [log] [blame]
reed@google.com02f65f22012-08-06 21:20:05 +00001/*
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
13class SkColorFilter;
14
15class SkFilterShader : public SkShader {
16public:
17 SkFilterShader(SkShader* shader, SkColorFilter* filter);
18 virtual ~SkFilterShader();
19
commit-bot@chromium.org87fcd952014-04-23 19:10:51 +000020 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.com02f65f22012-08-06 21:20:05 +000043
commit-bot@chromium.org0f10f7b2014-03-13 18:02:17 +000044 SK_TO_STRING_OVERRIDE()
reed@google.com02f65f22012-08-06 21:20:05 +000045 SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkFilterShader)
46
47protected:
commit-bot@chromium.org8b0e8ac2014-01-30 18:58:24 +000048 SkFilterShader(SkReadBuffer& );
49 virtual void flatten(SkWriteBuffer&) const SK_OVERRIDE;
reed@google.com02f65f22012-08-06 21:20:05 +000050
51private:
52 SkShader* fShader;
53 SkColorFilter* fFilter;
54
55 typedef SkShader INHERITED;
56};
57
58#endif