OLD | NEW |
1 | 1 |
2 /* | 2 /* |
3 * Copyright 2007 The Android Open Source Project | 3 * Copyright 2007 The Android Open Source Project |
4 * | 4 * |
5 * Use of this source code is governed by a BSD-style license that can be | 5 * Use of this source code is governed by a BSD-style license that can be |
6 * found in the LICENSE file. | 6 * found in the LICENSE file. |
7 */ | 7 */ |
8 | 8 |
9 | 9 |
10 #ifndef SkColorShader_DEFINED | 10 #ifndef SkColorShader_DEFINED |
11 #define SkColorShader_DEFINED | 11 #define SkColorShader_DEFINED |
12 | 12 |
13 #include "SkShader.h" | 13 #include "SkShader.h" |
14 | 14 |
15 /** \class SkColorShader | 15 /** \class SkColorShader |
16 A Shader that represents a single color. In general, this effect can be | 16 A Shader that represents a single color. In general, this effect can be |
17 accomplished by just using the color field on the paint, but if an | 17 accomplished by just using the color field on the paint, but if an |
18 actual shader object is needed, this provides that feature. | 18 actual shader object is needed, this provides that feature. |
19 */ | 19 */ |
20 class SK_API SkColorShader : public SkShader { | 20 class SK_API SkColorShader : public SkShader { |
21 public: | 21 public: |
22 /** Create a ColorShader that ignores the color in the paint, and uses the | 22 /** Create a ColorShader that ignores the color in the paint, and uses the |
23 specified color. Note: like all shaders, at draw time the paint's alpha | 23 specified color. Note: like all shaders, at draw time the paint's alpha |
24 will be respected, and is applied to the specified color. | 24 will be respected, and is applied to the specified color. |
25 */ | 25 */ |
26 explicit SkColorShader(SkColor c); | 26 explicit SkColorShader(SkColor c); |
27 | 27 |
28 virtual bool isOpaque() const SK_OVERRIDE; | 28 virtual bool isOpaque() const SK_OVERRIDE; |
29 | 29 |
30 virtual SkShader::Context* createContext(const ContextRec&, void* storage) c
onst SK_OVERRIDE; | |
31 | |
32 virtual size_t contextSize() const SK_OVERRIDE { | 30 virtual size_t contextSize() const SK_OVERRIDE { |
33 return sizeof(ColorShaderContext); | 31 return sizeof(ColorShaderContext); |
34 } | 32 } |
35 | 33 |
36 class ColorShaderContext : public SkShader::Context { | 34 class ColorShaderContext : public SkShader::Context { |
37 public: | 35 public: |
38 ColorShaderContext(const SkColorShader& shader, const ContextRec&); | 36 ColorShaderContext(const SkColorShader& shader, const ContextRec&); |
39 | 37 |
40 virtual uint32_t getFlags() const SK_OVERRIDE; | 38 virtual uint32_t getFlags() const SK_OVERRIDE; |
41 virtual uint8_t getSpan16Alpha() const SK_OVERRIDE; | 39 virtual uint8_t getSpan16Alpha() const SK_OVERRIDE; |
(...skipping 15 matching lines...) Expand all Loading... |
57 TileMode xy[2]) const SK_OVERRIDE; | 55 TileMode xy[2]) const SK_OVERRIDE; |
58 | 56 |
59 virtual GradientType asAGradient(GradientInfo* info) const SK_OVERRIDE; | 57 virtual GradientType asAGradient(GradientInfo* info) const SK_OVERRIDE; |
60 | 58 |
61 SK_TO_STRING_OVERRIDE() | 59 SK_TO_STRING_OVERRIDE() |
62 SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkColorShader) | 60 SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkColorShader) |
63 | 61 |
64 protected: | 62 protected: |
65 SkColorShader(SkReadBuffer&); | 63 SkColorShader(SkReadBuffer&); |
66 virtual void flatten(SkWriteBuffer&) const SK_OVERRIDE; | 64 virtual void flatten(SkWriteBuffer&) const SK_OVERRIDE; |
| 65 virtual Context* onCreateContext(const ContextRec&, void* storage) const SK_
OVERRIDE; |
67 | 66 |
68 private: | 67 private: |
69 SkColor fColor; // ignored if fInheritColor is true | 68 SkColor fColor; // ignored if fInheritColor is true |
70 | 69 |
71 typedef SkShader INHERITED; | 70 typedef SkShader INHERITED; |
72 }; | 71 }; |
73 | 72 |
74 #endif | 73 #endif |
OLD | NEW |