am 6fcf3a51: Merge "Improving profiling of views." into gingerbread

Merge commit '6fcf3a518526d4f844830735ca1a2ae82a7500d8' into gingerbread-plus-aosp

* commit '6fcf3a518526d4f844830735ca1a2ae82a7500d8':
  Improving profiling of views.
This commit is contained in:
Konstantin Lopyrev
2010-08-03 11:26:25 -07:00
committed by Android Git Automerger

View File

@@ -916,6 +916,24 @@ public class ViewDebug {
out = new BufferedWriter(new OutputStreamWriter(clientStream), 32 * 1024); out = new BufferedWriter(new OutputStreamWriter(clientStream), 32 * 1024);
if (view != null) { if (view != null) {
profileViewAndChildren(view, out);
} else {
out.write("-1 -1 -1");
out.newLine();
}
out.write("DONE.");
out.newLine();
} catch (Exception e) {
android.util.Log.w("View", "Problem profiling the view:", e);
} finally {
if (out != null) {
out.close();
}
}
}
private static void profileViewAndChildren(final View view, BufferedWriter out)
throws IOException {
final long durationMeasure = profileViewOperation(view, new ViewOperation<Void>() { final long durationMeasure = profileViewOperation(view, new ViewOperation<Void>() {
public Void[] pre() { public Void[] pre() {
forceLayout(view); forceLayout(view);
@@ -957,10 +975,13 @@ public class ViewDebug {
final long durationDraw = profileViewOperation(view, new ViewOperation<Object>() { final long durationDraw = profileViewOperation(view, new ViewOperation<Object>() {
public Object[] pre() { public Object[] pre() {
final DisplayMetrics metrics = view.getResources().getDisplayMetrics(); final DisplayMetrics metrics = view.getResources().getDisplayMetrics();
final Bitmap bitmap = Bitmap.createBitmap(metrics.widthPixels, final Bitmap bitmap =
metrics.heightPixels, Bitmap.Config.RGB_565); Bitmap.createBitmap(metrics.widthPixels, metrics.heightPixels,
Bitmap.Config.RGB_565);
final Canvas canvas = new Canvas(bitmap); final Canvas canvas = new Canvas(bitmap);
return new Object[] { bitmap, canvas }; return new Object[] {
bitmap, canvas
};
} }
public void run(Object... data) { public void run(Object... data) {
@@ -978,15 +999,11 @@ public class ViewDebug {
out.write(' '); out.write(' ');
out.write(String.valueOf(durationDraw)); out.write(String.valueOf(durationDraw));
out.newLine(); out.newLine();
} else { if (view instanceof ViewGroup) {
out.write("-1 -1 -1"); ViewGroup group = (ViewGroup) view;
out.newLine(); final int count = group.getChildCount();
} for (int i = 0; i < count; i++) {
} catch (Exception e) { profileViewAndChildren(group.getChildAt(i), out);
android.util.Log.w("View", "Problem profiling the view:", e);
} finally {
if (out != null) {
out.close();
} }
} }
} }