blob: 17afa5e5bdda5694419bf47cf510154c10e61b3d [file] [log] [blame]
brianosman2d1ee792016-05-05 12:24:31 -07001/*
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
Brian Osman964dec32017-01-26 09:32:33 -05008#ifndef GrSRGBEffect_DEFINED
9#define GrSRGBEffect_DEFINED
brianosman2d1ee792016-05-05 12:24:31 -070010
brianosmanfe4d5d32016-05-11 06:49:32 -070011#include "GrFragmentProcessor.h"
brianosman2d1ee792016-05-05 12:24:31 -070012
Brian Osman964dec32017-01-26 09:32:33 -050013class GrSRGBEffect : public GrFragmentProcessor {
brianosman2d1ee792016-05-05 12:24:31 -070014public:
brianosmanfe4d5d32016-05-11 06:49:32 -070015 enum class Mode {
16 kLinearToSRGB,
17 kSRGBToLinear,
brianosmanfe4d5d32016-05-11 06:49:32 -070018 };
19
brianosman2d1ee792016-05-05 12:24:31 -070020 /**
Brian Osman964dec32017-01-26 09:32:33 -050021 * Creates an effect that applies the sRGB transfer function (or its inverse)
22 */
23 static sk_sp<GrFragmentProcessor> Make(Mode mode);
brianosman2d1ee792016-05-05 12:24:31 -070024
Brian Osman964dec32017-01-26 09:32:33 -050025 const char* name() const override { return "sRGB"; }
brianosman2d1ee792016-05-05 12:24:31 -070026
brianosmanfe4d5d32016-05-11 06:49:32 -070027 Mode mode() const { return fMode; }
brianosman2d1ee792016-05-05 12:24:31 -070028
29private:
Brian Osman964dec32017-01-26 09:32:33 -050030 GrSRGBEffect(Mode mode);
brianosman2d1ee792016-05-05 12:24:31 -070031
32 GrGLSLFragmentProcessor* onCreateGLSLInstance() const override;
Brian Salomon94efbf52016-11-29 13:43:05 -050033 void onGetGLSLProcessorKey(const GrShaderCaps&, GrProcessorKeyBuilder*) const override;
brianosman2d1ee792016-05-05 12:24:31 -070034 bool onIsEqual(const GrFragmentProcessor&) const override;
Brian Salomoncb30bb22017-02-12 09:28:54 -050035
Brian Salomon587e08f2017-01-27 10:59:27 -050036 GrColor4f constantOutputForConstantInput(GrColor4f input) const override;
brianosman2d1ee792016-05-05 12:24:31 -070037
brianosmanfe4d5d32016-05-11 06:49:32 -070038 Mode fMode;
brianosman2d1ee792016-05-05 12:24:31 -070039
40 GR_DECLARE_FRAGMENT_PROCESSOR_TEST;
41
brianosmanfe4d5d32016-05-11 06:49:32 -070042 typedef GrFragmentProcessor INHERITED;
brianosman2d1ee792016-05-05 12:24:31 -070043};
44
45#endif