Add a --color option to dumpsys SurfaceFlinger

colorize a bit the output of dumpsys SurfaceFlinger to
make it easier to read. Right now it will bold the
title of each section and use green for the name of
each layer.

Change-Id: I0d9f18d115401cb45109d244ef3a278481f68cc6
This commit is contained in:
Mathias Agopian 2013-04-22 17:52:16 +02:00
parent 74d211ae26
commit 3e25fd8609
4 changed files with 103 additions and 12 deletions

View File

@ -0,0 +1,65 @@
/*
* Copyright 2013 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef ANDROID_SURFACE_FLINGER_COLORIZER_H
#define ANDROID_SURFACE_FLINGER_COLORIZER_H
namespace android {
// ---------------------------------------------------------------------------
class Colorizer {
bool mEnabled;
public:
enum color {
RED = 31,
GREEN = 32,
YELLOW = 33,
BLUE = 34,
MAGENTA = 35,
CYAN = 36,
WHITE = 37
};
Colorizer(bool enabled)
: mEnabled(enabled) {
}
void colorize(String8& out, color c) {
if (mEnabled) {
out.appendFormat("\e[%dm", c);
}
}
void bold(String8& out) {
if (mEnabled) {
out.append("\e[1m");
}
}
void reset(String8& out) {
if (mEnabled) {
out.append("\e[0m");
}
}
};
// ---------------------------------------------------------------------------
}; // namespace android
#endif /* ANDROID_SURFACE_FLINGER_COLORIZER_H */

View File

@ -36,6 +36,7 @@
#include <gui/Surface.h>
#include "clz.h"
#include "Colorizer.h"
#include "DisplayDevice.h"
#include "GLExtensions.h"
#include "Layer.h"
@ -1178,13 +1179,15 @@ void Layer::updateTransformHint(const sp<const DisplayDevice>& hw) const {
// debugging
// ----------------------------------------------------------------------------
void Layer::dump(String8& result) const
void Layer::dump(String8& result, Colorizer& colorizer) const
{
const Layer::State& s(drawingState());
colorizer.colorize(result, Colorizer::GREEN);
result.appendFormat(
"+ %s %p (%s)\n",
getTypeId(), this, getName().string());
colorizer.reset(result);
s.activeTransparentRegion.dump(result, "transparentRegion");
visibleRegion.dump(result, "visibleRegion");
@ -1224,11 +1227,6 @@ void Layer::dump(String8& result) const
}
}
void Layer::shortDump(String8& result) const {
Layer::dump(result);
}
void Layer::dumpStats(String8& result) const {
mFrameTracker.dump(result);
}

View File

@ -51,6 +51,7 @@ namespace android {
// ---------------------------------------------------------------------------
class Client;
class Colorizer;
class DisplayDevice;
class GraphicBuffer;
class SurfaceFlinger;
@ -304,8 +305,7 @@ public:
/* always call base class first */
virtual void dump(String8& result) const;
virtual void shortDump(String8& result) const;
virtual void dump(String8& result, Colorizer& colorizer) const;
virtual void dumpStats(String8& result) const;
virtual void clearStats();

View File

@ -55,10 +55,11 @@
#include <private/android_filesystem_config.h>
#include <private/gui/SyncFeatures.h>
#include "Client.h"
#include "clz.h"
#include "Colorizer.h"
#include "DdmConnection.h"
#include "DisplayDevice.h"
#include "Client.h"
#include "EventThread.h"
#include "GLExtensions.h"
#include "Layer.h"
@ -2285,6 +2286,15 @@ void SurfaceFlinger::clearStatsLocked(const Vector<String16>& args, size_t& inde
void SurfaceFlinger::dumpAllLocked(const Vector<String16>& args, size_t& index,
String8& result) const
{
bool colorize = false;
if (index < args.size()
&& (args[index] == String16("--color"))) {
colorize = true;
index++;
}
Colorizer colorizer(colorize);
// figure out if we're stuck somewhere
const nsecs_t now = systemTime();
const nsecs_t inSwapBuffers(mDebugInSwapBuffers);
@ -2295,13 +2305,18 @@ void SurfaceFlinger::dumpAllLocked(const Vector<String16>& args, size_t& index,
/*
* Dump library configuration.
*/
colorizer.bold(result);
result.append("Build configuration:");
colorizer.reset(result);
appendSfConfigString(result);
appendUiConfigString(result);
appendGuiConfigString(result);
result.append("\n");
colorizer.bold(result);
result.append("Sync configuration: ");
colorizer.reset(result);
result.append(SyncFeatures::getInstance().toString());
result.append("\n");
@ -2310,17 +2325,21 @@ void SurfaceFlinger::dumpAllLocked(const Vector<String16>& args, size_t& index,
*/
const LayerVector& currentLayers = mCurrentState.layersSortedByZ;
const size_t count = currentLayers.size();
colorizer.bold(result);
result.appendFormat("Visible layers (count = %d)\n", count);
colorizer.reset(result);
for (size_t i=0 ; i<count ; i++) {
const sp<Layer>& layer(currentLayers[i]);
layer->dump(result);
layer->dump(result, colorizer);
}
/*
* Dump Display state
*/
colorizer.bold(result);
result.appendFormat("Displays (%d entries)\n", mDisplays.size());
colorizer.reset(result);
for (size_t dpy=0 ; dpy<mDisplays.size() ; dpy++) {
const sp<const DisplayDevice>& hw(mDisplays[dpy]);
hw->dump(result);
@ -2330,20 +2349,27 @@ void SurfaceFlinger::dumpAllLocked(const Vector<String16>& args, size_t& index,
* Dump SurfaceFlinger global state
*/
colorizer.bold(result);
result.append("SurfaceFlinger global state:\n");
colorizer.reset(result);
HWComposer& hwc(getHwComposer());
sp<const DisplayDevice> hw(getDefaultDisplayDevice());
const GLExtensions& extensions(GLExtensions::getInstance());
result.appendFormat("EGL implementation : %s\n%s\n",
eglQueryStringImplementationANDROID(mEGLDisplay, EGL_VERSION),
colorizer.bold(result);
result.appendFormat("EGL implementation : %s\n",
eglQueryStringImplementationANDROID(mEGLDisplay, EGL_VERSION));
colorizer.reset(result);
result.appendFormat("%s\n",
eglQueryStringImplementationANDROID(mEGLDisplay, EGL_EXTENSIONS));
colorizer.bold(result);
result.appendFormat("GLES: %s, %s, %s\n",
extensions.getVendor(),
extensions.getRenderer(),
extensions.getVersion());
colorizer.reset(result);
result.appendFormat("%s\n", extensions.getExtension());
hw->undefinedRegion.dump(result, "undefinedRegion");
@ -2382,7 +2408,9 @@ void SurfaceFlinger::dumpAllLocked(const Vector<String16>& args, size_t& index,
/*
* Dump HWComposer state
*/
colorizer.bold(result);
result.append("h/w composer state:\n");
colorizer.reset(result);
result.appendFormat(" h/w composer %s and %s\n",
hwc.initCheck()==NO_ERROR ? "present" : "not present",
(mDebugDisableHWC || mDebugRegion) ? "disabled" : "enabled");