SurfaceFlinger: Get rid of String8 in dumpsys
Test: build and gui/ui/renderengine/surfaceflinger tests and compare
dumpsys SurfaceFlinger results
Change-Id: Iafdaf73a0acbbbb8fbafc930ad86285106a07e13
diff --git a/services/surfaceflinger/Layer.cpp b/services/surfaceflinger/Layer.cpp
index f53ffae..8e7be47 100644
--- a/services/surfaceflinger/Layer.cpp
+++ b/services/surfaceflinger/Layer.cpp
@@ -25,6 +25,8 @@
#include <sys/types.h>
#include <algorithm>
+#include <android-base/stringprintf.h>
+
#include <cutils/compiler.h>
#include <cutils/native_handle.h>
#include <cutils/properties.h>
@@ -63,6 +65,8 @@
namespace android {
+using base::StringAppendF;
+
std::atomic<int32_t> Layer::sSequence{1};
Layer::Layer(const LayerCreationArgs& args)
@@ -1399,7 +1403,7 @@
info.mName = getName();
sp<Layer> parent = getParent();
info.mParentName = (parent == nullptr ? std::string("none") : parent->getName().string());
- info.mType = String8(getTypeId());
+ info.mType = std::string(getTypeId());
info.mTransparentRegion = ds.activeTransparentRegion_legacy;
info.mVisibleRegion = visibleRegion;
info.mSurfaceDamageRegion = surfaceDamageRegion;
@@ -1439,7 +1443,7 @@
return info;
}
-void Layer::miniDumpHeader(String8& result) {
+void Layer::miniDumpHeader(std::string& result) {
result.append("-------------------------------");
result.append("-------------------------------");
result.append("-----------------------------\n");
@@ -1454,50 +1458,51 @@
result.append("-----------------------------\n");
}
-void Layer::miniDump(String8& result, DisplayId displayId) const {
+void Layer::miniDump(std::string& result, DisplayId displayId) const {
if (!hasHwcLayer(displayId)) {
return;
}
- String8 name;
+ std::string name;
if (mName.length() > 77) {
std::string shortened;
shortened.append(mName.string(), 36);
shortened.append("[...]");
shortened.append(mName.string() + (mName.length() - 36), 36);
- name = shortened.c_str();
+ name = shortened;
} else {
- name = mName;
+ name = std::string(mName.string(), mName.size());
}
- result.appendFormat(" %s\n", name.string());
+ StringAppendF(&result, " %s\n", name.c_str());
const State& layerState(getDrawingState());
const LayerBE::HWCInfo& hwcInfo = getBE().mHwcLayers.at(displayId);
if (layerState.zOrderRelativeOf != nullptr || mDrawingParent != nullptr) {
- result.appendFormat(" rel %6d | ", layerState.z);
+ StringAppendF(&result, " rel %6d | ", layerState.z);
} else {
- result.appendFormat(" %10d | ", layerState.z);
+ StringAppendF(&result, " %10d | ", layerState.z);
}
- result.appendFormat("%10s | ", to_string(getCompositionType(displayId)).c_str());
- result.appendFormat("%10s | ", to_string(hwcInfo.transform).c_str());
+ StringAppendF(&result, "%10s | ", to_string(getCompositionType(displayId)).c_str());
+ StringAppendF(&result, "%10s | ", to_string(hwcInfo.transform).c_str());
const Rect& frame = hwcInfo.displayFrame;
- result.appendFormat("%4d %4d %4d %4d | ", frame.left, frame.top, frame.right, frame.bottom);
+ StringAppendF(&result, "%4d %4d %4d %4d | ", frame.left, frame.top, frame.right, frame.bottom);
const FloatRect& crop = hwcInfo.sourceCrop;
- result.appendFormat("%6.1f %6.1f %6.1f %6.1f\n", crop.left, crop.top, crop.right, crop.bottom);
+ StringAppendF(&result, "%6.1f %6.1f %6.1f %6.1f\n", crop.left, crop.top, crop.right,
+ crop.bottom);
result.append("- - - - - - - - - - - - - - - -\n");
std::string compositionInfoStr;
getBE().compositionInfo.dump(compositionInfoStr, "compositionInfo");
- result.append(compositionInfoStr.c_str());
+ result.append(compositionInfoStr);
result.append("- - - - - - - - - - - - - - - -");
result.append("- - - - - - - - - - - - - - - -");
result.append("- - - - - - - - - - - - - - -\n");
}
-void Layer::dumpFrameStats(String8& result) const {
+void Layer::dumpFrameStats(std::string& result) const {
mFrameTracker.dumpStats(result);
}
@@ -1513,8 +1518,8 @@
mFrameTracker.getStats(outStats);
}
-void Layer::dumpFrameEvents(String8& result) {
- result.appendFormat("- Layer %s (%s, %p)\n", getName().string(), getTypeId(), this);
+void Layer::dumpFrameEvents(std::string& result) {
+ StringAppendF(&result, "- Layer %s (%s, %p)\n", getName().string(), getTypeId(), this);
Mutex::Autolock lock(mFrameEventHistoryMutex);
mFrameEventHistory.checkFencesForCompletion();
mFrameEventHistory.dump(result);