• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 <ui/mat4.h>
21 
22 namespace android {
23 
24 class Daltonizer {
25 public:
26     enum ColorBlindnessTypes {
27         protanopia,         // L (red) cone missing
28         deuteranopia,       // M (green) cone missing
29         tritanopia,         // S (blue) cone missing
30         protanomaly,        // L (red) cone deficient
31         deuteranomaly,      // M (green) cone deficient (most common)
32         tritanomaly         // S (blue) cone deficient
33     };
34 
35     enum Mode {
36         simulation,
37         correction
38     };
39 
40     Daltonizer();
41     ~Daltonizer();
42 
43     void setType(ColorBlindnessTypes type);
44     void setMode(Mode mode);
45 
46     // returns the color transform to apply in the shader
47     const mat4& operator()();
48 
49 private:
50     void update();
51 
52     ColorBlindnessTypes mType;
53     Mode mMode;
54     bool mDirty;
55     mat4 mColorTransform;
56 };
57 
58 } /* namespace android */
59 #endif /* SF_EFFECTS_DALTONIZER_H_ */
60