summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Chavi Weingarten <chaviw@google.com> 2023-03-06 22:20:42 +0000
committer Chavi Weingarten <chaviw@google.com> 2023-03-06 22:23:01 +0000
commitc8bcb68fa63ebef6c8afd9e6a125a7eed79b35db (patch)
treeab2492bbcbce674b55cb6c2b9b5d2dd617fe6778
parentb304b2f1177251c5deb904306ba5ad820e1c119d (diff)
Use external texture for buffer release.
When the buffer needs to be released due to the producer id changing, use the external texture and not the buffer in the transaction. This is because the buffer might be null if the buffer was already cached. Test: Not reproducible crash Fixes: 271771720 Change-Id: I6453fd44811b076c0c5670c047fe108383f4f426
-rw-r--r--services/surfaceflinger/SurfaceFlinger.cpp10
-rw-r--r--services/surfaceflinger/TransactionState.h2
2 files changed, 9 insertions, 3 deletions
diff --git a/services/surfaceflinger/SurfaceFlinger.cpp b/services/surfaceflinger/SurfaceFlinger.cpp
index dbaf1fb5b0..e45b438a7b 100644
--- a/services/surfaceflinger/SurfaceFlinger.cpp
+++ b/services/surfaceflinger/SurfaceFlinger.cpp
@@ -4105,7 +4105,12 @@ TransactionHandler::TransactionReadiness SurfaceFlinger::transactionReadyBufferC
const TransactionHandler::TransactionFlushState& flushState) {
using TransactionReadiness = TransactionHandler::TransactionReadiness;
auto ready = TransactionReadiness::Ready;
- flushState.transaction->traverseStatesWithBuffersWhileTrue([&](const layer_state_t& s) -> bool {
+ flushState.transaction->traverseStatesWithBuffersWhileTrue([&](const layer_state_t& s,
+ const std::shared_ptr<
+ renderengine::
+ ExternalTexture>&
+ externalTexture)
+ -> bool {
sp<Layer> layer = LayerHandle::getLayer(s.surface);
const auto& transaction = *flushState.transaction;
// check for barrier frames
@@ -4115,7 +4120,8 @@ TransactionHandler::TransactionReadiness SurfaceFlinger::transactionReadyBufferC
// don't wait on the barrier since we know that's stale information.
if (layer->getDrawingState().producerId > s.bufferData->producerId) {
layer->callReleaseBufferCallback(s.bufferData->releaseBufferListener,
- s.bufferData->buffer, s.bufferData->frameNumber,
+ externalTexture->getBuffer(),
+ s.bufferData->frameNumber,
s.bufferData->acquireFence);
// Delete the entire state at this point and not just release the buffer because
// everything associated with the Layer in this Transaction is now out of date.
diff --git a/services/surfaceflinger/TransactionState.h b/services/surfaceflinger/TransactionState.h
index 6c5a8b213d..40d06a8a8c 100644
--- a/services/surfaceflinger/TransactionState.h
+++ b/services/surfaceflinger/TransactionState.h
@@ -85,7 +85,7 @@ struct TransactionState {
for (auto state = states.begin(); state != states.end();) {
if (state->state.hasBufferChanges() && state->state.hasValidBuffer() &&
state->state.surface) {
- int result = visitor(state->state);
+ int result = visitor(state->state, state->externalTexture);
if (result == STOP_TRAVERSAL) return;
if (result == DELETE_AND_CONTINUE_TRAVERSAL) {
state = states.erase(state);