SurfaceFlinger: add TracedOrdinal
There are few placed in the code where we trace the value of an ordinal
to systrace. This change adds TracedOrdinal that automatically trace
ordinals when their value change making the code cleaner.
Test: collect systrace
Bug: 131091080
Change-Id: I53351d090a0764c2f5ba8db8ac02849f78e1109b
diff --git a/services/surfaceflinger/SurfaceFlinger.cpp b/services/surfaceflinger/SurfaceFlinger.cpp
index 99440a6..210a28a 100644
--- a/services/surfaceflinger/SurfaceFlinger.cpp
+++ b/services/surfaceflinger/SurfaceFlinger.cpp
@@ -976,7 +976,6 @@
mPhaseOffsets->getOffsetThresholdForNextVsync());
}
mDesiredActiveConfigChanged = true;
- ATRACE_INT("DesiredActiveConfigChanged", mDesiredActiveConfigChanged);
if (mRefreshRateOverlay) {
mRefreshRateOverlay->changeRefreshRate(mDesiredActiveConfig.type);
@@ -1021,7 +1020,6 @@
std::lock_guard<std::mutex> lock(mActiveConfigLock);
mDesiredActiveConfig.event = Scheduler::ConfigEvent::None;
mDesiredActiveConfigChanged = false;
- ATRACE_INT("DesiredActiveConfigChanged", mDesiredActiveConfigChanged);
mScheduler->resyncToHardwareVsync(true, getVsyncPeriod());
mPhaseOffsets->setRefreshRateType(mUpcomingActiveConfig.type);
@@ -1713,12 +1711,12 @@
// seeing this same value.
populateExpectedPresentTime();
- bool frameMissed = previousFrameMissed();
- bool hwcFrameMissed = mHadDeviceComposition && frameMissed;
- bool gpuFrameMissed = mHadClientComposition && frameMissed;
- ATRACE_INT("FrameMissed", static_cast<int>(frameMissed));
- ATRACE_INT("HwcFrameMissed", static_cast<int>(hwcFrameMissed));
- ATRACE_INT("GpuFrameMissed", static_cast<int>(gpuFrameMissed));
+ const TracedOrdinal<bool> frameMissed = {"FrameMissed", previousFrameMissed()};
+ const TracedOrdinal<bool> hwcFrameMissed = {"HwcFrameMissed",
+ mHadDeviceComposition && frameMissed};
+ const TracedOrdinal<bool> gpuFrameMissed = {"GpuFrameMissed",
+ mHadClientComposition && frameMissed};
+
if (frameMissed) {
mFrameMissedCount++;
mTimeStats->incrementMissedFrames();
@@ -3402,8 +3400,9 @@
const Region bounds(displayState.bounds);
const DisplayRenderArea renderArea(displayDevice);
- const bool hasClientComposition = getHwComposer().hasClientComposition(displayId);
- ATRACE_INT("hasClientComposition", hasClientComposition);
+ const TracedOrdinal<bool> hasClientComposition = {"hasClientComposition",
+ getHwComposer().hasClientComposition(
+ displayId)};
bool applyColorMatrix = false;