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

Commit 747321cc authored by Peiyong Lin's avatar Peiyong Lin
Browse files

[SurfaceFlinger] Avoid comparing to identity matrix.

hasColorTransform is called every time on every layer that needs to be client
composited. This patch adds a boolean for that check and move that check to
when color transform matrix is set.

BUG: 111562338
Test: Build, flash and boot.
Change-Id: Icbd17458dc194f10f744ee7cc72c3462ae239a28
parent f53ae7ed
Loading
Loading
Loading
Loading
+6 −2
Original line number Original line Diff line number Diff line
@@ -102,6 +102,7 @@ Layer::Layer(const LayerCreationArgs& args)
    mCurrentState.hdrMetadata.validTypes = 0;
    mCurrentState.hdrMetadata.validTypes = 0;
    mCurrentState.surfaceDamageRegion.clear();
    mCurrentState.surfaceDamageRegion.clear();
    mCurrentState.api = -1;
    mCurrentState.api = -1;
    mCurrentState.hasColorTransform = false;


    // drawing state & current state are identical
    // drawing state & current state are identical
    mDrawingState = mCurrentState;
    mDrawingState = mCurrentState;
@@ -1547,11 +1548,15 @@ bool Layer::detachChildren() {
}
}


bool Layer::setColorTransform(const mat4& matrix) {
bool Layer::setColorTransform(const mat4& matrix) {
    static const mat4 identityMatrix = mat4();

    if (mCurrentState.colorTransform == matrix) {
    if (mCurrentState.colorTransform == matrix) {
        return false;
        return false;
    }
    }
    ++mCurrentState.sequence;
    ++mCurrentState.sequence;
    mCurrentState.colorTransform = matrix;
    mCurrentState.colorTransform = matrix;
    mCurrentState.hasColorTransform = matrix != identityMatrix;
    mCurrentState.modified = true;
    setTransactionFlags(eTransactionNeeded);
    setTransactionFlags(eTransactionNeeded);
    return true;
    return true;
}
}
@@ -1561,8 +1566,7 @@ const mat4& Layer::getColorTransform() const {
}
}


bool Layer::hasColorTransform() const {
bool Layer::hasColorTransform() const {
    static const mat4 identityMatrix = mat4();
    return getDrawingState().hasColorTransform;
    return getDrawingState().colorTransform != identityMatrix;
}
}


bool Layer::isLegacyDataSpace() const {
bool Layer::isLegacyDataSpace() const {
+1 −0
Original line number Original line Diff line number Diff line
@@ -182,6 +182,7 @@ public:


        sp<NativeHandle> sidebandStream;
        sp<NativeHandle> sidebandStream;
        mat4 colorTransform;
        mat4 colorTransform;
        bool hasColorTransform;
    };
    };


    explicit Layer(const LayerCreationArgs& args);
    explicit Layer(const LayerCreationArgs& args);