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/CompositionEngine/src/Output.cpp b/services/surfaceflinger/CompositionEngine/src/Output.cpp
index b40aea4..64cded8 100644
--- a/services/surfaceflinger/CompositionEngine/src/Output.cpp
+++ b/services/surfaceflinger/CompositionEngine/src/Output.cpp
@@ -17,6 +17,7 @@
#include <SurfaceFlingerProperties.sysprop.h>
#include <android-base/stringprintf.h>
#include <common/FlagManager.h>
+#include <common/trace.h>
#include <compositionengine/CompositionEngine.h>
#include <compositionengine/CompositionRefreshArgs.h>
#include <compositionengine/DisplayColorProfile.h>
@@ -31,7 +32,6 @@
#include <compositionengine/impl/planner/Planner.h>
#include <ftl/algorithm.h>
#include <ftl/future.h>
-#include <gui/TraceUtils.h>
#include <scheduler/FrameTargeter.h>
#include <scheduler/Time.h>
@@ -53,7 +53,6 @@
#include <android-base/properties.h>
#include <ui/DebugUtils.h>
#include <ui/HdrCapabilities.h>
-#include <utils/Trace.h>
#include "TracedOrdinal.h"
@@ -424,7 +423,7 @@
void Output::prepare(const compositionengine::CompositionRefreshArgs& refreshArgs,
LayerFESet& geomSnapshots) {
- ATRACE_CALL();
+ SFTRACE_CALL();
ALOGV(__FUNCTION__);
rebuildLayerStacks(refreshArgs, geomSnapshots);
@@ -453,8 +452,8 @@
})
.value();
};
- ATRACE_FORMAT("%s for %s%s", __func__, mNamePlusId.c_str(),
- stringifyExpectedPresentTime().c_str());
+ SFTRACE_FORMAT("%s for %s%s", __func__, mNamePlusId.c_str(),
+ stringifyExpectedPresentTime().c_str());
ALOGV(__FUNCTION__);
updateColorProfile(refreshArgs);
@@ -518,7 +517,7 @@
if (!outputState.isEnabled || CC_LIKELY(!refreshArgs.updatingOutputGeometryThisFrame)) {
return;
}
- ATRACE_CALL();
+ SFTRACE_CALL();
ALOGV(__FUNCTION__);
// Process the layers to determine visibility and coverage
@@ -804,7 +803,7 @@
}
void Output::updateCompositionState(const compositionengine::CompositionRefreshArgs& refreshArgs) {
- ATRACE_CALL();
+ SFTRACE_CALL();
ALOGV(__FUNCTION__);
if (!getState().isEnabled) {
@@ -831,14 +830,14 @@
return;
}
- ATRACE_CALL();
+ SFTRACE_CALL();
ALOGV(__FUNCTION__);
mPlanner->plan(getOutputLayersOrderedByZ());
}
void Output::writeCompositionState(const compositionengine::CompositionRefreshArgs& refreshArgs) {
- ATRACE_CALL();
+ SFTRACE_CALL();
ALOGV(__FUNCTION__);
if (!getState().isEnabled) {
@@ -1081,7 +1080,7 @@
}
void Output::prepareFrame() {
- ATRACE_CALL();
+ SFTRACE_CALL();
ALOGV(__FUNCTION__);
auto& outputState = editState();
@@ -1116,7 +1115,7 @@
}
GpuCompositionResult Output::prepareFrameAsync() {
- ATRACE_CALL();
+ SFTRACE_CALL();
ALOGV(__FUNCTION__);
auto& state = editState();
const auto& previousChanges = state.previousDeviceRequestedChanges;
@@ -1146,7 +1145,7 @@
state.strategyPrediction = predictionSucceeded ? CompositionStrategyPredictionState::SUCCESS
: CompositionStrategyPredictionState::FAIL;
if (!predictionSucceeded) {
- ATRACE_NAME("CompositionStrategyPredictionMiss");
+ SFTRACE_NAME("CompositionStrategyPredictionMiss");
resetCompositionStrategy();
if (chooseCompositionSuccess) {
applyCompositionStrategy(changes);
@@ -1155,7 +1154,7 @@
// Track the dequeued buffer to reuse so we don't need to dequeue another one.
compositionResult.buffer = buffer;
} else {
- ATRACE_NAME("CompositionStrategyPredictionHit");
+ SFTRACE_NAME("CompositionStrategyPredictionHit");
}
state.previousDeviceRequestedChanges = std::move(changes);
state.previousDeviceRequestedSuccess = chooseCompositionSuccess;
@@ -1187,7 +1186,7 @@
}
void Output::finishFrame(GpuCompositionResult&& result) {
- ATRACE_CALL();
+ SFTRACE_CALL();
ALOGV(__FUNCTION__);
const auto& outputState = getState();
if (!outputState.isEnabled) {
@@ -1276,7 +1275,7 @@
std::optional<base::unique_fd> Output::composeSurfaces(
const Region& debugRegion, std::shared_ptr<renderengine::ExternalTexture> tex,
base::unique_fd& fd) {
- ATRACE_CALL();
+ SFTRACE_CALL();
ALOGV(__FUNCTION__);
const auto& outputState = getState();
@@ -1317,13 +1316,13 @@
if (mClientCompositionRequestCache->exists(tex->getBuffer()->getId(),
clientCompositionDisplay,
clientCompositionLayers)) {
- ATRACE_NAME("ClientCompositionCacheHit");
+ SFTRACE_NAME("ClientCompositionCacheHit");
outputCompositionState.reusedClientComposition = true;
setExpensiveRenderingExpected(false);
// b/239944175 pass the fence associated with the buffer.
return base::unique_fd(std::move(fd));
}
- ATRACE_NAME("ClientCompositionCacheMiss");
+ SFTRACE_NAME("ClientCompositionCacheMiss");
mClientCompositionRequestCache->add(tex->getBuffer()->getId(), clientCompositionDisplay,
clientCompositionLayers);
}
@@ -1570,7 +1569,7 @@
}
void Output::presentFrameAndReleaseLayers(bool flushEvenWhenDisabled) {
- ATRACE_FORMAT("%s for %s", __func__, mNamePlusId.c_str());
+ SFTRACE_FORMAT("%s for %s", __func__, mNamePlusId.c_str());
ALOGV(__FUNCTION__);
if (!getState().isEnabled) {