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

Commit e8334907 authored by Brian Lindahl's avatar Brian Lindahl
Browse files

Rename of ActivePictureUpdater to ActivePictureTracker

Bug: 337330263
Test: build
Test: atest ActivePictureTrackerTest
Flag: com.android.graphics.libgui.flags.apply_picture_profiles
Change-Id: I2ba2c707034312782d7bdd73d55673b740d651cd
parent 0b577d98
Loading
Loading
Loading
Loading
+4 −4
Original line number Diff line number Diff line
@@ -14,7 +14,7 @@
 * limitations under the License.
 */

#include "ActivePictureUpdater.h"
#include "ActivePictureTracker.h"

#include <algorithm>

@@ -23,7 +23,7 @@

namespace android {

void ActivePictureUpdater::onLayerComposed(const Layer& layer, const LayerFE& layerFE,
void ActivePictureTracker::onLayerComposed(const Layer& layer, const LayerFE& layerFE,
                                           const CompositionResult& result) {
    if (result.wasPictureProfileCommitted) {
        gui::ActivePicture picture;
@@ -39,7 +39,7 @@ void ActivePictureUpdater::onLayerComposed(const Layer& layer, const LayerFE& la
    }
}

bool ActivePictureUpdater::updateAndHasChanged() {
bool ActivePictureTracker::updateAndHasChanged() {
    bool hasChanged = true;
    if (mNewActivePictures.size() == mOldActivePictures.size()) {
        auto compare = [](const gui::ActivePicture& lhs, const gui::ActivePicture& rhs) -> int {
@@ -59,7 +59,7 @@ bool ActivePictureUpdater::updateAndHasChanged() {
    return hasChanged;
}

const std::vector<gui::ActivePicture>& ActivePictureUpdater::getActivePictures() const {
const std::vector<gui::ActivePicture>& ActivePictureTracker::getActivePictures() const {
    return mOldActivePictures;
}

+1 −1
Original line number Diff line number Diff line
@@ -27,7 +27,7 @@ class LayerFE;
struct CompositionResult;

// Keeps track of active pictures - layers that are undergoing picture processing.
class ActivePictureUpdater {
class ActivePictureTracker {
public:
    // Called for each visible layer when SurfaceFlinger finishes composing.
    void onLayerComposed(const Layer& layer, const LayerFE& layerFE,
+4 −4
Original line number Diff line number Diff line
@@ -126,7 +126,7 @@
#include <gui/SchedulingPolicy.h>
#include <gui/SyncScreenCaptureListener.h>
#include <ui/DisplayIdentification.h>
#include "ActivePictureUpdater.h"
#include "ActivePictureTracker.h"
#include "BackgroundExecutor.h"
#include "Client.h"
#include "ClientCache.h"
@@ -2911,7 +2911,7 @@ CompositeResultsPerDisplay SurfaceFlinger::composite(
            layer->setWasClientComposed(compositionResult.lastClientCompositionFence);
        }
        if (com_android_graphics_libgui_flags_apply_picture_profiles()) {
            mActivePictureUpdater.onLayerComposed(*layer, *layerFE, compositionResult);
            mActivePictureTracker.onLayerComposed(*layer, *layerFE, compositionResult);
        }
    }

@@ -3314,10 +3314,10 @@ void SurfaceFlinger::onCompositionPresented(PhysicalDisplayId pacesetterId,
    if (com_android_graphics_libgui_flags_apply_picture_profiles()) {
        // Track, update and notify changes to active pictures - layers that are undergoing picture
        // processing
        if (mActivePictureUpdater.updateAndHasChanged() || haveNewActivePictureListener) {
        if (mActivePictureTracker.updateAndHasChanged() || haveNewActivePictureListener) {
            if (activePictureListener) {
                activePictureListener->onActivePicturesChanged(
                        mActivePictureUpdater.getActivePictures());
                        mActivePictureTracker.getActivePictures());
            }
        }
    }
+2 −2
Original line number Diff line number Diff line
@@ -69,7 +69,7 @@
#include <ui/FenceResult.h>

#include <common/FlagManager.h>
#include "ActivePictureUpdater.h"
#include "ActivePictureTracker.h"
#include "BackgroundExecutor.h"
#include "Display/DisplayModeController.h"
#include "Display/PhysicalDisplay.h"
@@ -1404,7 +1404,7 @@ private:

    sp<gui::IActivePictureListener> mActivePictureListener GUARDED_BY(mStateLock);
    bool mHaveNewActivePictureListener GUARDED_BY(mStateLock);
    ActivePictureUpdater mActivePictureUpdater GUARDED_BY(kMainThreadContext);
    ActivePictureTracker mActivePictureTracker GUARDED_BY(kMainThreadContext);

    std::atomic<ui::Transform::RotationFlags> mActiveDisplayTransformHint;

+74 −74
Original line number Diff line number Diff line
@@ -24,7 +24,7 @@
#include <mock/MockLayer.h>
#include <renderengine/mock/RenderEngine.h>

#include "ActivePictureUpdater.h"
#include "ActivePictureTracker.h"
#include "LayerFE.h"
#include "TestableSurfaceFlinger.h"

@@ -48,7 +48,7 @@ public:
    LayerSnapshot& snapshot;
};

class ActivePictureUpdaterTest : public testing::Test {
class ActivePictureTrackerTest : public testing::Test {
protected:
    SurfaceFlinger* flinger() {
        if (!mFlingerSetup) {
@@ -84,113 +84,113 @@ void PrintTo(const ActivePicture& activePicture, std::ostream* os) {
    *os << activePicture.toString();
}

TEST_F(ActivePictureUpdaterTest, notCalledWithNoProfile) {
TEST_F(ActivePictureTrackerTest, notCalledWithNoProfile) {
    sp<NiceMock<MockLayer>> layer = sp<NiceMock<MockLayer>>::make(flinger(), 100);
    TestableLayerFE layerFE;
    EXPECT_CALL(*layer, getOwnerUid()).WillRepeatedly(Return(uid_t(10)));

    ActivePictureUpdater updater;
    ActivePictureTracker tracker;
    {
        layerFE.snapshot.pictureProfileHandle = PictureProfileHandle::NONE;
        updater.onLayerComposed(*layer, layerFE, layerFE.stealCompositionResult());
        tracker.onLayerComposed(*layer, layerFE, layerFE.stealCompositionResult());

        ASSERT_FALSE(updater.updateAndHasChanged());
        ASSERT_FALSE(tracker.updateAndHasChanged());
    }
}

TEST_F(ActivePictureUpdaterTest, calledWhenLayerStartsUsingProfile) {
TEST_F(ActivePictureTrackerTest, calledWhenLayerStartsUsingProfile) {
    sp<NiceMock<MockLayer>> layer = sp<NiceMock<MockLayer>>::make(flinger(), 100);
    TestableLayerFE layerFE;
    EXPECT_CALL(*layer, getOwnerUid()).WillRepeatedly(Return(uid_t(10)));

    ActivePictureUpdater updater;
    ActivePictureTracker tracker;
    {
        layerFE.snapshot.pictureProfileHandle = PictureProfileHandle::NONE;
        updater.onLayerComposed(*layer, layerFE, layerFE.stealCompositionResult());
        tracker.onLayerComposed(*layer, layerFE, layerFE.stealCompositionResult());

        ASSERT_FALSE(updater.updateAndHasChanged());
        ASSERT_FALSE(tracker.updateAndHasChanged());
    }
    {
        layerFE.snapshot.pictureProfileHandle = PictureProfileHandle(1);
        layerFE.onPictureProfileCommitted();
        updater.onLayerComposed(*layer, layerFE, layerFE.stealCompositionResult());
        tracker.onLayerComposed(*layer, layerFE, layerFE.stealCompositionResult());

        ASSERT_TRUE(updater.updateAndHasChanged());
        EXPECT_THAT(updater.getActivePictures(), UnorderedElementsAre({{100, 10, 1}}));
        ASSERT_TRUE(tracker.updateAndHasChanged());
        EXPECT_THAT(tracker.getActivePictures(), UnorderedElementsAre({{100, 10, 1}}));
    }
}

TEST_F(ActivePictureUpdaterTest, notCalledWhenLayerContinuesUsingProfile) {
TEST_F(ActivePictureTrackerTest, notCalledWhenLayerContinuesUsingProfile) {
    sp<NiceMock<MockLayer>> layer = sp<NiceMock<MockLayer>>::make(flinger(), 100);
    TestableLayerFE layerFE;
    EXPECT_CALL(*layer, getOwnerUid()).WillRepeatedly(Return(uid_t(10)));

    ActivePictureUpdater updater;
    ActivePictureTracker tracker;
    {
        layerFE.snapshot.pictureProfileHandle = PictureProfileHandle(1);
        layerFE.onPictureProfileCommitted();
        updater.onLayerComposed(*layer, layerFE, layerFE.stealCompositionResult());
        tracker.onLayerComposed(*layer, layerFE, layerFE.stealCompositionResult());

        ASSERT_TRUE(updater.updateAndHasChanged());
        EXPECT_THAT(updater.getActivePictures(), UnorderedElementsAre({{100, 10, 1}}));
        ASSERT_TRUE(tracker.updateAndHasChanged());
        EXPECT_THAT(tracker.getActivePictures(), UnorderedElementsAre({{100, 10, 1}}));
    }
    {
        layerFE.snapshot.pictureProfileHandle = PictureProfileHandle(1);
        layerFE.onPictureProfileCommitted();
        updater.onLayerComposed(*layer, layerFE, layerFE.stealCompositionResult());
        tracker.onLayerComposed(*layer, layerFE, layerFE.stealCompositionResult());

        ASSERT_FALSE(updater.updateAndHasChanged());
        ASSERT_FALSE(tracker.updateAndHasChanged());
    }
}

TEST_F(ActivePictureUpdaterTest, calledWhenLayerStopsUsingProfile) {
TEST_F(ActivePictureTrackerTest, calledWhenLayerStopsUsingProfile) {
    sp<NiceMock<MockLayer>> layer = sp<NiceMock<MockLayer>>::make(flinger(), 100);
    TestableLayerFE layerFE;
    EXPECT_CALL(*layer, getOwnerUid()).WillRepeatedly(Return(uid_t(10)));

    ActivePictureUpdater updater;
    ActivePictureTracker tracker;
    {
        layerFE.snapshot.pictureProfileHandle = PictureProfileHandle(1);
        layerFE.onPictureProfileCommitted();
        updater.onLayerComposed(*layer, layerFE, layerFE.stealCompositionResult());
        tracker.onLayerComposed(*layer, layerFE, layerFE.stealCompositionResult());

        ASSERT_TRUE(updater.updateAndHasChanged());
        EXPECT_THAT(updater.getActivePictures(), UnorderedElementsAre({{100, 10, 1}}));
        ASSERT_TRUE(tracker.updateAndHasChanged());
        EXPECT_THAT(tracker.getActivePictures(), UnorderedElementsAre({{100, 10, 1}}));
    }
    {
        layerFE.snapshot.pictureProfileHandle = PictureProfileHandle::NONE;
        updater.onLayerComposed(*layer, layerFE, layerFE.stealCompositionResult());
        tracker.onLayerComposed(*layer, layerFE, layerFE.stealCompositionResult());

        ASSERT_TRUE(updater.updateAndHasChanged());
        EXPECT_THAT(updater.getActivePictures(), UnorderedElementsAre({}));
        ASSERT_TRUE(tracker.updateAndHasChanged());
        EXPECT_THAT(tracker.getActivePictures(), UnorderedElementsAre({}));
    }
}

TEST_F(ActivePictureUpdaterTest, calledWhenLayerChangesProfile) {
TEST_F(ActivePictureTrackerTest, calledWhenLayerChangesProfile) {
    sp<NiceMock<MockLayer>> layer = sp<NiceMock<MockLayer>>::make(flinger(), 100);
    TestableLayerFE layerFE;
    EXPECT_CALL(*layer, getOwnerUid()).WillRepeatedly(Return(uid_t(10)));

    ActivePictureUpdater updater;
    ActivePictureTracker tracker;
    {
        layerFE.snapshot.pictureProfileHandle = PictureProfileHandle(1);
        layerFE.onPictureProfileCommitted();
        updater.onLayerComposed(*layer, layerFE, layerFE.stealCompositionResult());
        tracker.onLayerComposed(*layer, layerFE, layerFE.stealCompositionResult());

        ASSERT_TRUE(updater.updateAndHasChanged());
        EXPECT_THAT(updater.getActivePictures(), UnorderedElementsAre({{100, 10, 1}}));
        ASSERT_TRUE(tracker.updateAndHasChanged());
        EXPECT_THAT(tracker.getActivePictures(), UnorderedElementsAre({{100, 10, 1}}));
    }
    {
        layerFE.snapshot.pictureProfileHandle = PictureProfileHandle(2);
        layerFE.onPictureProfileCommitted();
        updater.onLayerComposed(*layer, layerFE, layerFE.stealCompositionResult());
        tracker.onLayerComposed(*layer, layerFE, layerFE.stealCompositionResult());

        ASSERT_TRUE(updater.updateAndHasChanged());
        EXPECT_THAT(updater.getActivePictures(), UnorderedElementsAre({{100, 10, 2}}));
        ASSERT_TRUE(tracker.updateAndHasChanged());
        EXPECT_THAT(tracker.getActivePictures(), UnorderedElementsAre({{100, 10, 2}}));
    }
}

TEST_F(ActivePictureUpdaterTest, notCalledWhenUncommittedLayerChangesProfile) {
TEST_F(ActivePictureTrackerTest, notCalledWhenUncommittedLayerChangesProfile) {
    sp<NiceMock<MockLayer>> layer1 = sp<NiceMock<MockLayer>>::make(flinger(), 100);
    TestableLayerFE layerFE1;
    EXPECT_CALL(*layer1, getOwnerUid()).WillRepeatedly(Return(uid_t(10)));
@@ -199,31 +199,31 @@ TEST_F(ActivePictureUpdaterTest, notCalledWhenUncommittedLayerChangesProfile) {
    TestableLayerFE layerFE2;
    EXPECT_CALL(*layer2, getOwnerUid()).WillRepeatedly(Return(uid_t(20)));

    ActivePictureUpdater updater;
    ActivePictureTracker tracker;
    {
        layerFE1.snapshot.pictureProfileHandle = PictureProfileHandle(1);
        layerFE1.onPictureProfileCommitted();
        updater.onLayerComposed(*layer1, layerFE1, layerFE1.stealCompositionResult());
        tracker.onLayerComposed(*layer1, layerFE1, layerFE1.stealCompositionResult());

        layerFE2.snapshot.pictureProfileHandle = PictureProfileHandle(1);
        updater.onLayerComposed(*layer2, layerFE2, layerFE2.stealCompositionResult());
        tracker.onLayerComposed(*layer2, layerFE2, layerFE2.stealCompositionResult());

        ASSERT_TRUE(updater.updateAndHasChanged());
        EXPECT_THAT(updater.getActivePictures(), UnorderedElementsAre({{100, 10, 1}}));
        ASSERT_TRUE(tracker.updateAndHasChanged());
        EXPECT_THAT(tracker.getActivePictures(), UnorderedElementsAre({{100, 10, 1}}));
    }
    {
        layerFE1.snapshot.pictureProfileHandle = PictureProfileHandle(1);
        layerFE1.onPictureProfileCommitted();
        updater.onLayerComposed(*layer1, layerFE1, layerFE1.stealCompositionResult());
        tracker.onLayerComposed(*layer1, layerFE1, layerFE1.stealCompositionResult());

        layerFE2.snapshot.pictureProfileHandle = PictureProfileHandle(2);
        updater.onLayerComposed(*layer2, layerFE2, layerFE2.stealCompositionResult());
        tracker.onLayerComposed(*layer2, layerFE2, layerFE2.stealCompositionResult());

        ASSERT_FALSE(updater.updateAndHasChanged());
        ASSERT_FALSE(tracker.updateAndHasChanged());
    }
}

TEST_F(ActivePictureUpdaterTest, calledWhenDifferentLayerUsesSameProfile) {
TEST_F(ActivePictureTrackerTest, calledWhenDifferentLayerUsesSameProfile) {
    sp<NiceMock<MockLayer>> layer1 = sp<NiceMock<MockLayer>>::make(flinger(), 100);
    TestableLayerFE layerFE1;
    EXPECT_CALL(*layer1, getOwnerUid()).WillRepeatedly(Return(uid_t(10)));
@@ -232,36 +232,36 @@ TEST_F(ActivePictureUpdaterTest, calledWhenDifferentLayerUsesSameProfile) {
    TestableLayerFE layerFE2;
    EXPECT_CALL(*layer2, getOwnerUid()).WillRepeatedly(Return(uid_t(20)));

    ActivePictureUpdater updater;
    ActivePictureTracker tracker;
    {
        layerFE1.snapshot.pictureProfileHandle = PictureProfileHandle(1);
        layerFE1.onPictureProfileCommitted();
        updater.onLayerComposed(*layer1, layerFE1, layerFE1.stealCompositionResult());
        tracker.onLayerComposed(*layer1, layerFE1, layerFE1.stealCompositionResult());

        layerFE2.snapshot.pictureProfileHandle = PictureProfileHandle(2);
        layerFE2.onPictureProfileCommitted();
        updater.onLayerComposed(*layer2, layerFE2, layerFE2.stealCompositionResult());
        tracker.onLayerComposed(*layer2, layerFE2, layerFE2.stealCompositionResult());

        ASSERT_TRUE(updater.updateAndHasChanged());
        EXPECT_THAT(updater.getActivePictures(),
        ASSERT_TRUE(tracker.updateAndHasChanged());
        EXPECT_THAT(tracker.getActivePictures(),
                    UnorderedElementsAre({{100, 10, 1}, {200, 20, 2}}));
    }
    {
        layerFE1.snapshot.pictureProfileHandle = PictureProfileHandle(2);
        layerFE1.onPictureProfileCommitted();
        updater.onLayerComposed(*layer1, layerFE1, layerFE1.stealCompositionResult());
        tracker.onLayerComposed(*layer1, layerFE1, layerFE1.stealCompositionResult());

        layerFE2.snapshot.pictureProfileHandle = PictureProfileHandle(1);
        layerFE2.onPictureProfileCommitted();
        updater.onLayerComposed(*layer2, layerFE2, layerFE2.stealCompositionResult());
        tracker.onLayerComposed(*layer2, layerFE2, layerFE2.stealCompositionResult());

        ASSERT_TRUE(updater.updateAndHasChanged());
        EXPECT_THAT(updater.getActivePictures(),
        ASSERT_TRUE(tracker.updateAndHasChanged());
        EXPECT_THAT(tracker.getActivePictures(),
                    UnorderedElementsAre({{100, 10, 2}, {200, 20, 1}}));
    }
}

TEST_F(ActivePictureUpdaterTest, calledWhenSameUidUsesSameProfile) {
TEST_F(ActivePictureTrackerTest, calledWhenSameUidUsesSameProfile) {
    sp<NiceMock<MockLayer>> layer1 = sp<NiceMock<MockLayer>>::make(flinger(), 100);
    TestableLayerFE layerFE1;
    EXPECT_CALL(*layer1, getOwnerUid()).WillRepeatedly(Return(uid_t(10)));
@@ -270,48 +270,48 @@ TEST_F(ActivePictureUpdaterTest, calledWhenSameUidUsesSameProfile) {
    TestableLayerFE layerFE2;
    EXPECT_CALL(*layer2, getOwnerUid()).WillRepeatedly(Return(uid_t(10)));

    ActivePictureUpdater updater;
    ActivePictureTracker tracker;
    {
        layerFE1.snapshot.pictureProfileHandle = PictureProfileHandle(1);
        layerFE1.onPictureProfileCommitted();
        updater.onLayerComposed(*layer1, layerFE1, layerFE1.stealCompositionResult());
        tracker.onLayerComposed(*layer1, layerFE1, layerFE1.stealCompositionResult());

        layerFE2.snapshot.pictureProfileHandle = PictureProfileHandle(2);
        layerFE2.onPictureProfileCommitted();
        updater.onLayerComposed(*layer2, layerFE2, layerFE2.stealCompositionResult());
        tracker.onLayerComposed(*layer2, layerFE2, layerFE2.stealCompositionResult());

        ASSERT_TRUE(updater.updateAndHasChanged());
        EXPECT_THAT(updater.getActivePictures(),
        ASSERT_TRUE(tracker.updateAndHasChanged());
        EXPECT_THAT(tracker.getActivePictures(),
                    UnorderedElementsAre({{100, 10, 1}, {200, 10, 2}}));
    }
    {
        layerFE1.snapshot.pictureProfileHandle = PictureProfileHandle(2);
        layerFE1.onPictureProfileCommitted();
        updater.onLayerComposed(*layer1, layerFE1, layerFE1.stealCompositionResult());
        tracker.onLayerComposed(*layer1, layerFE1, layerFE1.stealCompositionResult());

        layerFE2.snapshot.pictureProfileHandle = PictureProfileHandle(1);
        layerFE2.onPictureProfileCommitted();
        updater.onLayerComposed(*layer2, layerFE2, layerFE2.stealCompositionResult());
        tracker.onLayerComposed(*layer2, layerFE2, layerFE2.stealCompositionResult());

        ASSERT_TRUE(updater.updateAndHasChanged());
        EXPECT_THAT(updater.getActivePictures(),
        ASSERT_TRUE(tracker.updateAndHasChanged());
        EXPECT_THAT(tracker.getActivePictures(),
                    UnorderedElementsAre({{100, 10, 2}, {200, 10, 1}}));
    }
}

TEST_F(ActivePictureUpdaterTest, calledWhenNewLayerUsesSameProfile) {
TEST_F(ActivePictureTrackerTest, calledWhenNewLayerUsesSameProfile) {
    sp<NiceMock<MockLayer>> layer1 = sp<NiceMock<MockLayer>>::make(flinger(), 100);
    TestableLayerFE layerFE1;
    EXPECT_CALL(*layer1, getOwnerUid()).WillRepeatedly(Return(uid_t(10)));

    ActivePictureUpdater updater;
    ActivePictureTracker tracker;
    {
        layerFE1.snapshot.pictureProfileHandle = PictureProfileHandle(1);
        layerFE1.onPictureProfileCommitted();
        updater.onLayerComposed(*layer1, layerFE1, layerFE1.stealCompositionResult());
        tracker.onLayerComposed(*layer1, layerFE1, layerFE1.stealCompositionResult());

        ASSERT_TRUE(updater.updateAndHasChanged());
        EXPECT_THAT(updater.getActivePictures(), UnorderedElementsAre({{100, 10, 1}}));
        ASSERT_TRUE(tracker.updateAndHasChanged());
        EXPECT_THAT(tracker.getActivePictures(), UnorderedElementsAre({{100, 10, 1}}));
    }

    sp<NiceMock<MockLayer>> layer2 = sp<NiceMock<MockLayer>>::make(flinger(), 200);
@@ -321,14 +321,14 @@ TEST_F(ActivePictureUpdaterTest, calledWhenNewLayerUsesSameProfile) {
    {
        layerFE1.snapshot.pictureProfileHandle = PictureProfileHandle(1);
        layerFE1.onPictureProfileCommitted();
        updater.onLayerComposed(*layer1, layerFE1, layerFE1.stealCompositionResult());
        tracker.onLayerComposed(*layer1, layerFE1, layerFE1.stealCompositionResult());

        layerFE2.snapshot.pictureProfileHandle = PictureProfileHandle(1);
        layerFE2.onPictureProfileCommitted();
        updater.onLayerComposed(*layer2, layerFE2, layerFE2.stealCompositionResult());
        tracker.onLayerComposed(*layer2, layerFE2, layerFE2.stealCompositionResult());

        ASSERT_TRUE(updater.updateAndHasChanged());
        EXPECT_THAT(updater.getActivePictures(),
        ASSERT_TRUE(tracker.updateAndHasChanged());
        EXPECT_THAT(tracker.getActivePictures(),
                    UnorderedElementsAre({{100, 10, 1}, {200, 10, 1}}));
    }
}
+1 −1

File changed.

Contains only whitespace changes.

Loading