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 | 12 |
13 /** \class SkColorShader | 13 /** \class SkColorShader |
14 A Shader that represents a single color. In general, this effect can be | 14 A Shader that represents a single color. In general, this effect can be |
15 accomplished by just using the color field on the paint, but if an | 15 accomplished by just using the color field on the paint, but if an |
16 actual shader object is needed, this provides that feature. | 16 actual shader object is needed, this provides that feature. |
17 */ | 17 */ |
18 class SK_API SkColorShader : public SkShader { | 18 class SK_API SkColorShader : public SkShader { |
19 public: | 19 public: |
20 /** Create a ColorShader that ignores the color in the paint, and uses the | 20 /** Create a ColorShader that ignores the color in the paint, and uses the |
21 specified color. Note: like all shaders, at draw time the paint's alpha | 21 specified color. Note: like all shaders, at draw time the paint's alpha |
22 will be respected, and is applied to the specified color. | 22 will be respected, and is applied to the specified color. |
23 */ | 23 */ |
24 explicit SkColorShader(SkColor c); | 24 explicit SkColorShader(SkColor c); |
25 | 25 |
26 bool isOpaque() const SK_OVERRIDE; | 26 bool isOpaque() const override; |
27 | 27 |
28 size_t contextSize() const SK_OVERRIDE { | 28 size_t contextSize() const override { |
29 return sizeof(ColorShaderContext); | 29 return sizeof(ColorShaderContext); |
30 } | 30 } |
31 | 31 |
32 class ColorShaderContext : public SkShader::Context { | 32 class ColorShaderContext : public SkShader::Context { |
33 public: | 33 public: |
34 ColorShaderContext(const SkColorShader& shader, const ContextRec&); | 34 ColorShaderContext(const SkColorShader& shader, const ContextRec&); |
35 | 35 |
36 uint32_t getFlags() const SK_OVERRIDE; | 36 uint32_t getFlags() const override; |
37 uint8_t getSpan16Alpha() const SK_OVERRIDE; | 37 uint8_t getSpan16Alpha() const override; |
38 void shadeSpan(int x, int y, SkPMColor span[], int count) SK_OVERRIDE; | 38 void shadeSpan(int x, int y, SkPMColor span[], int count) override; |
39 void shadeSpan16(int x, int y, uint16_t span[], int count) SK_OVERRIDE; | 39 void shadeSpan16(int x, int y, uint16_t span[], int count) override; |
40 void shadeSpanAlpha(int x, int y, uint8_t alpha[], int count) SK_OVERRID
E; | 40 void shadeSpanAlpha(int x, int y, uint8_t alpha[], int count) override; |
41 | 41 |
42 private: | 42 private: |
43 SkPMColor fPMColor; | 43 SkPMColor fPMColor; |
44 uint32_t fFlags; | 44 uint32_t fFlags; |
45 uint16_t fColor16; | 45 uint16_t fColor16; |
46 | 46 |
47 typedef SkShader::Context INHERITED; | 47 typedef SkShader::Context INHERITED; |
48 }; | 48 }; |
49 | 49 |
50 // we return false for this, use asAGradient | 50 // we return false for this, use asAGradient |
51 virtual BitmapType asABitmap(SkBitmap* outTexture, | 51 virtual BitmapType asABitmap(SkBitmap* outTexture, |
52 SkMatrix* outMatrix, | 52 SkMatrix* outMatrix, |
53 TileMode xy[2]) const SK_OVERRIDE; | 53 TileMode xy[2]) const override; |
54 | 54 |
55 GradientType asAGradient(GradientInfo* info) const SK_OVERRIDE; | 55 GradientType asAGradient(GradientInfo* info) const override; |
56 | 56 |
57 virtual bool asFragmentProcessor(GrContext*, const SkPaint&, const SkMatrix&
viewM, | 57 virtual bool asFragmentProcessor(GrContext*, const SkPaint&, const SkMatrix&
viewM, |
58 const SkMatrix*, GrColor*, | 58 const SkMatrix*, GrColor*, |
59 GrFragmentProcessor**) const SK_OVERRIDE; | 59 GrFragmentProcessor**) const override; |
60 | 60 |
61 SK_TO_STRING_OVERRIDE() | 61 SK_TO_STRING_OVERRIDE() |
62 SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkColorShader) | 62 SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkColorShader) |
63 | 63 |
64 protected: | 64 protected: |
65 SkColorShader(SkReadBuffer&); | 65 SkColorShader(SkReadBuffer&); |
66 void flatten(SkWriteBuffer&) const SK_OVERRIDE; | 66 void flatten(SkWriteBuffer&) const override; |
67 Context* onCreateContext(const ContextRec&, void* storage) const SK_OVERRIDE
; | 67 Context* onCreateContext(const ContextRec&, void* storage) const override; |
68 bool onAsLuminanceColor(SkColor* lum) const SK_OVERRIDE { | 68 bool onAsLuminanceColor(SkColor* lum) const override { |
69 *lum = fColor; | 69 *lum = fColor; |
70 return true; | 70 return true; |
71 } | 71 } |
72 | 72 |
73 private: | 73 private: |
74 SkColor fColor; | 74 SkColor fColor; |
75 | 75 |
76 typedef SkShader INHERITED; | 76 typedef SkShader INHERITED; |
77 }; | 77 }; |
78 | 78 |
79 #endif | 79 #endif |
OLD | NEW |