summaryrefslogtreecommitdiff
path: root/services/surfaceflinger/SurfaceFlinger.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'services/surfaceflinger/SurfaceFlinger.cpp')
-rw-r--r--services/surfaceflinger/SurfaceFlinger.cpp57
1 files changed, 21 insertions, 36 deletions
diff --git a/services/surfaceflinger/SurfaceFlinger.cpp b/services/surfaceflinger/SurfaceFlinger.cpp
index 9d759dfe82..8863182be3 100644
--- a/services/surfaceflinger/SurfaceFlinger.cpp
+++ b/services/surfaceflinger/SurfaceFlinger.cpp
@@ -4993,13 +4993,7 @@ bool SurfaceFlinger::shouldLatchUnsignaled(const layer_state_t& state, size_t nu
return true;
}
-status_t SurfaceFlinger::setTransactionState(
- const FrameTimelineInfo& frameTimelineInfo, Vector<ComposerState>& states,
- Vector<DisplayState>& displays, uint32_t flags, const sp<IBinder>& applyToken,
- InputWindowCommands inputWindowCommands, int64_t desiredPresentTime, bool isAutoTimestamp,
- const std::vector<client_cache_t>& uncacheBuffers, bool hasListenerCallbacks,
- const std::vector<ListenerCallbacks>& listenerCallbacks, uint64_t transactionId,
- const std::vector<uint64_t>& mergedTransactionIds) {
+status_t SurfaceFlinger::setTransactionState(TransactionState&& transactionState) {
SFTRACE_CALL();
IPCThreadState* ipc = IPCThreadState::self();
@@ -5007,7 +5001,7 @@ status_t SurfaceFlinger::setTransactionState(
const int originUid = ipc->getCallingUid();
uint32_t permissions = LayerStatePermissions::getTransactionPermissions(originPid, originUid);
ftl::Flags<adpf::Workload> queuedWorkload;
- for (auto& composerState : states) {
+ for (auto& composerState : transactionState.mComposerStates) {
composerState.state.sanitize(permissions);
if (composerState.state.what & layer_state_t::COMPOSITION_EFFECTS) {
queuedWorkload |= adpf::Workload::EFFECTS;
@@ -5017,27 +5011,27 @@ status_t SurfaceFlinger::setTransactionState(
}
}
- for (DisplayState& display : displays) {
+ for (DisplayState& display : transactionState.mDisplayStates) {
display.sanitize(permissions);
}
- if (!inputWindowCommands.empty() &&
+ if (!transactionState.mInputWindowCommands.empty() &&
(permissions & layer_state_t::Permission::ACCESS_SURFACE_FLINGER) == 0) {
ALOGE("Only privileged callers are allowed to send input commands.");
- inputWindowCommands.clear();
+ transactionState.mInputWindowCommands.clear();
}
- if (flags & (eEarlyWakeupStart | eEarlyWakeupEnd)) {
+ if (transactionState.mFlags & (eEarlyWakeupStart | eEarlyWakeupEnd)) {
const bool hasPermission =
(permissions & layer_state_t::Permission::ACCESS_SURFACE_FLINGER) ||
callingThreadHasPermission(sWakeupSurfaceFlinger);
if (!hasPermission) {
ALOGE("Caller needs permission android.permission.WAKEUP_SURFACE_FLINGER to use "
"eEarlyWakeup[Start|End] flags");
- flags &= ~(eEarlyWakeupStart | eEarlyWakeupEnd);
+ transactionState.mFlags &= ~(eEarlyWakeupStart | eEarlyWakeupEnd);
}
}
- if (flags & eEarlyWakeupStart) {
+ if (transactionState.mFlags & eEarlyWakeupStart) {
queuedWorkload |= adpf::Workload::WAKEUP;
}
mPowerAdvisor->setQueuedWorkload(queuedWorkload);
@@ -5045,8 +5039,8 @@ status_t SurfaceFlinger::setTransactionState(
const int64_t postTime = systemTime();
std::vector<uint64_t> uncacheBufferIds;
- uncacheBufferIds.reserve(uncacheBuffers.size());
- for (const auto& uncacheBuffer : uncacheBuffers) {
+ uncacheBufferIds.reserve(transactionState.mUncacheBuffers.size());
+ for (const auto& uncacheBuffer : transactionState.mUncacheBuffers) {
sp<GraphicBuffer> buffer = ClientCache::getInstance().erase(uncacheBuffer);
if (buffer != nullptr) {
uncacheBufferIds.push_back(buffer->getId());
@@ -5054,8 +5048,8 @@ status_t SurfaceFlinger::setTransactionState(
}
std::vector<ResolvedComposerState> resolvedStates;
- resolvedStates.reserve(states.size());
- for (auto& state : states) {
+ resolvedStates.reserve(transactionState.mComposerStates.size());
+ for (auto& state : transactionState.mComposerStates) {
resolvedStates.emplace_back(std::move(state));
auto& resolvedState = resolvedStates.back();
resolvedState.layerId = LayerHandle::getLayerId(resolvedState.state.surface);
@@ -5066,7 +5060,7 @@ status_t SurfaceFlinger::setTransactionState(
layer->getDebugName() : std::to_string(resolvedState.state.layerId);
resolvedState.externalTexture =
getExternalTextureFromBufferData(*resolvedState.state.bufferData,
- layerName.c_str(), transactionId);
+ layerName.c_str(), transactionState.getId());
if (resolvedState.externalTexture) {
resolvedState.state.bufferData->buffer = resolvedState.externalTexture->getBuffer();
}
@@ -5088,22 +5082,12 @@ status_t SurfaceFlinger::setTransactionState(
}
}
- QueuedTransactionState state{frameTimelineInfo,
- resolvedStates,
- displays,
- flags,
- applyToken,
- std::move(inputWindowCommands),
- desiredPresentTime,
- isAutoTimestamp,
+ QueuedTransactionState state{std::move(transactionState),
+ std::move(resolvedStates),
std::move(uncacheBufferIds),
postTime,
- hasListenerCallbacks,
- listenerCallbacks,
originPid,
- originUid,
- transactionId,
- mergedTransactionIds};
+ originUid};
state.workloadHint = queuedWorkload;
if (mTransactionTracing) {
@@ -5126,16 +5110,16 @@ status_t SurfaceFlinger::setTransactionState(
for (const auto& [displayId, data] : mNotifyExpectedPresentMap) {
if (data.hintStatus.load() == NotifyExpectedPresentHintStatus::ScheduleOnTx) {
- scheduleNotifyExpectedPresentHint(displayId, VsyncId{frameTimelineInfo.vsyncId});
+ scheduleNotifyExpectedPresentHint(displayId, VsyncId{state.frameTimelineInfo.vsyncId});
}
}
- setTransactionFlags(eTransactionFlushNeeded, schedule, applyToken, frameHint);
+ setTransactionFlags(eTransactionFlushNeeded, schedule, state.applyToken, frameHint);
return NO_ERROR;
}
bool SurfaceFlinger::applyTransactionState(
const FrameTimelineInfo& frameTimelineInfo, std::vector<ResolvedComposerState>& states,
- Vector<DisplayState>& displays, uint32_t flags,
+ std::span<DisplayState> displays, uint32_t flags,
const InputWindowCommands& inputWindowCommands, const int64_t desiredPresentTime,
bool isAutoTimestamp, const std::vector<uint64_t>& uncacheBufferIds, const int64_t postTime,
bool hasListenerCallbacks, const std::vector<ListenerCallbacks>& listenerCallbacks,
@@ -5625,7 +5609,8 @@ void SurfaceFlinger::initializeDisplays() {
auto layerStack = ui::DEFAULT_LAYER_STACK.id;
for (const auto& [id, display] : FTL_FAKE_GUARD(mStateLock, mPhysicalDisplays)) {
- state.displays.push(DisplayState(display.token(), ui::LayerStack::fromValue(layerStack++)));
+ state.displays.emplace_back(
+ DisplayState(display.token(), ui::LayerStack::fromValue(layerStack++)));
}
std::vector<QueuedTransactionState> transactions;