[sf] fix buffer info when generating layers trace
Update the trace generation code to generate a mock
external texture.
Test: atest transactiontrace_testsuite
Bug: 270408775
Change-Id: Ieac3bceef8350518a7655d89fe4b72bcd7979755
diff --git a/services/surfaceflinger/Tracing/TransactionProtoParser.cpp b/services/surfaceflinger/Tracing/TransactionProtoParser.cpp
index 2f46487..475c76b 100644
--- a/services/surfaceflinger/Tracing/TransactionProtoParser.cpp
+++ b/services/surfaceflinger/Tracing/TransactionProtoParser.cpp
@@ -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 @@
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);
}
diff --git a/services/surfaceflinger/Tracing/tools/run.sh b/services/surfaceflinger/Tracing/tools/run.sh
index baa93f1..307a4d8 100644
--- a/services/surfaceflinger/Tracing/tools/run.sh
+++ b/services/surfaceflinger/Tracing/tools/run.sh
@@ -5,7 +5,15 @@
# 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
-echo "Writing transaction trace to file"
-adb shell service call SurfaceFlinger 1041 i32 0
-adb shell /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
diff --git a/services/surfaceflinger/tests/tracing/TransactionTraceTestSuite.cpp b/services/surfaceflinger/tests/tracing/TransactionTraceTestSuite.cpp
index 0e214af..5f9214c 100644
--- a/services/surfaceflinger/tests/tracing/TransactionTraceTestSuite.cpp
+++ b/services/surfaceflinger/tests/tracing/TransactionTraceTestSuite.cpp
@@ -91,6 +91,8 @@
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 @@
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 @@
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 @@
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 @@
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);