blob: d21b155f85059ec94eb32304b4a387a4b8f686cf [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
20#include <ui/mat4.h>
21
22namespace android {
23
Dan Stoza9f26a9c2016-06-22 14:51:09 -070024enum 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
31enum class ColorBlindnessMode {
32 Simulation,
33 Correction
34};
35
Mathias Agopianff2ed702013-09-01 21:36:12 -070036class Daltonizer {
37public:
Dan Stoza9f26a9c2016-06-22 14:51:09 -070038 void setType(ColorBlindnessType type);
39 void setMode(ColorBlindnessMode mode);
Mathias Agopianff2ed702013-09-01 21:36:12 -070040
41 // returns the color transform to apply in the shader
42 const mat4& operator()();
43
44private:
45 void update();
46
Dan Stoza9f26a9c2016-06-22 14:51:09 -070047 ColorBlindnessType mType = ColorBlindnessType::None;
48 ColorBlindnessMode mMode = ColorBlindnessMode::Simulation;
49 bool mDirty = true;
Mathias Agopianff2ed702013-09-01 21:36:12 -070050 mat4 mColorTransform;
51};
52
53} /* namespace android */
54#endif /* SF_EFFECTS_DALTONIZER_H_ */