1 /* 2 * Copyright 2016 Google Inc. 3 * 4 * Use of this source code is governed by a BSD-style license that can be 5 * found in the LICENSE file. 6 */ 7 8 #ifndef GrSRGBEffect_DEFINED 9 #define GrSRGBEffect_DEFINED 10 11 #include "GrFragmentProcessor.h" 12 13 class GrSRGBEffect : public GrFragmentProcessor { 14 public: 15 enum class Mode { 16 kLinearToSRGB, 17 kSRGBToLinear, 18 }; 19 20 /** 21 * Creates an effect that applies the sRGB transfer function (or its inverse) 22 */ 23 static sk_sp<GrFragmentProcessor> Make(Mode mode); 24 25 const char* name() const override { return "sRGB"; } 26 27 Mode mode() const { return fMode; } 28 29 private: 30 GrSRGBEffect(Mode mode); 31 32 GrGLSLFragmentProcessor* onCreateGLSLInstance() const override; 33 void onGetGLSLProcessorKey(const GrShaderCaps&, GrProcessorKeyBuilder*) const override; 34 bool onIsEqual(const GrFragmentProcessor&) const override; 35 36 GrColor4f constantOutputForConstantInput(GrColor4f input) const override; 37 38 Mode fMode; 39 40 GR_DECLARE_FRAGMENT_PROCESSOR_TEST; 41 42 typedef GrFragmentProcessor INHERITED; 43 }; 44 45 #endif 46