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 <math/mat4.h> 21 22 namespace android { 23 24 // Forward declare test class 25 class DaltonizerTest; 26 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 39 class Daltonizer { 40 public: 41 void setType(ColorBlindnessType type); 42 void setMode(ColorBlindnessMode mode); 43 // sets level for correction saturation, [0-10]. 44 void setLevel(int32_t level); 45 46 // returns the color transform to apply in the shader 47 const mat4& operator()(); 48 49 // For testing. 50 friend class DaltonizerTest; 51 52 private: 53 void update(); 54 55 ColorBlindnessType mType = ColorBlindnessType::None; 56 ColorBlindnessMode mMode = ColorBlindnessMode::Simulation; 57 bool mDirty = true; 58 mat4 mColorTransform; 59 // level of error spreading, [0.0-1.0]. 60 float mLevel = 0.7f; 61 }; 62 63 } /* namespace android */ 64 #endif /* SF_EFFECTS_DALTONIZER_H_ */ 65