1 /*
2  * Copyright 2013 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #ifndef SF_EFFECTS_DALTONIZER_H_
18 #define SF_EFFECTS_DALTONIZER_H_
19 
20 #include <math/mat4.h>
21 
22 namespace android {
23 
24 enum class ColorBlindnessType {
25     None,               // Disables the Daltonizer
26     Protanomaly,        // L (red) cone deficient
27     Deuteranomaly,      // M (green) cone deficient (most common)
28     Tritanomaly         // S (blue) cone deficient
29 };
30 
31 enum class ColorBlindnessMode {
32     Simulation,
33     Correction
34 };
35 
36 class Daltonizer {
37 public:
38     void setType(ColorBlindnessType type);
39     void setMode(ColorBlindnessMode mode);
40 
41     // returns the color transform to apply in the shader
42     const mat4& operator()();
43 
44 private:
45     void update();
46 
47     ColorBlindnessType mType = ColorBlindnessType::None;
48     ColorBlindnessMode mMode = ColorBlindnessMode::Simulation;
49     bool mDirty = true;
50     mat4 mColorTransform;
51 };
52 
53 } /* namespace android */
54 #endif /* SF_EFFECTS_DALTONIZER_H_ */
55