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

Commit c949cdee authored by Melody Hsu's avatar Melody Hsu
Browse files

Clean up uses of refreshStartTime for stats.

refreshStartTime is keeps track of frame refreshes for
stats and can be set from SurfaceFlinger. This makes
subsequent changes in refactoring
SurfaceFlinger#composite cleaner and makes tracking the
metric more consistent between changes.

The refreshStartTime field can be removed entirely from
LayerFE's CompositionResult and removed as an argument
in LayerFE#onPreComposition.

Bug: b/294936197, b/329275965
Test: presubmit
Change-Id: I97988315f8982d05aec4b2684d4f5f1826a0fefa
parent 48d4be6d
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -19,6 +19,7 @@
#include <chrono>
#include <optional>
#include <vector>
#include "utils/Timers.h"

#include <compositionengine/Display.h>
#include <compositionengine/LayerFE.h>
@@ -105,6 +106,9 @@ struct CompositionRefreshArgs {
    bool hasTrustedPresentationListener = false;

    ICEPowerCallback* powerCallback = nullptr;

    // System time for when frame refresh starts. Used for stats.
    nsecs_t refreshStartTime = 0;
};

} // namespace android::compositionengine
+1 −2
Original line number Diff line number Diff line
@@ -58,8 +58,7 @@ public:
    // Called before composition starts. Should return true if this layer has
    // pending updates which would require an extra display refresh cycle to
    // process.
    virtual bool onPreComposition(nsecs_t refreshStartTime,
                                  bool updatingOutputGeometryThisFrame) = 0;
    virtual bool onPreComposition(bool updatingOutputGeometryThisFrame) = 0;

    struct ClientCompositionTargetSettings {
        enum class BlurSetting {
+1 −1
Original line number Diff line number Diff line
@@ -43,7 +43,7 @@ public:

    MOCK_CONST_METHOD0(getCompositionState, const LayerFECompositionState*());

    MOCK_METHOD2(onPreComposition, bool(nsecs_t, bool));
    MOCK_METHOD1(onPreComposition, bool(bool));

    MOCK_CONST_METHOD1(prepareClientComposition,
                       std::optional<compositionengine::LayerFE::LayerSettings>(
+2 −2
Original line number Diff line number Diff line
@@ -181,10 +181,10 @@ void CompositionEngine::preComposition(CompositionRefreshArgs& args) {

    bool needsAnotherUpdate = false;

    mRefreshStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
    mRefreshStartTime = args.refreshStartTime;

    for (auto& layer : args.layers) {
        if (layer->onPreComposition(mRefreshStartTime, args.updatingOutputGeometryThisFrame)) {
        if (layer->onPreComposition(args.updatingOutputGeometryThisFrame)) {
            needsAnotherUpdate = true;
        }
    }
+10 −12
Original line number Diff line number Diff line
@@ -214,6 +214,7 @@ struct CompositionTestPreComposition : public CompositionEngineTest {

TEST_F(CompositionTestPreComposition, preCompositionSetsFrameTimestamp) {
    const nsecs_t before = systemTime(SYSTEM_TIME_MONOTONIC);
    mRefreshArgs.refreshStartTime = systemTime(SYSTEM_TIME_MONOTONIC);
    mEngine.preComposition(mRefreshArgs);
    const nsecs_t after = systemTime(SYSTEM_TIME_MONOTONIC);

@@ -226,12 +227,9 @@ TEST_F(CompositionTestPreComposition, preCompositionInvokesLayerPreCompositionWi
    nsecs_t ts1 = 0;
    nsecs_t ts2 = 0;
    nsecs_t ts3 = 0;
    EXPECT_CALL(*mLayer1FE, onPreComposition(_, _))
            .WillOnce(DoAll(SaveArg<0>(&ts1), Return(false)));
    EXPECT_CALL(*mLayer2FE, onPreComposition(_, _))
            .WillOnce(DoAll(SaveArg<0>(&ts2), Return(false)));
    EXPECT_CALL(*mLayer3FE, onPreComposition(_, _))
            .WillOnce(DoAll(SaveArg<0>(&ts3), Return(false)));
    EXPECT_CALL(*mLayer1FE, onPreComposition(_)).WillOnce(DoAll(SaveArg<0>(&ts1), Return(false)));
    EXPECT_CALL(*mLayer2FE, onPreComposition(_)).WillOnce(DoAll(SaveArg<0>(&ts2), Return(false)));
    EXPECT_CALL(*mLayer3FE, onPreComposition(_)).WillOnce(DoAll(SaveArg<0>(&ts3), Return(false)));

    mRefreshArgs.outputs = {mOutput1};
    mRefreshArgs.layers = {mLayer1FE, mLayer2FE, mLayer3FE};
@@ -245,9 +243,9 @@ TEST_F(CompositionTestPreComposition, preCompositionInvokesLayerPreCompositionWi
}

TEST_F(CompositionTestPreComposition, preCompositionDefaultsToNoUpdateNeeded) {
    EXPECT_CALL(*mLayer1FE, onPreComposition(_, _)).WillOnce(Return(false));
    EXPECT_CALL(*mLayer2FE, onPreComposition(_, _)).WillOnce(Return(false));
    EXPECT_CALL(*mLayer3FE, onPreComposition(_, _)).WillOnce(Return(false));
    EXPECT_CALL(*mLayer1FE, onPreComposition(_)).WillOnce(Return(false));
    EXPECT_CALL(*mLayer2FE, onPreComposition(_)).WillOnce(Return(false));
    EXPECT_CALL(*mLayer3FE, onPreComposition(_)).WillOnce(Return(false));

    mEngine.setNeedsAnotherUpdateForTest(true);

@@ -262,9 +260,9 @@ TEST_F(CompositionTestPreComposition, preCompositionDefaultsToNoUpdateNeeded) {

TEST_F(CompositionTestPreComposition,
       preCompositionSetsNeedsAnotherUpdateIfAtLeastOneLayerRequestsIt) {
    EXPECT_CALL(*mLayer1FE, onPreComposition(_, _)).WillOnce(Return(true));
    EXPECT_CALL(*mLayer2FE, onPreComposition(_, _)).WillOnce(Return(false));
    EXPECT_CALL(*mLayer3FE, onPreComposition(_, _)).WillOnce(Return(false));
    EXPECT_CALL(*mLayer1FE, onPreComposition(_)).WillOnce(Return(true));
    EXPECT_CALL(*mLayer2FE, onPreComposition(_)).WillOnce(Return(false));
    EXPECT_CALL(*mLayer3FE, onPreComposition(_)).WillOnce(Return(false));

    mRefreshArgs.outputs = {mOutput1};
    mRefreshArgs.layers = {mLayer1FE, mLayer2FE, mLayer3FE};
Loading