Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 60efde74 authored by Steve Kondik's avatar Steve Kondik
Browse files

surfaceflinger: Add support for secondary color matrix

 * Add a new binder transaction for applying a secondary color matrix
   using RenderEngine. This stacks with the primary color matrix
   (if set for a11y) to enable GPU-based display calibration.

Change-Id: I766455bfb5212e2dcc8ad0cb8ebdddbda87af732
parent 30bc76d6
Loading
Loading
Loading
Loading
+29 −3
Original line number Diff line number Diff line
@@ -154,6 +154,7 @@ SurfaceFlinger::SurfaceFlinger()
        mHWVsyncAvailable(false),
        mDaltonize(false),
        mHasColorMatrix(false),
        mHasSecondaryColorMatrix(false),
        mHasPoweredOff(false),
        mFrameBuckets(),
        mTotalTime(0),
@@ -1214,7 +1215,7 @@ void SurfaceFlinger::setUpHWComposer() {

                    layer->setGeometry(displayDevice);
                    if (mDebugDisableHWC || mDebugRegion || mDaltonize ||
                            mHasColorMatrix) {
                            mHasColorMatrix || mHasSecondaryColorMatrix) {
                        layer->forceClientComposition(hwcId);
                    }
                }
@@ -1905,11 +1906,14 @@ void SurfaceFlinger::doDisplayComposition(const sp<const DisplayDevice>& hw,
        }
    }

    if (CC_LIKELY(!mDaltonize && !mHasColorMatrix)) {
    if (CC_LIKELY(!mDaltonize && !mHasColorMatrix && !mHasSecondaryColorMatrix)) {
        if (!doComposeSurfaces(hw, dirtyRegion)) return;
    } else {
        RenderEngine& engine(getRenderEngine());
        mat4 colorMatrix = mColorMatrix;
        if (mHasSecondaryColorMatrix) {
            colorMatrix = mHasColorMatrix ? (colorMatrix * mSecondaryColorMatrix) : mSecondaryColorMatrix;
        }
        if (mDaltonize) {
            colorMatrix = colorMatrix * mDaltonizer();
        }
@@ -2871,7 +2875,7 @@ void SurfaceFlinger::dumpAllLocked(const Vector<String16>& args, size_t& index,
    result.append("h/w composer state:\n");
    colorizer.reset(result);
    bool hwcDisabled = mDebugDisableHWC || mDebugRegion || mDaltonize ||
            mHasColorMatrix;
            mHasColorMatrix || mHasSecondaryColorMatrix;
    result.appendFormat("  h/w composer %s\n",
            hwcDisabled ? "disabled" : "enabled");
    hwc.dump(result);
@@ -3082,6 +3086,28 @@ status_t SurfaceFlinger::onTransact(
                mSFEventThread->setPhaseOffset(static_cast<nsecs_t>(n));
                return NO_ERROR;
            }
            case 1030: {
                // apply a secondary color matrix
                // this will be combined with any other transformations
                n = data.readInt32();
                mHasSecondaryColorMatrix = 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++) {
                          mSecondaryColorMatrix[i][j] = data.readFloat();
                      }
                    }
                } else {
                    mSecondaryColorMatrix = mat4();
                }
                invalidateHwcGeometry();
                repaintEverything();
                return NO_ERROR;
            }

        }
    }
    return err;
+3 −0
Original line number Diff line number Diff line
@@ -560,6 +560,9 @@ private:
    mat4 mColorMatrix;
    bool mHasColorMatrix;

    mat4 mSecondaryColorMatrix;
    bool mHasSecondaryColorMatrix;

    // Static screen stats
    bool mHasPoweredOff;
    static const size_t NUM_BUCKETS = 8; // < 1-7, 7+