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

Commit 1a26c9aa authored by Romain Guy's avatar Romain Guy Committed by Android (Google) Code Review
Browse files

Merge "Improve export to bitmap layers for HierarchyViewer."

parents 464bf236 65554f27
Loading
Loading
Loading
Loading
+6 −4
Original line number Diff line number Diff line
@@ -1040,7 +1040,7 @@ public class ViewDebug {
            clientStream.writeInt(outRect.width());
            clientStream.writeInt(outRect.height());
    
            captureViewLayer(root, clientStream);
            captureViewLayer(root, clientStream, true);
            
            clientStream.write(2);
        } finally {
@@ -1048,9 +1048,11 @@ public class ViewDebug {
        }
    }

    private static void captureViewLayer(View view, DataOutputStream clientStream)
    private static void captureViewLayer(View view, DataOutputStream clientStream, boolean visible)
            throws IOException {

        final boolean localVisible = view.getVisibility() == View.VISIBLE && visible;

        if ((view.mPrivateFlags & View.SKIP_DRAW) != View.SKIP_DRAW) {
            final int id = view.getId();
            String name = view.getClass().getSimpleName();
@@ -1060,7 +1062,7 @@ public class ViewDebug {
    
            clientStream.write(1);
            clientStream.writeUTF(name);
            clientStream.writeByte(view.getVisibility() == View.VISIBLE ? 1 : 0);
            clientStream.writeByte(localVisible ? 1 : 0);
    
            int[] position = new int[2];
            // XXX: Should happen on the UI thread
@@ -1086,7 +1088,7 @@ public class ViewDebug {
            int count = group.getChildCount();

            for (int i = 0; i < count; i++) {
                captureViewLayer(group.getChildAt(i), clientStream);
                captureViewLayer(group.getChildAt(i), clientStream, localVisible);
            }
        }
    }
+17 −3
Original line number Diff line number Diff line
@@ -1274,13 +1274,27 @@ public abstract class ViewGroup extends View implements ViewParent, ViewManager

    @Override
    Bitmap createSnapshot(Bitmap.Config quality, int backgroundColor, boolean skipChildren) {
        int oldCount = mChildrenCount;
        int count = mChildrenCount;
        int[] visibilities = null;

        if (skipChildren) {
            mChildrenCount = 0;
            visibilities = new int[count];
            for (int i = 0; i < count; i++) {
                View child = getChildAt(i);
                visibilities[i] = child.getVisibility();
                if (visibilities[i] == View.VISIBLE) {
                    child.setVisibility(INVISIBLE);
                }
            }
        }

        Bitmap b = super.createSnapshot(quality, backgroundColor, skipChildren);
        mChildrenCount = oldCount;

        if (skipChildren) {
            for (int i = 0; i < count; i++) {
                getChildAt(i).setVisibility(visibilities[i]);
            }        
        }

        return b;
    }