TransactionTracing: Introduce FlingerDataMapper
Allow the proto parser to handle dependencies
that are external to layer via a clear interface.
This is needed to make sure the parser can map
handles to ids, get buffer info from cached buffers
or inject fake buffers in transactions to recreate
the layer's internal state.
Test: presubmit
Bug: 200284593
Change-Id: I830048a560945cce088d7276e764c953f408e0d3
diff --git a/libs/gui/LayerState.cpp b/libs/gui/LayerState.cpp
index eec4a87..9022e7d 100644
--- a/libs/gui/LayerState.cpp
+++ b/libs/gui/LayerState.cpp
@@ -35,7 +35,9 @@
using gui::WindowInfoHandle;
layer_state_t::layer_state_t()
- : what(0),
+ : surface(nullptr),
+ layerId(-1),
+ what(0),
x(0),
y(0),
z(0),
@@ -153,8 +155,12 @@
SAFE_PARCEL(output.writeBool, isTrustedOverlay);
SAFE_PARCEL(output.writeUint32, static_cast<uint32_t>(dropInputMode));
- SAFE_PARCEL(output.writeNullableParcelable,
- bufferData ? std::make_optional<BufferData>(*bufferData) : std::nullopt);
+
+ const bool hasBufferData = (bufferData != nullptr);
+ SAFE_PARCEL(output.writeBool, hasBufferData);
+ if (hasBufferData) {
+ SAFE_PARCEL(output.writeParcelable, *bufferData);
+ }
return NO_ERROR;
}
@@ -264,9 +270,15 @@
uint32_t mode;
SAFE_PARCEL(input.readUint32, &mode);
dropInputMode = static_cast<gui::DropInputMode>(mode);
- std::optional<BufferData> tmpBufferData;
- SAFE_PARCEL(input.readParcelable, &tmpBufferData);
- bufferData = tmpBufferData ? std::make_shared<BufferData>(*tmpBufferData) : nullptr;
+
+ bool hasBufferData;
+ SAFE_PARCEL(input.readBool, &hasBufferData);
+ if (hasBufferData) {
+ bufferData = std::make_shared<BufferData>();
+ SAFE_PARCEL(input.readParcelable, bufferData.get());
+ } else {
+ bufferData = nullptr;
+ }
return NO_ERROR;
}