diff --git a/services/surfaceflinger/Colorizer.h b/services/surfaceflinger/Colorizer.h new file mode 100644 index 000000000..652448159 --- /dev/null +++ b/services/surfaceflinger/Colorizer.h @@ -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 */ diff --git a/services/surfaceflinger/Layer.cpp b/services/surfaceflinger/Layer.cpp index 91113c913..989658157 100644 --- a/services/surfaceflinger/Layer.cpp +++ b/services/surfaceflinger/Layer.cpp @@ -36,6 +36,7 @@ #include #include "clz.h" +#include "Colorizer.h" #include "DisplayDevice.h" #include "GLExtensions.h" #include "Layer.h" @@ -1178,13 +1179,15 @@ void Layer::updateTransformHint(const sp& 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); } diff --git a/services/surfaceflinger/Layer.h b/services/surfaceflinger/Layer.h index 2c06f1a0c..11fdbb571 100644 --- a/services/surfaceflinger/Layer.h +++ b/services/surfaceflinger/Layer.h @@ -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(); diff --git a/services/surfaceflinger/SurfaceFlinger.cpp b/services/surfaceflinger/SurfaceFlinger.cpp index dc73fe740..4b5429ff9 100644 --- a/services/surfaceflinger/SurfaceFlinger.cpp +++ b/services/surfaceflinger/SurfaceFlinger.cpp @@ -55,10 +55,11 @@ #include #include +#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& args, size_t& inde void SurfaceFlinger::dumpAllLocked(const Vector& 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& 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& 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& 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& hw(mDisplays[dpy]); hw->dump(result); @@ -2330,20 +2349,27 @@ void SurfaceFlinger::dumpAllLocked(const Vector& args, size_t& index, * Dump SurfaceFlinger global state */ + colorizer.bold(result); result.append("SurfaceFlinger global state:\n"); + colorizer.reset(result); HWComposer& hwc(getHwComposer()); sp 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& 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");