| 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 class GrInvariantOutput; | |
| 14 | |
| 15 /** | 13 /** |
| 16 * 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 |
| 17 * 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 |
| 18 * 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. |
| 19 */ | 17 */ |
| 20 class GrConstColorProcessor : public GrFragmentProcessor { | 18 class GrConstColorProcessor : public GrFragmentProcessor { |
| 21 public: | 19 public: |
| 22 enum InputMode { | 20 enum InputMode { |
| 23 kIgnore_InputMode, | 21 kIgnore_InputMode, |
| 24 kModulateRGBA_InputMode, | 22 kModulateRGBA_InputMode, |
| 25 kModulateA_InputMode, | 23 kModulateA_InputMode, |
| 26 | 24 |
| 27 kLastInputMode = kModulateA_InputMode | 25 kLastInputMode = kModulateA_InputMode |
| 28 }; | 26 }; |
| 29 static const int kInputModeCnt = kLastInputMode + 1; | 27 static const int kInputModeCnt = kLastInputMode + 1; |
| 30 | 28 |
| 31 static GrFragmentProcessor* Create(GrColor color, InputMode mode) { | 29 static GrFragmentProcessor* Create(GrColor color, InputMode mode) { |
| 32 return new GrConstColorProcessor(color, mode); | 30 return new GrConstColorProcessor(color, mode); |
| 33 } | 31 } |
| 34 | 32 |
| 35 ~GrConstColorProcessor() override {} | |
| 36 | |
| 37 const char* name() const override { return "Color"; } | 33 const char* name() const override { return "Color"; } |
| 38 | 34 |
| 39 GrColor color() const { return fColor; } | 35 GrColor color() const { return fColor; } |
| 40 | 36 |
| 41 InputMode inputMode() const { return fMode; } | 37 InputMode inputMode() const { return fMode; } |
| 42 | 38 |
| 43 private: | 39 private: |
| 44 GrConstColorProcessor(GrColor color, InputMode mode) : fColor(color), fMode(
mode) { | 40 GrConstColorProcessor(GrColor color, InputMode mode) : fColor(color), fMode(
mode) { |
| 45 this->initClassID<GrConstColorProcessor>(); | 41 this->initClassID<GrConstColorProcessor>(); |
| 46 } | 42 } |
| 47 | 43 |
| 48 GrGLFragmentProcessor* onCreateGLInstance() const override; | 44 GrGLFragmentProcessor* onCreateGLInstance() const override; |
| 49 | 45 |
| 50 void onGetGLProcessorKey(const GrGLSLCaps&, GrProcessorKeyBuilder*) const ov
erride; | 46 void onGetGLProcessorKey(const GrGLSLCaps&, GrProcessorKeyBuilder*) const ov
erride; |
| 51 | 47 |
| 52 bool onIsEqual(const GrFragmentProcessor&) const override; | 48 bool onIsEqual(const GrFragmentProcessor&) const override; |
| 53 | 49 |
| 54 void onComputeInvariantOutput(GrInvariantOutput* inout) const override; | 50 void onComputeInvariantOutput(GrInvariantOutput* inout) const override; |
| 55 | 51 |
| 56 GR_DECLARE_FRAGMENT_PROCESSOR_TEST; | 52 GR_DECLARE_FRAGMENT_PROCESSOR_TEST; |
| 57 | 53 |
| 58 GrColor fColor; | 54 GrColor fColor; |
| 59 InputMode fMode; | 55 InputMode fMode; |
| 60 | 56 |
| 61 typedef GrFragmentProcessor INHERITED; | 57 typedef GrFragmentProcessor INHERITED; |
| 62 }; | 58 }; |
| 63 | 59 |
| 64 #endif | 60 #endif |
| OLD | NEW |