From 685cfefb624ec9414cf3c1bb2de1f8fbadefc0dd Mon Sep 17 00:00:00 2001 From: Vishnu Nair Date: Wed, 2 Feb 2022 10:01:25 -0800 Subject: 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 --- libs/gui/LayerState.cpp | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) (limited to 'libs/gui/LayerState.cpp') diff --git a/libs/gui/LayerState.cpp b/libs/gui/LayerState.cpp index eec4a874b9..9022e7d5a4 100644 --- a/libs/gui/LayerState.cpp +++ b/libs/gui/LayerState.cpp @@ -35,7 +35,9 @@ using gui::FocusRequest; 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 @@ status_t layer_state_t::write(Parcel& output) const SAFE_PARCEL(output.writeBool, isTrustedOverlay); SAFE_PARCEL(output.writeUint32, static_cast(dropInputMode)); - SAFE_PARCEL(output.writeNullableParcelable, - bufferData ? std::make_optional(*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 @@ status_t layer_state_t::read(const Parcel& input) uint32_t mode; SAFE_PARCEL(input.readUint32, &mode); dropInputMode = static_cast(mode); - std::optional tmpBufferData; - SAFE_PARCEL(input.readParcelable, &tmpBufferData); - bufferData = tmpBufferData ? std::make_shared(*tmpBufferData) : nullptr; + + bool hasBufferData; + SAFE_PARCEL(input.readBool, &hasBufferData); + if (hasBufferData) { + bufferData = std::make_shared(); + SAFE_PARCEL(input.readParcelable, bufferData.get()); + } else { + bufferData = nullptr; + } return NO_ERROR; } -- cgit v1.2.3-59-g8ed1b