summaryrefslogtreecommitdiff
path: root/services/surfaceflinger/SurfaceFlinger.cpp
diff options
context:
space:
mode:
author Dominik Laskowski <domlaskowski@google.com> 2022-07-07 11:50:20 -0700
committer Dominik Laskowski <domlaskowski@google.com> 2022-07-12 12:18:18 -0700
commit4376bd84b4ee9d038daeba17dfae3e7174bbf5bd (patch)
treee06cfab12535d17a88acf98ee9dfcc5bff308823 /services/surfaceflinger/SurfaceFlinger.cpp
parent5d164f2b95e5f867307b7105bbaaadd6a7fcc422 (diff)
SF: Remove CompositorTiming state and lock
Replace the CompositorTiming::interval access on layer creation with a RefreshRateConfigs lookup. Bug: 185535769 Test: Perfetto timeline is green. Change-Id: I0d2240f879b60c1d0ffe68be35c96a227e495ce3
Diffstat (limited to 'services/surfaceflinger/SurfaceFlinger.cpp')
-rw-r--r--services/surfaceflinger/SurfaceFlinger.cpp26
1 files changed, 8 insertions, 18 deletions
diff --git a/services/surfaceflinger/SurfaceFlinger.cpp b/services/surfaceflinger/SurfaceFlinger.cpp
index 65e4b4e2c7..9f1cf9c362 100644
--- a/services/surfaceflinger/SurfaceFlinger.cpp
+++ b/services/surfaceflinger/SurfaceFlinger.cpp
@@ -1886,11 +1886,6 @@ void SurfaceFlinger::onComposerHalVsync(hal::HWDisplayId hwcDisplayId, int64_t t
}
}
-void SurfaceFlinger::getCompositorTiming(CompositorTiming* compositorTiming) {
- std::lock_guard<std::mutex> lock(getBE().mCompositorTimingLock);
- *compositorTiming = getBE().mCompositorTiming;
-}
-
void SurfaceFlinger::onComposerHalHotplug(hal::HWDisplayId hwcDisplayId,
hal::Connection connection) {
const bool connected = connection == hal::Connection::CONNECTED;
@@ -2349,8 +2344,8 @@ nsecs_t SurfaceFlinger::trackPresentLatency(nsecs_t compositeTime,
return compositeToPresentLatency;
}
-void SurfaceFlinger::setCompositorTimingSnapped(nsecs_t vsyncDeadline, nsecs_t vsyncPeriod,
- nsecs_t compositeToPresentLatency) {
+CompositorTiming SurfaceFlinger::makeCompositorTiming(nsecs_t vsyncDeadline, nsecs_t vsyncPeriod,
+ nsecs_t compositeToPresentLatency) {
// Avoid division by 0 by defaulting to 60Hz
vsyncPeriod = vsyncPeriod ?: (60_Hz).getPeriodNsecs();
@@ -2377,10 +2372,9 @@ void SurfaceFlinger::setCompositorTimingSnapped(nsecs_t vsyncDeadline, nsecs_t v
const nsecs_t snappedCompositeToPresentLatency =
(extraVsyncs > 0) ? idealLatency + (extraVsyncs * vsyncPeriod) : idealLatency;
- std::lock_guard<std::mutex> lock(getBE().mCompositorTimingLock);
- getBE().mCompositorTiming.deadline = vsyncDeadline - idealLatency;
- getBE().mCompositorTiming.interval = vsyncPeriod;
- getBE().mCompositorTiming.presentLatency = snappedCompositeToPresentLatency;
+ return {.deadline = vsyncDeadline - idealLatency,
+ .interval = vsyncPeriod,
+ .presentLatency = snappedCompositeToPresentLatency};
}
bool SurfaceFlinger::isHdrLayer(Layer* layer) const {
@@ -2469,7 +2463,7 @@ void SurfaceFlinger::postComposition() {
// We use the CompositionEngine::getLastFrameRefreshTimestamp() which might
// be sampled a little later than when we started doing work for this frame,
- // but that should be okay since setCompositorTimingSnapped has snapping logic.
+ // but that should be okay since makeCompositorTiming has snapping logic.
const nsecs_t compositeTime = mCompositionEngine->getLastFrameRefreshTimestamp();
const nsecs_t presentLatency =
trackPresentLatency(compositeTime, mPreviousPresentFences[0].fenceTime);
@@ -2477,13 +2471,9 @@ void SurfaceFlinger::postComposition() {
const auto& schedule = mScheduler->getVsyncSchedule();
const TimePoint vsyncDeadline = schedule.vsyncDeadlineAfter(TimePoint::fromNs(now));
const Period vsyncPeriod = schedule.period();
- setCompositorTimingSnapped(vsyncDeadline.ns(), vsyncPeriod.ns(), presentLatency);
- CompositorTiming compositorTiming;
- {
- std::lock_guard<std::mutex> lock(getBE().mCompositorTimingLock);
- compositorTiming = getBE().mCompositorTiming;
- }
+ const CompositorTiming compositorTiming =
+ makeCompositorTiming(vsyncDeadline.ns(), vsyncPeriod.ns(), presentLatency);
for (const auto& layer: mLayersWithQueuedFrames) {
layer->onPostComposition(display, glCompositionDoneFenceTime,