Mathias Agopian | ff2ed70 | 2013-09-01 21:36:12 -0700 | [diff] [blame] | 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 | |
Dan Stoza | 9f26a9c | 2016-06-22 14:51:09 -0700 | [diff] [blame] | 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 | |
Mathias Agopian | ff2ed70 | 2013-09-01 21:36:12 -0700 | [diff] [blame] | 36 | class Daltonizer { |
| 37 | public: |
Dan Stoza | 9f26a9c | 2016-06-22 14:51:09 -0700 | [diff] [blame] | 38 | void setType(ColorBlindnessType type); |
| 39 | void setMode(ColorBlindnessMode mode); |
Mathias Agopian | ff2ed70 | 2013-09-01 21:36:12 -0700 | [diff] [blame] | 40 | |
| 41 | // returns the color transform to apply in the shader |
| 42 | const mat4& operator()(); |
| 43 | |
| 44 | private: |
| 45 | void update(); |
| 46 | |
Dan Stoza | 9f26a9c | 2016-06-22 14:51:09 -0700 | [diff] [blame] | 47 | ColorBlindnessType mType = ColorBlindnessType::None; |
| 48 | ColorBlindnessMode mMode = ColorBlindnessMode::Simulation; |
| 49 | bool mDirty = true; |
Mathias Agopian | ff2ed70 | 2013-09-01 21:36:12 -0700 | [diff] [blame] | 50 | mat4 mColorTransform; |
| 51 | }; |
| 52 | |
| 53 | } /* namespace android */ |
| 54 | #endif /* SF_EFFECTS_DALTONIZER_H_ */ |