summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKonstantin Lopyrev <klopyrev@google.com>2010-08-04 11:12:19 -0700
committerAndroid Git Automerger <android-git-automerger@android.com>2010-08-04 11:12:19 -0700
commitbf0d12c2e2169ce94995c3bef66fe7b088468545 (patch)
tree792f01d6e19945381a97a523427b74b95a65b86e
parent2bf8028a23a2282f485a49d8ed037d28c5bd4a0d (diff)
parent77c444dd2bdc9bb2d54fc58420d263a83018190c (diff)
downloadframeworks_base-bf0d12c2e2169ce94995c3bef66fe7b088468545.zip
frameworks_base-bf0d12c2e2169ce94995c3bef66fe7b088468545.tar.gz
frameworks_base-bf0d12c2e2169ce94995c3bef66fe7b088468545.tar.bz2
am 77c444dd: am 6fcf3a51: Merge "Improving profiling of views." into gingerbread
Merge commit '77c444dd2bdc9bb2d54fc58420d263a83018190c' * commit '77c444dd2bdc9bb2d54fc58420d263a83018190c': Improving profiling of views.
-rw-r--r--core/java/android/view/ViewDebug.java137
1 files changed, 77 insertions, 60 deletions
diff --git a/core/java/android/view/ViewDebug.java b/core/java/android/view/ViewDebug.java
index d2563a8..5dd45f9 100644
--- a/core/java/android/view/ViewDebug.java
+++ b/core/java/android/view/ViewDebug.java
@@ -916,77 +916,94 @@ public class ViewDebug {
out = new BufferedWriter(new OutputStreamWriter(clientStream), 32 * 1024);
if (view != null) {
- final long durationMeasure = profileViewOperation(view, new ViewOperation<Void>() {
- public Void[] pre() {
- forceLayout(view);
- return 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 void forceLayout(View view) {
- view.forceLayout();
- if (view instanceof ViewGroup) {
- ViewGroup group = (ViewGroup) view;
- final int count = group.getChildCount();
- for (int i = 0; i < count; i++) {
- forceLayout(group.getChildAt(i));
- }
- }
- }
+ private static void profileViewAndChildren(final View view, BufferedWriter out)
+ throws IOException {
+ final long durationMeasure = profileViewOperation(view, new ViewOperation<Void>() {
+ public Void[] pre() {
+ forceLayout(view);
+ return null;
+ }
- public void run(Void... data) {
- view.measure(view.mOldWidthMeasureSpec, view.mOldHeightMeasureSpec);
+ private void forceLayout(View view) {
+ view.forceLayout();
+ if (view instanceof ViewGroup) {
+ ViewGroup group = (ViewGroup) view;
+ final int count = group.getChildCount();
+ for (int i = 0; i < count; i++) {
+ forceLayout(group.getChildAt(i));
}
+ }
+ }
- public void post(Void... data) {
- }
- });
+ public void run(Void... data) {
+ view.measure(view.mOldWidthMeasureSpec, view.mOldHeightMeasureSpec);
+ }
- final long durationLayout = profileViewOperation(view, new ViewOperation<Void>() {
- public Void[] pre() {
- return null;
- }
+ public void post(Void... data) {
+ }
+ });
- public void run(Void... data) {
- view.layout(view.mLeft, view.mTop, view.mRight, view.mBottom);
- }
+ final long durationLayout = profileViewOperation(view, new ViewOperation<Void>() {
+ public Void[] pre() {
+ return null;
+ }
- public void post(Void... data) {
- }
- });
-
- final long durationDraw = profileViewOperation(view, new ViewOperation<Object>() {
- public Object[] pre() {
- final DisplayMetrics metrics = view.getResources().getDisplayMetrics();
- final Bitmap bitmap = Bitmap.createBitmap(metrics.widthPixels,
- metrics.heightPixels, Bitmap.Config.RGB_565);
- final Canvas canvas = new Canvas(bitmap);
- return new Object[] { bitmap, canvas };
- }
+ public void run(Void... data) {
+ view.layout(view.mLeft, view.mTop, view.mRight, view.mBottom);
+ }
- public void run(Object... data) {
- view.draw((Canvas) data[1]);
- }
+ public void post(Void... data) {
+ }
+ });
- public void post(Object... data) {
- ((Bitmap) data[0]).recycle();
- }
- });
+ final long durationDraw = profileViewOperation(view, new ViewOperation<Object>() {
+ public Object[] pre() {
+ final DisplayMetrics metrics = view.getResources().getDisplayMetrics();
+ final Bitmap bitmap =
+ Bitmap.createBitmap(metrics.widthPixels, metrics.heightPixels,
+ Bitmap.Config.RGB_565);
+ final Canvas canvas = new Canvas(bitmap);
+ return new Object[] {
+ bitmap, canvas
+ };
+ }
- out.write(String.valueOf(durationMeasure));
- out.write(' ');
- out.write(String.valueOf(durationLayout));
- out.write(' ');
- out.write(String.valueOf(durationDraw));
- out.newLine();
- } else {
- out.write("-1 -1 -1");
- out.newLine();
+ public void run(Object... data) {
+ view.draw((Canvas) data[1]);
}
- } catch (Exception e) {
- android.util.Log.w("View", "Problem profiling the view:", e);
- } finally {
- if (out != null) {
- out.close();
+
+ public void post(Object... data) {
+ ((Bitmap) data[0]).recycle();
+ }
+ });
+
+ out.write(String.valueOf(durationMeasure));
+ out.write(' ');
+ out.write(String.valueOf(durationLayout));
+ out.write(' ');
+ out.write(String.valueOf(durationDraw));
+ out.newLine();
+ if (view instanceof ViewGroup) {
+ ViewGroup group = (ViewGroup) view;
+ final int count = group.getChildCount();
+ for (int i = 0; i < count; i++) {
+ profileViewAndChildren(group.getChildAt(i), out);
}
}
}