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

Commit 8581cb2a authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "[sf] fix buffer info when generating layers trace" into udc-dev

parents 57ddefa7 63a662a1
Loading
Loading
Loading
Loading
+9 −0
Original line number Diff line number Diff line
@@ -15,6 +15,7 @@
 */

#include <gui/SurfaceComposerClient.h>
#include <renderengine/mock/FakeExternalTexture.h>
#include <ui/Fence.h>
#include <ui/Rect.h>

@@ -313,6 +314,14 @@ TransactionState TransactionProtoParser::fromProto(const proto::TransactionState
        ResolvedComposerState s;
        s.state.what = 0;
        fromProto(proto.layer_changes(i), s.state);
        if (s.state.bufferData) {
            s.externalTexture = std::make_shared<
                    renderengine::mock::FakeExternalTexture>(s.state.bufferData->getWidth(),
                                                             s.state.bufferData->getHeight(),
                                                             s.state.bufferData->getId(),
                                                             s.state.bufferData->getPixelFormat(),
                                                             s.state.bufferData->getUsage());
        }
        t.states.emplace_back(s);
    }

+11 −3
Original line number Diff line number Diff line
@@ -5,7 +5,15 @@ set -ex
# Build, push and run layertracegenerator
$ANDROID_BUILD_TOP/build/soong/soong_ui.bash --make-mode layertracegenerator
adb wait-for-device && adb push $OUT/system/bin/layertracegenerator /data/layertracegenerator

if [ -z "$1" ]
  then
    echo "Writing transaction trace to file"
    adb shell service call SurfaceFlinger 1041 i32 0
    adb shell /data/layertracegenerator
  else
    echo "Pushing transaction trace to device"
    adb push $1 /data/transaction_trace.winscope
    adb shell /data/layertracegenerator /data/transaction_trace.winscope
fi
adb pull /data/misc/wmtrace/layers_trace.winscope
 No newline at end of file
+18 −9
Original line number Diff line number Diff line
@@ -91,6 +91,8 @@ struct LayerInfo {
    uint64_t curr_frame;
    float x;
    float y;
    uint32_t bufferWidth;
    uint32_t bufferHeight;
};

bool operator==(const LayerInfo& lh, const LayerInfo& rh) {
@@ -105,7 +107,8 @@ bool compareById(const LayerInfo& a, const LayerInfo& b) {
inline void PrintTo(const LayerInfo& info, ::std::ostream* os) {
    *os << "Layer [" << info.id << "] name=" << info.name << " parent=" << info.parent
        << " z=" << info.z << " curr_frame=" << info.curr_frame << " x=" << info.x
        << " y=" << info.y;
        << " y=" << info.y << " bufferWidth=" << info.bufferWidth
        << " bufferHeight=" << info.bufferHeight;
}

struct find_id : std::unary_function<LayerInfo, bool> {
@@ -114,6 +117,18 @@ struct find_id : std::unary_function<LayerInfo, bool> {
    bool operator()(LayerInfo const& m) const { return m.id == id; }
};

static LayerInfo getLayerInfoFromProto(::android::surfaceflinger::LayerProto& proto) {
    return {proto.id(),
            proto.name(),
            proto.parent(),
            proto.z(),
            proto.curr_frame(),
            proto.has_position() ? proto.position().x() : -1,
            proto.has_position() ? proto.position().y() : -1,
            proto.has_active_buffer() ? proto.active_buffer().width() : 0,
            proto.has_active_buffer() ? proto.active_buffer().height() : 0};
}

TEST_P(TransactionTraceTestSuite, validateEndState) {
    ASSERT_GT(mActualLayersTraceProto.entry_size(), 0);
    ASSERT_GT(mExpectedLayersTraceProto.entry_size(), 0);
@@ -128,10 +143,7 @@ TEST_P(TransactionTraceTestSuite, validateEndState) {
    expectedLayers.reserve(static_cast<size_t>(expectedLastEntry.layers().layers_size()));
    for (int i = 0; i < expectedLastEntry.layers().layers_size(); i++) {
        auto layer = expectedLastEntry.layers().layers(i);
        expectedLayers.push_back({layer.id(), layer.name(), layer.parent(), layer.z(),
                                  layer.curr_frame(),
                                  layer.has_position() ? layer.position().x() : -1,
                                  layer.has_position() ? layer.position().y() : -1});
        expectedLayers.push_back(getLayerInfoFromProto(layer));
    }
    std::sort(expectedLayers.begin(), expectedLayers.end(), compareById);

@@ -139,10 +151,7 @@ TEST_P(TransactionTraceTestSuite, validateEndState) {
    actualLayers.reserve(static_cast<size_t>(actualLastEntry.layers().layers_size()));
    for (int i = 0; i < actualLastEntry.layers().layers_size(); i++) {
        auto layer = actualLastEntry.layers().layers(i);
        actualLayers.push_back({layer.id(), layer.name(), layer.parent(), layer.z(),
                                layer.curr_frame(),
                                layer.has_position() ? layer.position().x() : -1,
                                layer.has_position() ? layer.position().y() : -1});
        actualLayers.push_back(getLayerInfoFromProto(layer));
    }
    std::sort(actualLayers.begin(), actualLayers.end(), compareById);