blob: f5eaae7ab4da1cb38ce6367094ee0946eb87740a [file] [log] [blame]
Mathias Agopianff2ed702013-09-01 21:36:12 -07001/*
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 Agopian1d77b712017-02-17 15:46:13 -080020#include <math/mat4.h>
Mathias Agopianff2ed702013-09-01 21:36:12 -070021
22namespace android {
23
Isaac Chai1ec2d9a2024-04-11 20:10:34 +000024// Forward declare test class
25class DaltonizerTest;
26
Dan Stoza9f26a9c2016-06-22 14:51:09 -070027enum 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
34enum class ColorBlindnessMode {
35 Simulation,
36 Correction
37};
38
Mathias Agopianff2ed702013-09-01 21:36:12 -070039class Daltonizer {
40public:
Dan Stoza9f26a9c2016-06-22 14:51:09 -070041 void setType(ColorBlindnessType type);
42 void setMode(ColorBlindnessMode mode);
Isaac Chai1ec2d9a2024-04-11 20:10:34 +000043 // sets level for correction saturation, [0-10].
44 void setLevel(int32_t level);
Mathias Agopianff2ed702013-09-01 21:36:12 -070045
46 // returns the color transform to apply in the shader
47 const mat4& operator()();
48
Isaac Chai1ec2d9a2024-04-11 20:10:34 +000049 // For testing.
50 friend class DaltonizerTest;
51
Mathias Agopianff2ed702013-09-01 21:36:12 -070052private:
53 void update();
54
Dan Stoza9f26a9c2016-06-22 14:51:09 -070055 ColorBlindnessType mType = ColorBlindnessType::None;
56 ColorBlindnessMode mMode = ColorBlindnessMode::Simulation;
57 bool mDirty = true;
Mathias Agopianff2ed702013-09-01 21:36:12 -070058 mat4 mColorTransform;
Isaac Chai1ec2d9a2024-04-11 20:10:34 +000059 // level of error spreading, [0.0-1.0].
60 float mLevel = 0.7f;
Mathias Agopianff2ed702013-09-01 21:36:12 -070061};
62
63} /* namespace android */
64#endif /* SF_EFFECTS_DALTONIZER_H_ */