From ff2ed70fa30f04b90dd1a2c06ec2319e157152d7 Mon Sep 17 00:00:00 2001 From: Mathias Agopian Date: Sun, 1 Sep 2013 21:36:12 -0700 Subject: color blindness enhancement This is an attempt at improving the experience of users with color vision impairement. At this time this feature can only be enabled for debugging: adb shell service call SurfaceFlinger 1014 i32 PARAM with PARAM: 0 : disabled 1 : protanomaly/protanopia simulation 2 : deuteranomaly/deuteranopia simulation 3 : tritanopia/tritanomaly simulation 11, 12, 13: same as above w/ attempted correction/enhancement The enhancement algorithm tries to spread the "error" such that tones that would otherwise appear similar can be distinguished. Bug: 9465644 Change-Id: I860f7eed0cb81f54ef9cf24ad78155b6395ade48 --- services/surfaceflinger/SurfaceFlinger.cpp | 37 ++++++++++++++++++++++++++---- 1 file changed, 33 insertions(+), 4 deletions(-) (limited to 'services/surfaceflinger/SurfaceFlinger.cpp') diff --git a/services/surfaceflinger/SurfaceFlinger.cpp b/services/surfaceflinger/SurfaceFlinger.cpp index 0323cb73a1..fa1ea09896 100644 --- a/services/surfaceflinger/SurfaceFlinger.cpp +++ b/services/surfaceflinger/SurfaceFlinger.cpp @@ -68,7 +68,10 @@ #include "DisplayHardware/HWComposer.h" #include "DisplayHardware/VirtualDisplaySurface.h" +#include "Effects/Daltonizer.h" + #include "RenderEngine/RenderEngine.h" +#include #define DISPLAY_COUNT 1 @@ -110,7 +113,8 @@ SurfaceFlinger::SurfaceFlinger() mLastSwapBufferTime(0), mDebugInTransaction(0), mLastTransactionTime(0), - mBootFinished(false) + mBootFinished(false), + mDaltonize(false) { ALOGI("SurfaceFlinger is starting"); @@ -865,7 +869,7 @@ void SurfaceFlinger::setUpHWComposer() { for (size_t i=0 ; cur!=end && i& layer(currentLayers[i]); layer->setGeometry(hw, *cur); - if (mDebugDisableHWC || mDebugRegion) { + if (mDebugDisableHWC || mDebugRegion || mDaltonize) { cur->setSkip(true); } } @@ -1479,7 +1483,14 @@ void SurfaceFlinger::doDisplayComposition(const sp& hw, } } - doComposeSurfaces(hw, dirtyRegion); + if (CC_LIKELY(!mDaltonize)) { + doComposeSurfaces(hw, dirtyRegion); + } else { + RenderEngine& engine(getRenderEngine()); + engine.beginGroup(mDaltonizer()); + doComposeSurfaces(hw, dirtyRegion); + engine.endGroup(); + } // update the swap region and clear the dirty region hw->swapRegion.orSelf(dirtyRegion); @@ -2360,7 +2371,7 @@ void SurfaceFlinger::dumpAllLocked(const Vector& args, size_t& index, colorizer.reset(result); result.appendFormat(" h/w composer %s and %s\n", hwc.initCheck()==NO_ERROR ? "present" : "not present", - (mDebugDisableHWC || mDebugRegion) ? "disabled" : "enabled"); + (mDebugDisableHWC || mDebugRegion || mDaltonize) ? "disabled" : "enabled"); hwc.dump(result); /* @@ -2505,6 +2516,24 @@ status_t SurfaceFlinger::onTransact( Mutex::Autolock _l(mStateLock); sp hw(getDefaultDisplayDevice()); reply->writeInt32(hw->getPageFlipCount()); + return NO_ERROR; + } + case 1014: { + // daltonize + n = data.readInt32(); + switch (n % 10) { + case 1: mDaltonizer.setType(Daltonizer::protanomaly); break; + case 2: mDaltonizer.setType(Daltonizer::deuteranomaly); break; + case 3: mDaltonizer.setType(Daltonizer::tritanomaly); break; + } + if (n >= 10) { + mDaltonizer.setMode(Daltonizer::correction); + } else { + mDaltonizer.setMode(Daltonizer::simulation); + } + mDaltonize = n > 0; + invalidateHwcGeometry(); + repaintEverything(); } return NO_ERROR; } -- cgit v1.2.3-59-g8ed1b