Create a wrapper for atrace macros
Create a SF specific macro to call into atrace. This will make the
switch to perfetto for capturing atrace tags easier.
Flag: EXEMPT refactor
Bug: 349905670
Test: perfetto
Change-Id: I4d046d837f52ef78b08e3c97556f2eddb06232dd
diff --git a/services/surfaceflinger/Scheduler/LayerHistory.cpp b/services/surfaceflinger/Scheduler/LayerHistory.cpp
index a819b79..4fd4c0e 100644
--- a/services/surfaceflinger/Scheduler/LayerHistory.cpp
+++ b/services/surfaceflinger/Scheduler/LayerHistory.cpp
@@ -21,8 +21,8 @@
#include "LayerHistory.h"
#include <android-base/stringprintf.h>
+#include <common/trace.h>
#include <cutils/properties.h>
-#include <gui/TraceUtils.h>
#include <utils/Log.h>
#include <utils/Timers.h>
@@ -72,7 +72,7 @@
void trace(const LayerInfo& info, LayerHistory::LayerVoteType type, int fps) {
const auto traceType = [&](LayerHistory::LayerVoteType checkedType, int value) {
- ATRACE_INT(info.getTraceTag(checkedType), type == checkedType ? value : 0);
+ SFTRACE_INT(info.getTraceTag(checkedType), type == checkedType ? value : 0);
};
traceType(LayerHistory::LayerVoteType::NoVote, 1);
@@ -190,7 +190,7 @@
}
auto LayerHistory::summarize(const RefreshRateSelector& selector, nsecs_t now) -> Summary {
- ATRACE_CALL();
+ SFTRACE_CALL();
Summary summary;
std::lock_guard lock(mLock);
@@ -204,7 +204,7 @@
ALOGV("%s has priority: %d %s focused", info->getName().c_str(), frameRateSelectionPriority,
layerFocused ? "" : "not");
- ATRACE_FORMAT("%s", info->getName().c_str());
+ SFTRACE_FORMAT("%s", info->getName().c_str());
const auto votes = info->getRefreshRateVote(selector, now);
for (LayerInfo::LayerVote vote : votes) {
if (vote.isNoVote()) {
@@ -222,8 +222,8 @@
const std::string categoryString = vote.category == FrameRateCategory::Default
? ""
: base::StringPrintf("category=%s", ftl::enum_string(vote.category).c_str());
- ATRACE_FORMAT_INSTANT("%s %s %s (%.2f)", ftl::enum_string(vote.type).c_str(),
- to_string(vote.fps).c_str(), categoryString.c_str(), weight);
+ SFTRACE_FORMAT_INSTANT("%s %s %s (%.2f)", ftl::enum_string(vote.type).c_str(),
+ to_string(vote.fps).c_str(), categoryString.c_str(), weight);
summary.push_back({info->getName(), info->getOwnerUid(), vote.type, vote.fps,
vote.seamlessness, vote.category, vote.categorySmoothSwitchOnly,
weight, layerFocused});
@@ -238,7 +238,7 @@
}
void LayerHistory::partitionLayers(nsecs_t now, bool isVrrDevice) {
- ATRACE_CALL();
+ SFTRACE_CALL();
const nsecs_t threshold = getActiveLayerThreshold(now);
// iterate over inactive map
@@ -310,7 +310,7 @@
if (gameModeFrameRateOverride.isValid()) {
info->setLayerVote({gameFrameRateOverrideVoteType, gameModeFrameRateOverride});
- ATRACE_FORMAT_INSTANT("GameModeFrameRateOverride");
+ SFTRACE_FORMAT_INSTANT("GameModeFrameRateOverride");
if (CC_UNLIKELY(mTraceEnabled)) {
trace(*info, gameFrameRateOverrideVoteType,
gameModeFrameRateOverride.getIntValue());
@@ -326,19 +326,19 @@
} else if (gameDefaultFrameRateOverride.isValid()) {
info->setLayerVote(
{gameFrameRateOverrideVoteType, gameDefaultFrameRateOverride});
- ATRACE_FORMAT_INSTANT("GameDefaultFrameRateOverride");
+ SFTRACE_FORMAT_INSTANT("GameDefaultFrameRateOverride");
if (CC_UNLIKELY(mTraceEnabled)) {
trace(*info, gameFrameRateOverrideVoteType,
gameDefaultFrameRateOverride.getIntValue());
}
} else {
if (frameRate.isValid() && !frameRate.isVoteValidForMrr(isVrrDevice)) {
- ATRACE_FORMAT_INSTANT("Reset layer to ignore explicit vote on MRR %s: %s "
- "%s %s",
- info->getName().c_str(),
- ftl::enum_string(frameRate.vote.type).c_str(),
- to_string(frameRate.vote.rate).c_str(),
- ftl::enum_string(frameRate.category).c_str());
+ SFTRACE_FORMAT_INSTANT("Reset layer to ignore explicit vote on MRR %s: %s "
+ "%s %s",
+ info->getName().c_str(),
+ ftl::enum_string(frameRate.vote.type).c_str(),
+ to_string(frameRate.vote.rate).c_str(),
+ ftl::enum_string(frameRate.category).c_str());
}
info->resetLayerVote();
}
@@ -349,12 +349,12 @@
frameRate.vote.seamlessness, frameRate.category});
} else {
if (!frameRate.isVoteValidForMrr(isVrrDevice)) {
- ATRACE_FORMAT_INSTANT("Reset layer to ignore explicit vote on MRR %s: %s "
- "%s %s",
- info->getName().c_str(),
- ftl::enum_string(frameRate.vote.type).c_str(),
- to_string(frameRate.vote.rate).c_str(),
- ftl::enum_string(frameRate.category).c_str());
+ SFTRACE_FORMAT_INSTANT("Reset layer to ignore explicit vote on MRR %s: %s "
+ "%s %s",
+ info->getName().c_str(),
+ ftl::enum_string(frameRate.vote.type).c_str(),
+ to_string(frameRate.vote.rate).c_str(),
+ ftl::enum_string(frameRate.category).c_str());
}
info->resetLayerVote();
}
@@ -421,7 +421,7 @@
bool LayerHistory::isSmallDirtyArea(uint32_t dirtyArea, float threshold) const {
const float ratio = (float)dirtyArea / mDisplayArea;
const bool isSmallDirty = ratio <= threshold;
- ATRACE_FORMAT_INSTANT("small dirty=%s, ratio=%.3f", isSmallDirty ? "true" : "false", ratio);
+ SFTRACE_FORMAT_INSTANT("small dirty=%s, ratio=%.3f", isSmallDirty ? "true" : "false", ratio);
return isSmallDirty;
}