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 SkBitmap& device, | 30 virtual SkShader::Context* createContext(const ContextRec&, void* storage) c
onst SK_OVERRIDE; |
31 const SkPaint& paint, | |
32 const SkMatrix& matrix, | |
33 void* storage) const SK_OVERRIDE; | |
34 | 31 |
35 virtual size_t contextSize() const SK_OVERRIDE { | 32 virtual size_t contextSize() const SK_OVERRIDE { |
36 return sizeof(ColorShaderContext); | 33 return sizeof(ColorShaderContext); |
37 } | 34 } |
38 | 35 |
39 class ColorShaderContext : public SkShader::Context { | 36 class ColorShaderContext : public SkShader::Context { |
40 public: | 37 public: |
41 ColorShaderContext(const SkColorShader& shader, const SkBitmap& device, | 38 ColorShaderContext(const SkColorShader& shader, const ContextRec&); |
42 const SkPaint& paint, const SkMatrix& matrix); | |
43 | 39 |
44 virtual uint32_t getFlags() const SK_OVERRIDE; | 40 virtual uint32_t getFlags() const SK_OVERRIDE; |
45 virtual uint8_t getSpan16Alpha() const SK_OVERRIDE; | 41 virtual uint8_t getSpan16Alpha() const SK_OVERRIDE; |
46 virtual void shadeSpan(int x, int y, SkPMColor span[], int count) SK_OVE
RRIDE; | 42 virtual void shadeSpan(int x, int y, SkPMColor span[], int count) SK_OVE
RRIDE; |
47 virtual void shadeSpan16(int x, int y, uint16_t span[], int count) SK_OV
ERRIDE; | 43 virtual void shadeSpan16(int x, int y, uint16_t span[], int count) SK_OV
ERRIDE; |
48 virtual void shadeSpanAlpha(int x, int y, uint8_t alpha[], int count) SK
_OVERRIDE; | 44 virtual void shadeSpanAlpha(int x, int y, uint8_t alpha[], int count) SK
_OVERRIDE; |
49 | 45 |
50 private: | 46 private: |
51 SkPMColor fPMColor; | 47 SkPMColor fPMColor; |
52 uint32_t fFlags; | 48 uint32_t fFlags; |
(...skipping 16 matching lines...) Expand all Loading... |
69 SkColorShader(SkReadBuffer&); | 65 SkColorShader(SkReadBuffer&); |
70 virtual void flatten(SkWriteBuffer&) const SK_OVERRIDE; | 66 virtual void flatten(SkWriteBuffer&) const SK_OVERRIDE; |
71 | 67 |
72 private: | 68 private: |
73 SkColor fColor; // ignored if fInheritColor is true | 69 SkColor fColor; // ignored if fInheritColor is true |
74 | 70 |
75 typedef SkShader INHERITED; | 71 typedef SkShader INHERITED; |
76 }; | 72 }; |
77 | 73 |
78 #endif | 74 #endif |
OLD | NEW |