diff options
Diffstat (limited to 'services/surfaceflinger/SurfaceFlinger.cpp')
-rw-r--r-- | services/surfaceflinger/SurfaceFlinger.cpp | 38 |
1 files changed, 32 insertions, 6 deletions
diff --git a/services/surfaceflinger/SurfaceFlinger.cpp b/services/surfaceflinger/SurfaceFlinger.cpp index e374548..3ae335f 100644 --- a/services/surfaceflinger/SurfaceFlinger.cpp +++ b/services/surfaceflinger/SurfaceFlinger.cpp @@ -114,7 +114,8 @@ SurfaceFlinger::SurfaceFlinger() mDebugInTransaction(0), mLastTransactionTime(0), mBootFinished(false), - mDaltonize(false) + mDaltonize(false), + mHasColorMatrix(false) { ALOGI("SurfaceFlinger is starting"); @@ -880,7 +881,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 || mDaltonize) { + if (mDebugDisableHWC || mDebugRegion || mDaltonize || mHasColorMatrix) { cur->setSkip(true); } } @@ -1500,11 +1501,15 @@ void SurfaceFlinger::doDisplayComposition(const sp<const DisplayDevice>& hw, } } - if (CC_LIKELY(!mDaltonize)) { + if (CC_LIKELY(!mDaltonize && !mHasColorMatrix)) { doComposeSurfaces(hw, dirtyRegion); } else { RenderEngine& engine(getRenderEngine()); - engine.beginGroup(mDaltonizer()); + mat4 colorMatrix = mColorMatrix; + if (mDaltonize) { + colorMatrix = colorMatrix * mDaltonizer(); + } + engine.beginGroup(colorMatrix); doComposeSurfaces(hw, dirtyRegion); engine.endGroup(); } @@ -2389,7 +2394,8 @@ 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 || mDaltonize) ? "disabled" : "enabled"); + (mDebugDisableHWC || mDebugRegion || mDaltonize + || mHasColorMatrix) ? "disabled" : "enabled"); hwc.dump(result); /* @@ -2552,8 +2558,28 @@ status_t SurfaceFlinger::onTransact( mDaltonize = n > 0; invalidateHwcGeometry(); repaintEverything(); + return NO_ERROR; + } + case 1015: { + // apply a color matrix + n = data.readInt32(); + mHasColorMatrix = n ? 1 : 0; + if (n) { + // color matrix is sent as mat3 matrix followed by vec3 + // offset, then packed into a mat4 where the last row is + // the offset and extra values are 0 + for (size_t i = 0 ; i < 4; i++) { + for (size_t j = 0; j < 4; j++) { + mColorMatrix[i][j] = data.readFloat(); + } + } + } else { + mColorMatrix = mat4(); + } + invalidateHwcGeometry(); + repaintEverything(); + return NO_ERROR; } - return NO_ERROR; } } return err; |