Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 63cca691 authored by Konstantin Lopyrev's avatar Konstantin Lopyrev Committed by Android (Google) Code Review
Browse files

Merge "Make sure profiling is done only for views that are actually measured,...

Merge "Make sure profiling is done only for views that are actually measured, laid out and drawn." into gingerbread
parents 66edf558 c6dc4570
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -1420,8 +1420,8 @@ public class View implements Drawable.Callback, KeyEvent.Callback, Accessibility
    static final int MEASURED_DIMENSION_SET         = 0x00000800;
    /** {@hide} */
    static final int FORCE_LAYOUT                   = 0x00001000;

    private static final int LAYOUT_REQUIRED        = 0x00002000;
    /** {@hide} */
    static final int LAYOUT_REQUIRED                = 0x00002000;

    private static final int PRESSED                = 0x00004000;

+66 −52
Original line number Diff line number Diff line
@@ -934,7 +934,15 @@ public class ViewDebug {

    private static void profileViewAndChildren(final View view, BufferedWriter out)
            throws IOException {
        final long durationMeasure = profileViewOperation(view, new ViewOperation<Void>() {
        profileViewAndChildren(view, out, true);
    }

    private static void profileViewAndChildren(final View view, BufferedWriter out, boolean root)
            throws IOException {

        long durationMeasure =
                (root || (view.mPrivateFlags & View.MEASURED_DIMENSION_SET) != 0) ? profileViewOperation(
                        view, new ViewOperation<Void>() {
                            public Void[] pre() {
                                forceLayout(view);
                                return null;
@@ -957,9 +965,11 @@ public class ViewDebug {

                            public void post(Void... data) {
                            }
        });

        final long durationLayout = profileViewOperation(view, new ViewOperation<Void>() {
                        })
                        : 0;
        long durationLayout =
                (root || (view.mPrivateFlags & View.LAYOUT_REQUIRED) != 0) ? profileViewOperation(
                        view, new ViewOperation<Void>() {
                            public Void[] pre() {
                                return null;
                            }
@@ -970,14 +980,16 @@ public class ViewDebug {

                            public void post(Void... data) {
                            }
        });

        final long durationDraw = profileViewOperation(view, new ViewOperation<Object>() {
                        }) : 0;
        long durationDraw =
                (root || (view.mPrivateFlags & View.DRAWN) != 0) ? profileViewOperation(view,
                        new ViewOperation<Object>() {
                            public Object[] pre() {
                final DisplayMetrics metrics = view.getResources().getDisplayMetrics();
                                final DisplayMetrics metrics =
                                        view.getResources().getDisplayMetrics();
                                final Bitmap bitmap =
                        Bitmap.createBitmap(metrics.widthPixels, metrics.heightPixels,
                                Bitmap.Config.RGB_565);
                                        Bitmap.createBitmap(metrics.widthPixels,
                                                metrics.heightPixels, Bitmap.Config.RGB_565);
                                final Canvas canvas = new Canvas(bitmap);
                                return new Object[] {
                                        bitmap, canvas
@@ -991,8 +1003,7 @@ public class ViewDebug {
                            public void post(Object... data) {
                                ((Bitmap) data[0]).recycle();
                            }
        });

                        }) : 0;
        out.write(String.valueOf(durationMeasure));
        out.write(' ');
        out.write(String.valueOf(durationLayout));
@@ -1003,7 +1014,7 @@ public class ViewDebug {
            ViewGroup group = (ViewGroup) view;
            final int count = group.getChildCount();
            for (int i = 0; i < count; i++) {
                profileViewAndChildren(group.getChildAt(i), out);
                profileViewAndChildren(group.getChildAt(i), out, false);
            }
        }
    }
@@ -1033,7 +1044,10 @@ public class ViewDebug {
        });

        try {
            latch.await(CAPTURE_TIMEOUT, TimeUnit.MILLISECONDS);
            if (!latch.await(CAPTURE_TIMEOUT, TimeUnit.MILLISECONDS)) {
                Log.w("View", "Could not complete the profiling of the view " + view);
                return -1;
            }
        } catch (InterruptedException e) {
            Log.w("View", "Could not complete the profiling of the view " + view);
            Thread.currentThread().interrupt();