summaryrefslogtreecommitdiff
path: root/services/surfaceflinger/SurfaceFlinger.cpp
diff options
context:
space:
mode:
author Mathias Agopian <mathias@google.com> 2013-09-01 21:36:12 -0700
committer Mathias Agopian <mathias@google.com> 2013-09-04 22:11:15 -0700
commitff2ed70fa30f04b90dd1a2c06ec2319e157152d7 (patch)
treece07917c9844239d37b000afd2518b08028ed8be /services/surfaceflinger/SurfaceFlinger.cpp
parent1d4d8f94e2989b7c8667602304df9059d2701653 (diff)
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
Diffstat (limited to 'services/surfaceflinger/SurfaceFlinger.cpp')
-rw-r--r--services/surfaceflinger/SurfaceFlinger.cpp37
1 files changed, 33 insertions, 4 deletions
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 <cutils/compiler.h>
#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<count ; ++i, ++cur) {
const sp<Layer>& 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<const DisplayDevice>& 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<String16>& 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<const DisplayDevice> 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;
}