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/Scheduler/DispSyncSource.cpp b/services/surfaceflinger/Scheduler/DispSyncSource.cpp
index 5faf46e..571c9ca 100644
--- a/services/surfaceflinger/Scheduler/DispSyncSource.cpp
+++ b/services/surfaceflinger/Scheduler/DispSyncSource.cpp
@@ -31,19 +31,16 @@
nsecs_t offsetThresholdForNextVsync, bool traceVsync,
const char* name)
: mName(name),
+ mValue(base::StringPrintf("VSYNC-%s", name), 0),
mTraceVsync(traceVsync),
mVsyncOnLabel(base::StringPrintf("VsyncOn-%s", name)),
- mVsyncEventLabel(base::StringPrintf("VSYNC-%s", name)),
- mVsyncOffsetLabel(base::StringPrintf("VsyncOffset-%s", name)),
- mVsyncNegativeOffsetLabel(base::StringPrintf("VsyncNegativeOffset-%s", name)),
mDispSync(dispSync),
- mPhaseOffset(phaseOffset),
+ mPhaseOffset(base::StringPrintf("VsyncOffset-%s", name), phaseOffset),
mOffsetThresholdForNextVsync(offsetThresholdForNextVsync) {}
void DispSyncSource::setVSyncEnabled(bool enable) {
std::lock_guard lock(mVsyncMutex);
if (enable) {
- tracePhaseOffset();
status_t err = mDispSync->addEventListener(mName, mPhaseOffset,
static_cast<DispSync::Callback*>(this),
mLastCallbackTime);
@@ -83,7 +80,6 @@
}
mPhaseOffset = phaseOffset;
- tracePhaseOffset();
// If we're not enabled, we don't need to mess with the listeners
if (!mEnabled) {
@@ -106,7 +102,6 @@
if (mTraceVsync) {
mValue = (mValue + 1) % 2;
- ATRACE_INT(mVsyncEventLabel.c_str(), mValue);
}
if (callback != nullptr) {
@@ -114,14 +109,4 @@
}
}
-void DispSyncSource::tracePhaseOffset() {
- if (mPhaseOffset > 0) {
- ATRACE_INT(mVsyncOffsetLabel.c_str(), mPhaseOffset);
- ATRACE_INT(mVsyncNegativeOffsetLabel.c_str(), 0);
- } else {
- ATRACE_INT(mVsyncOffsetLabel.c_str(), 0);
- ATRACE_INT(mVsyncNegativeOffsetLabel.c_str(), -mPhaseOffset);
- }
-}
-
} // namespace android