OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2007 The Android Open Source Project | 2 * Copyright 2007 The Android Open Source Project |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
6 */ | 6 */ |
7 | 7 |
8 #ifndef SkColorShader_DEFINED | 8 #ifndef SkColorShader_DEFINED |
9 #define SkColorShader_DEFINED | 9 #define SkColorShader_DEFINED |
10 | 10 |
11 #include "SkShader.h" | 11 #include "SkShader.h" |
12 #include "SkPM4f.h" | 12 #include "SkPM4f.h" |
13 | 13 |
14 /** \class SkColorShader | 14 /** \class SkColorShader |
15 A Shader that represents a single color. In general, this effect can be | 15 A Shader that represents a single color. In general, this effect can be |
16 accomplished by just using the color field on the paint, but if an | 16 accomplished by just using the color field on the paint, but if an |
17 actual shader object is needed, this provides that feature. | 17 actual shader object is needed, this provides that feature. |
18 */ | 18 */ |
19 class SK_API SkColorShader : public SkShader { | 19 class SK_API SkColorShader : public SkShader { |
20 public: | 20 public: |
21 /** Create a ColorShader that ignores the color in the paint, and uses the | 21 /** Create a ColorShader that ignores the color in the paint, and uses the |
22 specified color. Note: like all shaders, at draw time the paint's alpha | 22 specified color. Note: like all shaders, at draw time the paint's alpha |
23 will be respected, and is applied to the specified color. | 23 will be respected, and is applied to the specified color. |
24 */ | 24 */ |
25 explicit SkColorShader(SkColor c); | 25 explicit SkColorShader(SkColor c); |
26 | 26 |
27 bool isOpaque() const override; | 27 bool isOpaque() const override; |
28 | 28 |
29 size_t contextSize() const override { | 29 size_t contextSize(const ContextRec&) const override { |
30 return sizeof(ColorShaderContext); | 30 return sizeof(ColorShaderContext); |
31 } | 31 } |
32 | 32 |
33 class ColorShaderContext : public SkShader::Context { | 33 class ColorShaderContext : public SkShader::Context { |
34 public: | 34 public: |
35 ColorShaderContext(const SkColorShader& shader, const ContextRec&); | 35 ColorShaderContext(const SkColorShader& shader, const ContextRec&); |
36 | 36 |
37 uint32_t getFlags() const override; | 37 uint32_t getFlags() const override; |
38 void shadeSpan(int x, int y, SkPMColor span[], int count) override; | 38 void shadeSpan(int x, int y, SkPMColor span[], int count) override; |
39 void shadeSpanAlpha(int x, int y, uint8_t alpha[], int count) override; | 39 void shadeSpanAlpha(int x, int y, uint8_t alpha[], int count) override; |
(...skipping 26 matching lines...) Expand all Loading... |
66 return true; | 66 return true; |
67 } | 67 } |
68 | 68 |
69 private: | 69 private: |
70 SkColor fColor; | 70 SkColor fColor; |
71 | 71 |
72 typedef SkShader INHERITED; | 72 typedef SkShader INHERITED; |
73 }; | 73 }; |
74 | 74 |
75 #endif | 75 #endif |
OLD | NEW |