| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2016 Google Inc. | 2 * Copyright 2016 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 GrGammaEffect_DEFINED | 8 #ifndef GrGammaEffect_DEFINED |
| 9 #define GrGammaEffect_DEFINED | 9 #define GrGammaEffect_DEFINED |
| 10 | 10 |
| 11 #include "GrFragmentProcessor.h" | 11 #include "GrFragmentProcessor.h" |
| 12 | 12 |
| 13 class GrGammaEffect : public GrFragmentProcessor { | 13 class GrGammaEffect : public GrFragmentProcessor { |
| 14 public: | 14 public: |
| 15 enum class Mode { | 15 enum class Mode { |
| 16 kLinearToSRGB, | 16 kLinearToSRGB, |
| 17 kSRGBToLinear, | 17 kSRGBToLinear, |
| 18 kExponential, | 18 kExponential, |
| 19 }; | 19 }; |
| 20 | 20 |
| 21 /** | 21 /** |
| 22 * Creates an effect that applies a gamma curve. | 22 * Creates an effect that applies a gamma curve. |
| 23 */ | 23 */ |
| 24 static const GrFragmentProcessor* Create(SkScalar gamma); | 24 static sk_sp<GrFragmentProcessor> Make(SkScalar gamma); |
| 25 | 25 |
| 26 const char* name() const override { return "Gamma"; } | 26 const char* name() const override { return "Gamma"; } |
| 27 | 27 |
| 28 Mode mode() const { return fMode; } | 28 Mode mode() const { return fMode; } |
| 29 SkScalar gamma() const { return fGamma; } | 29 SkScalar gamma() const { return fGamma; } |
| 30 | 30 |
| 31 private: | 31 private: |
| 32 GrGammaEffect(Mode mode, SkScalar gamma); | 32 GrGammaEffect(Mode mode, SkScalar gamma); |
| 33 | 33 |
| 34 GrGLSLFragmentProcessor* onCreateGLSLInstance() const override; | 34 GrGLSLFragmentProcessor* onCreateGLSLInstance() const override; |
| 35 void onGetGLSLProcessorKey(const GrGLSLCaps&, GrProcessorKeyBuilder*) const
override; | 35 void onGetGLSLProcessorKey(const GrGLSLCaps&, GrProcessorKeyBuilder*) const
override; |
| 36 bool onIsEqual(const GrFragmentProcessor&) const override; | 36 bool onIsEqual(const GrFragmentProcessor&) const override; |
| 37 void onComputeInvariantOutput(GrInvariantOutput* inout) const override; | 37 void onComputeInvariantOutput(GrInvariantOutput* inout) const override; |
| 38 | 38 |
| 39 Mode fMode; | 39 Mode fMode; |
| 40 SkScalar fGamma; | 40 SkScalar fGamma; |
| 41 | 41 |
| 42 GR_DECLARE_FRAGMENT_PROCESSOR_TEST; | 42 GR_DECLARE_FRAGMENT_PROCESSOR_TEST; |
| 43 | 43 |
| 44 typedef GrFragmentProcessor INHERITED; | 44 typedef GrFragmentProcessor INHERITED; |
| 45 }; | 45 }; |
| 46 | 46 |
| 47 #endif | 47 #endif |
| OLD | NEW |