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

Commit 651806f2 authored by Huihong Luo's avatar Huihong Luo
Browse files

Reset pending commands

Allow takePendingCommands to have ownership for mComamnds so commands
are reset on each call. Make reset method to be private.

Bug: 273525126
Test: manual
Change-Id: Ifecad733e5e85d475825969296ddf68081ce9e60
parent 9c95ea9b
Loading
Loading
Loading
Loading
+10 −8
Original line number Original line Diff line number Diff line
@@ -70,12 +70,6 @@ class ComposerClientWriter final {
    ComposerClientWriter(const ComposerClientWriter&) = delete;
    ComposerClientWriter(const ComposerClientWriter&) = delete;
    ComposerClientWriter& operator=(const ComposerClientWriter&) = delete;
    ComposerClientWriter& operator=(const ComposerClientWriter&) = delete;


    void reset() {
        mDisplayCommand.reset();
        mLayerCommand.reset();
        mCommands.clear();
    }

    void setColorTransform(int64_t display, const float* matrix) {
    void setColorTransform(int64_t display, const float* matrix) {
        std::vector<float> matVec;
        std::vector<float> matVec;
        matVec.reserve(16);
        matVec.reserve(16);
@@ -235,10 +229,12 @@ class ComposerClientWriter final {
        getLayerCommand(display, layer).blockingRegion.emplace(blocking.begin(), blocking.end());
        getLayerCommand(display, layer).blockingRegion.emplace(blocking.begin(), blocking.end());
    }
    }


    const std::vector<DisplayCommand>& getPendingCommands() {
    std::vector<DisplayCommand> takePendingCommands() {
        flushLayerCommand();
        flushLayerCommand();
        flushDisplayCommand();
        flushDisplayCommand();
        return mCommands;
        std::vector<DisplayCommand> moved = std::move(mCommands);
        mCommands.clear();
        return moved;
    }
    }


  private:
  private:
@@ -289,6 +285,12 @@ class ComposerClientWriter final {
        }
        }
        return *mLayerCommand;
        return *mLayerCommand;
    }
    }

    void reset() {
        mDisplayCommand.reset();
        mLayerCommand.reset();
        mCommands.clear();
    }
};
};


}  // namespace aidl::android::hardware::graphics::composer3
}  // namespace aidl::android::hardware::graphics::composer3
+1 −3
Original line number Original line Diff line number Diff line
@@ -207,9 +207,8 @@ class GraphicsCompositionTestBase : public ::testing::Test {
    }
    }


    void execute() {
    void execute() {
        const auto& commands = mWriter->getPendingCommands();
        auto commands = mWriter->takePendingCommands();
        if (commands.empty()) {
        if (commands.empty()) {
            mWriter->reset();
            return;
            return;
        }
        }


@@ -217,7 +216,6 @@ class GraphicsCompositionTestBase : public ::testing::Test {
        ASSERT_TRUE(status.isOk()) << "executeCommands failed " << status.getDescription();
        ASSERT_TRUE(status.isOk()) << "executeCommands failed " << status.getDescription();


        mReader.parse(std::move(results));
        mReader.parse(std::move(results));
        mWriter->reset();
    }
    }


    bool getHasReadbackBuffer() {
    bool getHasReadbackBuffer() {
+1 −3
Original line number Original line Diff line number Diff line
@@ -1171,15 +1171,13 @@ class GraphicsComposerAidlCommandTest : public GraphicsComposerAidlTest {
    void execute() {
    void execute() {
        std::vector<CommandResultPayload> payloads;
        std::vector<CommandResultPayload> payloads;
        for (auto& [_, writer] : mWriters) {
        for (auto& [_, writer] : mWriters) {
            const auto& commands = writer.getPendingCommands();
            auto commands = writer.takePendingCommands();
            if (commands.empty()) {
            if (commands.empty()) {
                writer.reset();
                continue;
                continue;
            }
            }


            auto [status, results] = mComposerClient->executeCommands(commands);
            auto [status, results] = mComposerClient->executeCommands(commands);
            ASSERT_TRUE(status.isOk()) << "executeCommands failed " << status.getDescription();
            ASSERT_TRUE(status.isOk()) << "executeCommands failed " << status.getDescription();
            writer.reset();


            payloads.reserve(payloads.size() + results.size());
            payloads.reserve(payloads.size() + results.size());
            payloads.insert(payloads.end(), std::make_move_iterator(results.begin()),
            payloads.insert(payloads.end(), std::make_move_iterator(results.begin()),