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 | |
Mathias Agopian | 1d77b71 | 2017-02-17 15:46:13 -0800 | [diff] [blame] | 20 | #include <math/mat4.h> |
Mathias Agopian | ff2ed70 | 2013-09-01 21:36:12 -0700 | [diff] [blame] | 21 | |
| 22 | namespace android { |
| 23 | |
Isaac Chai | 1ec2d9a | 2024-04-11 20:10:34 +0000 | [diff] [blame^] | 24 | // Forward declare test class |
| 25 | class DaltonizerTest; |
| 26 | |
Dan Stoza | 9f26a9c | 2016-06-22 14:51:09 -0700 | [diff] [blame] | 27 | enum class ColorBlindnessType { |
| 28 | None, // Disables the Daltonizer |
| 29 | Protanomaly, // L (red) cone deficient |
| 30 | Deuteranomaly, // M (green) cone deficient (most common) |
| 31 | Tritanomaly // S (blue) cone deficient |
| 32 | }; |
| 33 | |
| 34 | enum class ColorBlindnessMode { |
| 35 | Simulation, |
| 36 | Correction |
| 37 | }; |
| 38 | |
Mathias Agopian | ff2ed70 | 2013-09-01 21:36:12 -0700 | [diff] [blame] | 39 | class Daltonizer { |
| 40 | public: |
Dan Stoza | 9f26a9c | 2016-06-22 14:51:09 -0700 | [diff] [blame] | 41 | void setType(ColorBlindnessType type); |
| 42 | void setMode(ColorBlindnessMode mode); |
Isaac Chai | 1ec2d9a | 2024-04-11 20:10:34 +0000 | [diff] [blame^] | 43 | // sets level for correction saturation, [0-10]. |
| 44 | void setLevel(int32_t level); |
Mathias Agopian | ff2ed70 | 2013-09-01 21:36:12 -0700 | [diff] [blame] | 45 | |
| 46 | // returns the color transform to apply in the shader |
| 47 | const mat4& operator()(); |
| 48 | |
Isaac Chai | 1ec2d9a | 2024-04-11 20:10:34 +0000 | [diff] [blame^] | 49 | // For testing. |
| 50 | friend class DaltonizerTest; |
| 51 | |
Mathias Agopian | ff2ed70 | 2013-09-01 21:36:12 -0700 | [diff] [blame] | 52 | private: |
| 53 | void update(); |
| 54 | |
Dan Stoza | 9f26a9c | 2016-06-22 14:51:09 -0700 | [diff] [blame] | 55 | ColorBlindnessType mType = ColorBlindnessType::None; |
| 56 | ColorBlindnessMode mMode = ColorBlindnessMode::Simulation; |
| 57 | bool mDirty = true; |
Mathias Agopian | ff2ed70 | 2013-09-01 21:36:12 -0700 | [diff] [blame] | 58 | mat4 mColorTransform; |
Isaac Chai | 1ec2d9a | 2024-04-11 20:10:34 +0000 | [diff] [blame^] | 59 | // level of error spreading, [0.0-1.0]. |
| 60 | float mLevel = 0.7f; |
Mathias Agopian | ff2ed70 | 2013-09-01 21:36:12 -0700 | [diff] [blame] | 61 | }; |
| 62 | |
| 63 | } /* namespace android */ |
| 64 | #endif /* SF_EFFECTS_DALTONIZER_H_ */ |