From 076acace33a13f588d3e7450872e738bc1fa3f06 Mon Sep 17 00:00:00 2001 From: Chavi Weingarten Date: Thu, 19 Jan 2023 17:20:43 +0000 Subject: SurfaceFlinger: Add TrustedPresentationListener API TrustedPresentationListener is intended to allow the producer of a buffer layer to gain a trusted signal on whether and to what extent a layer is presented. A strawman design would be to provide the producer details on it's presentation (alpha, position, scale, final crop, covered region, etc). In the strawman design the client end would then decide itself whether each of these parameters were in an acceptable range. However providing the client feedback on it's per frame position would have a negative system health impact. Furthermore in some of the target use cases we can't even be sure the layer of interest is actively producing buffers and so there may be no existing callback to piggy-back on. Because of this we use a server side thresholding approach, where the client expresses some visibility threshold and a time stability constraint. See SurfaceComposerClient.h comment for details on these thresholds and their computation. Bug: 256993331 Test: LayerTrustedPresentationListener_test.cpp Change-Id: If4bef60dc6b22ce4959c353fa2a19b0994a00f5c --- libs/gui/LayerState.cpp | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) (limited to 'libs/gui/LayerState.cpp') diff --git a/libs/gui/LayerState.cpp b/libs/gui/LayerState.cpp index 59b62fe58c..43acb16299 100644 --- a/libs/gui/LayerState.cpp +++ b/libs/gui/LayerState.cpp @@ -185,6 +185,8 @@ status_t layer_state_t::write(Parcel& output) const if (hasBufferData) { SAFE_PARCEL(output.writeParcelable, *bufferData); } + SAFE_PARCEL(output.writeParcelable, trustedPresentationThresholds); + SAFE_PARCEL(output.writeParcelable, trustedPresentationListener); return NO_ERROR; } @@ -315,6 +317,10 @@ status_t layer_state_t::read(const Parcel& input) } else { bufferData = nullptr; } + + SAFE_PARCEL(input.readParcelable, &trustedPresentationThresholds); + SAFE_PARCEL(input.readParcelable, &trustedPresentationListener); + return NO_ERROR; } @@ -553,6 +559,11 @@ void layer_state_t::merge(const layer_state_t& other) { what |= eBufferChanged; bufferData = other.bufferData; } + if (other.what & eTrustedPresentationInfoChanged) { + what |= eTrustedPresentationInfoChanged; + trustedPresentationListener = other.trustedPresentationListener; + trustedPresentationThresholds = other.trustedPresentationThresholds; + } if (other.what & eDataspaceChanged) { what |= eDataspaceChanged; dataspace = other.dataspace; @@ -998,4 +1009,20 @@ status_t BufferData::readFromParcel(const Parcel* input) { return NO_ERROR; } +status_t TrustedPresentationListener::writeToParcel(Parcel* parcel) const { + SAFE_PARCEL(parcel->writeStrongBinder, callbackInterface); + SAFE_PARCEL(parcel->writeInt32, callbackId); + return NO_ERROR; +} + +status_t TrustedPresentationListener::readFromParcel(const Parcel* parcel) { + sp tmpBinder = nullptr; + SAFE_PARCEL(parcel->readNullableStrongBinder, &tmpBinder); + if (tmpBinder) { + callbackInterface = checked_interface_cast(tmpBinder); + } + SAFE_PARCEL(parcel->readInt32, &callbackId); + return NO_ERROR; +} + }; // namespace android -- cgit v1.2.3-59-g8ed1b