OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2015 Google Inc. | 2 * Copyright 2015 Google Inc. |
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 GrColorProcessor_DEFINED | 8 #ifndef GrColorProcessor_DEFINED |
9 #define GrColorProcessor_DEFINED | 9 #define GrColorProcessor_DEFINED |
10 | 10 |
11 #include "GrFragmentProcessor.h" | 11 #include "GrFragmentProcessor.h" |
12 | 12 |
13 /** | 13 /** |
14 * This is a simple GrFragmentProcessor that outputs a constant color. It may do
one of the | 14 * This is a simple GrFragmentProcessor that outputs a constant color. It may do
one of the |
15 * following with its input color: ignore it, or multiply it by the constant col
or, multiply its | 15 * following with its input color: ignore it, or multiply it by the constant col
or, multiply its |
16 * alpha by the constant color and ignore the input color's r, g, and b. | 16 * alpha by the constant color and ignore the input color's r, g, and b. |
17 */ | 17 */ |
18 class GrConstColorProcessor : public GrFragmentProcessor { | 18 class GrConstColorProcessor : public GrFragmentProcessor { |
19 public: | 19 public: |
20 enum InputMode { | 20 enum InputMode { |
21 kIgnore_InputMode, | 21 kIgnore_InputMode, |
22 kModulateRGBA_InputMode, | 22 kModulateRGBA_InputMode, |
23 kModulateA_InputMode, | 23 kModulateA_InputMode, |
24 | 24 |
25 kLastInputMode = kModulateA_InputMode | 25 kLastInputMode = kModulateA_InputMode |
26 }; | 26 }; |
27 static const int kInputModeCnt = kLastInputMode + 1; | 27 static const int kInputModeCnt = kLastInputMode + 1; |
28 | 28 |
29 static GrFragmentProcessor* Create(GrColor color, InputMode mode) { | 29 static sk_sp<GrFragmentProcessor> Make(GrColor color, InputMode mode) { |
30 return new GrConstColorProcessor(color, mode); | 30 return sk_sp<GrFragmentProcessor>(new GrConstColorProcessor(color, mode)
); |
31 } | 31 } |
32 | 32 |
33 const char* name() const override { return "Color"; } | 33 const char* name() const override { return "Color"; } |
34 | 34 |
35 SkString dumpInfo() const override { | 35 SkString dumpInfo() const override { |
36 SkString str; | 36 SkString str; |
37 str.appendf("Color: 0x%08x", fColor); | 37 str.appendf("Color: 0x%08x", fColor); |
38 return str; | 38 return str; |
39 } | 39 } |
40 | 40 |
(...skipping 16 matching lines...) Expand all Loading... |
57 | 57 |
58 GR_DECLARE_FRAGMENT_PROCESSOR_TEST; | 58 GR_DECLARE_FRAGMENT_PROCESSOR_TEST; |
59 | 59 |
60 GrColor fColor; | 60 GrColor fColor; |
61 InputMode fMode; | 61 InputMode fMode; |
62 | 62 |
63 typedef GrFragmentProcessor INHERITED; | 63 typedef GrFragmentProcessor INHERITED; |
64 }; | 64 }; |
65 | 65 |
66 #endif | 66 #endif |
OLD | NEW |