Loading core/java/android/view/View.java +2 −1 Original line number Diff line number Diff line Loading @@ -4496,8 +4496,9 @@ public class View implements Drawable.Callback, KeyEvent.Callback, * When non-null and valid, this is expected to contain an up-to-date copy * of the background drawable. It is cleared on temporary detach, and reset * on cleanup. * @hide */ private RenderNode mBackgroundRenderNode; RenderNode mBackgroundRenderNode; @UnsupportedAppUsage private int mBackgroundResource; core/java/android/view/ViewRootImpl.java +26 −10 Original line number Diff line number Diff line Loading @@ -7297,26 +7297,42 @@ public final class ViewRootImpl implements ViewParent, } } public void dumpGfxInfo(int[] info) { info[0] = info[1] = 0; static final class GfxInfo { public int viewCount; public long renderNodeMemoryUsage; public long renderNodeMemoryAllocated; void add(GfxInfo other) { viewCount += other.viewCount; renderNodeMemoryUsage += other.renderNodeMemoryUsage; renderNodeMemoryAllocated += other.renderNodeMemoryAllocated; } } GfxInfo getGfxInfo() { GfxInfo info = new GfxInfo(); if (mView != null) { getGfxInfo(mView, info); appendGfxInfo(mView, info); } return info; } private static void getGfxInfo(View view, int[] info) { RenderNode renderNode = view.mRenderNode; info[0]++; if (renderNode != null) { info[1] += (int) renderNode.computeApproximateMemoryUsage(); private static void computeRenderNodeUsage(RenderNode node, GfxInfo info) { if (node == null) return; info.renderNodeMemoryUsage += node.computeApproximateMemoryUsage(); info.renderNodeMemoryAllocated += node.computeApproximateMemoryAllocated(); } private static void appendGfxInfo(View view, GfxInfo info) { info.viewCount++; computeRenderNodeUsage(view.mRenderNode, info); computeRenderNodeUsage(view.mBackgroundRenderNode, info); if (view instanceof ViewGroup) { ViewGroup group = (ViewGroup) view; int count = group.getChildCount(); for (int i = 0; i < count; i++) { getGfxInfo(group.getChildAt(i), info); appendGfxInfo(group.getChildAt(i), info); } } } Loading core/java/android/view/WindowManagerGlobal.java +10 −12 Original line number Diff line number Diff line Loading @@ -604,26 +604,24 @@ public final class WindowManagerGlobal { pw.println("\nView hierarchy:\n"); int viewsCount = 0; int displayListsSize = 0; int[] info = new int[2]; ViewRootImpl.GfxInfo totals = new ViewRootImpl.GfxInfo(); for (int i = 0; i < count; i++) { ViewRootImpl root = mRoots.get(i); root.dumpGfxInfo(info); ViewRootImpl.GfxInfo info = root.getGfxInfo(); totals.add(info); String name = getWindowName(root); pw.printf(" %s\n %d views, %.2f kB of display lists", name, info[0], info[1] / 1024.0f); pw.printf(" %s\n %d views, %.2f kB of render nodes", name, info.viewCount, info.renderNodeMemoryUsage / 1024.f); pw.printf("\n\n"); viewsCount += info[0]; displayListsSize += info[1]; } pw.printf("\nTotal ViewRootImpl: %d\n", count); pw.printf("Total Views: %d\n", viewsCount); pw.printf("Total DisplayList: %.2f kB\n\n", displayListsSize / 1024.0f); pw.printf("\nTotal %-15s: %d\n", "ViewRootImpl", count); pw.printf("Total %-15s: %d\n", "attached Views", totals.viewCount); pw.printf("Total %-15s: %.2f kB (used) / %.2f kB (capacity)\n\n", "RenderNode", totals.renderNodeMemoryUsage / 1024.0f, totals.renderNodeMemoryAllocated / 1024.0f); } } finally { pw.flush(); Loading core/jni/android_view_RenderNode.cpp +9 −3 Original line number Diff line number Diff line Loading @@ -52,9 +52,14 @@ static void android_view_RenderNode_output(JNIEnv* env, jobject clazz, jlong ren renderNode->output(); } static jint android_view_RenderNode_getDebugSize(JNIEnv* env, jobject clazz, jlong renderNodePtr) { static jint android_view_RenderNode_getUsageSize(JNIEnv* env, jobject clazz, jlong renderNodePtr) { RenderNode* renderNode = reinterpret_cast<RenderNode*>(renderNodePtr); return renderNode->getDebugSize(); return renderNode->getUsageSize(); } static jint android_view_RenderNode_getAllocatedSize(JNIEnv* env, jobject clazz, jlong renderNodePtr) { RenderNode* renderNode = reinterpret_cast<RenderNode*>(renderNodePtr); return renderNode->getAllocatedSize(); } static jlong android_view_RenderNode_create(JNIEnv* env, jobject, jstring name) { Loading Loading @@ -647,7 +652,8 @@ static const JNINativeMethod gMethods[] = { { "nCreate", "(Ljava/lang/String;)J", (void*) android_view_RenderNode_create }, { "nGetNativeFinalizer", "()J", (void*) android_view_RenderNode_getNativeFinalizer }, { "nOutput", "(J)V", (void*) android_view_RenderNode_output }, { "nGetDebugSize", "(J)I", (void*) android_view_RenderNode_getDebugSize }, { "nGetUsageSize", "(J)I", (void*) android_view_RenderNode_getUsageSize }, { "nGetAllocatedSize", "(J)I", (void*) android_view_RenderNode_getAllocatedSize }, { "nAddAnimator", "(JJ)V", (void*) android_view_RenderNode_addAnimator }, { "nEndAllAnimators", "(J)V", (void*) android_view_RenderNode_endAllAnimators }, { "nRequestPositionUpdates", "(JLandroid/graphics/RenderNode$PositionUpdateListener;)V", (void*) android_view_RenderNode_requestPositionUpdates }, Loading graphics/java/android/graphics/RenderNode.java +18 −2 Original line number Diff line number Diff line Loading @@ -1380,7 +1380,22 @@ public final class RenderNode { * @return Approximate memory usage in bytes. */ public @BytesLong long computeApproximateMemoryUsage() { return nGetDebugSize(mNativeRenderNode); return nGetUsageSize(mNativeRenderNode); } /** * Gets the approximate amount of memory allocated for the RenderNode for debug purposes. * Does not include the memory allocated by any child RenderNodes nor any bitmaps, only the * memory allocated for this RenderNode and any data it owns. * * The difference between this and {@link #computeApproximateMemoryUsage()} is this includes * memory allocated but not used. In particular structures such as DisplayLists are similar * to things like ArrayLists - they need to resize as commands are added to them. As such, * memory used can be less than memory allocated. * * @hide */ public @BytesLong long computeApproximateMemoryAllocated() { return nGetAllocatedSize(mNativeRenderNode); } /** Loading Loading @@ -1485,7 +1500,8 @@ public final class RenderNode { private static native void nOutput(long renderNode); private static native int nGetDebugSize(long renderNode); private static native int nGetUsageSize(long renderNode); private static native int nGetAllocatedSize(long renderNode); private static native void nRequestPositionUpdates(long renderNode, PositionUpdateListener callback); Loading Loading
core/java/android/view/View.java +2 −1 Original line number Diff line number Diff line Loading @@ -4496,8 +4496,9 @@ public class View implements Drawable.Callback, KeyEvent.Callback, * When non-null and valid, this is expected to contain an up-to-date copy * of the background drawable. It is cleared on temporary detach, and reset * on cleanup. * @hide */ private RenderNode mBackgroundRenderNode; RenderNode mBackgroundRenderNode; @UnsupportedAppUsage private int mBackgroundResource;
core/java/android/view/ViewRootImpl.java +26 −10 Original line number Diff line number Diff line Loading @@ -7297,26 +7297,42 @@ public final class ViewRootImpl implements ViewParent, } } public void dumpGfxInfo(int[] info) { info[0] = info[1] = 0; static final class GfxInfo { public int viewCount; public long renderNodeMemoryUsage; public long renderNodeMemoryAllocated; void add(GfxInfo other) { viewCount += other.viewCount; renderNodeMemoryUsage += other.renderNodeMemoryUsage; renderNodeMemoryAllocated += other.renderNodeMemoryAllocated; } } GfxInfo getGfxInfo() { GfxInfo info = new GfxInfo(); if (mView != null) { getGfxInfo(mView, info); appendGfxInfo(mView, info); } return info; } private static void getGfxInfo(View view, int[] info) { RenderNode renderNode = view.mRenderNode; info[0]++; if (renderNode != null) { info[1] += (int) renderNode.computeApproximateMemoryUsage(); private static void computeRenderNodeUsage(RenderNode node, GfxInfo info) { if (node == null) return; info.renderNodeMemoryUsage += node.computeApproximateMemoryUsage(); info.renderNodeMemoryAllocated += node.computeApproximateMemoryAllocated(); } private static void appendGfxInfo(View view, GfxInfo info) { info.viewCount++; computeRenderNodeUsage(view.mRenderNode, info); computeRenderNodeUsage(view.mBackgroundRenderNode, info); if (view instanceof ViewGroup) { ViewGroup group = (ViewGroup) view; int count = group.getChildCount(); for (int i = 0; i < count; i++) { getGfxInfo(group.getChildAt(i), info); appendGfxInfo(group.getChildAt(i), info); } } } Loading
core/java/android/view/WindowManagerGlobal.java +10 −12 Original line number Diff line number Diff line Loading @@ -604,26 +604,24 @@ public final class WindowManagerGlobal { pw.println("\nView hierarchy:\n"); int viewsCount = 0; int displayListsSize = 0; int[] info = new int[2]; ViewRootImpl.GfxInfo totals = new ViewRootImpl.GfxInfo(); for (int i = 0; i < count; i++) { ViewRootImpl root = mRoots.get(i); root.dumpGfxInfo(info); ViewRootImpl.GfxInfo info = root.getGfxInfo(); totals.add(info); String name = getWindowName(root); pw.printf(" %s\n %d views, %.2f kB of display lists", name, info[0], info[1] / 1024.0f); pw.printf(" %s\n %d views, %.2f kB of render nodes", name, info.viewCount, info.renderNodeMemoryUsage / 1024.f); pw.printf("\n\n"); viewsCount += info[0]; displayListsSize += info[1]; } pw.printf("\nTotal ViewRootImpl: %d\n", count); pw.printf("Total Views: %d\n", viewsCount); pw.printf("Total DisplayList: %.2f kB\n\n", displayListsSize / 1024.0f); pw.printf("\nTotal %-15s: %d\n", "ViewRootImpl", count); pw.printf("Total %-15s: %d\n", "attached Views", totals.viewCount); pw.printf("Total %-15s: %.2f kB (used) / %.2f kB (capacity)\n\n", "RenderNode", totals.renderNodeMemoryUsage / 1024.0f, totals.renderNodeMemoryAllocated / 1024.0f); } } finally { pw.flush(); Loading
core/jni/android_view_RenderNode.cpp +9 −3 Original line number Diff line number Diff line Loading @@ -52,9 +52,14 @@ static void android_view_RenderNode_output(JNIEnv* env, jobject clazz, jlong ren renderNode->output(); } static jint android_view_RenderNode_getDebugSize(JNIEnv* env, jobject clazz, jlong renderNodePtr) { static jint android_view_RenderNode_getUsageSize(JNIEnv* env, jobject clazz, jlong renderNodePtr) { RenderNode* renderNode = reinterpret_cast<RenderNode*>(renderNodePtr); return renderNode->getDebugSize(); return renderNode->getUsageSize(); } static jint android_view_RenderNode_getAllocatedSize(JNIEnv* env, jobject clazz, jlong renderNodePtr) { RenderNode* renderNode = reinterpret_cast<RenderNode*>(renderNodePtr); return renderNode->getAllocatedSize(); } static jlong android_view_RenderNode_create(JNIEnv* env, jobject, jstring name) { Loading Loading @@ -647,7 +652,8 @@ static const JNINativeMethod gMethods[] = { { "nCreate", "(Ljava/lang/String;)J", (void*) android_view_RenderNode_create }, { "nGetNativeFinalizer", "()J", (void*) android_view_RenderNode_getNativeFinalizer }, { "nOutput", "(J)V", (void*) android_view_RenderNode_output }, { "nGetDebugSize", "(J)I", (void*) android_view_RenderNode_getDebugSize }, { "nGetUsageSize", "(J)I", (void*) android_view_RenderNode_getUsageSize }, { "nGetAllocatedSize", "(J)I", (void*) android_view_RenderNode_getAllocatedSize }, { "nAddAnimator", "(JJ)V", (void*) android_view_RenderNode_addAnimator }, { "nEndAllAnimators", "(J)V", (void*) android_view_RenderNode_endAllAnimators }, { "nRequestPositionUpdates", "(JLandroid/graphics/RenderNode$PositionUpdateListener;)V", (void*) android_view_RenderNode_requestPositionUpdates }, Loading
graphics/java/android/graphics/RenderNode.java +18 −2 Original line number Diff line number Diff line Loading @@ -1380,7 +1380,22 @@ public final class RenderNode { * @return Approximate memory usage in bytes. */ public @BytesLong long computeApproximateMemoryUsage() { return nGetDebugSize(mNativeRenderNode); return nGetUsageSize(mNativeRenderNode); } /** * Gets the approximate amount of memory allocated for the RenderNode for debug purposes. * Does not include the memory allocated by any child RenderNodes nor any bitmaps, only the * memory allocated for this RenderNode and any data it owns. * * The difference between this and {@link #computeApproximateMemoryUsage()} is this includes * memory allocated but not used. In particular structures such as DisplayLists are similar * to things like ArrayLists - they need to resize as commands are added to them. As such, * memory used can be less than memory allocated. * * @hide */ public @BytesLong long computeApproximateMemoryAllocated() { return nGetAllocatedSize(mNativeRenderNode); } /** Loading Loading @@ -1485,7 +1500,8 @@ public final class RenderNode { private static native void nOutput(long renderNode); private static native int nGetDebugSize(long renderNode); private static native int nGetUsageSize(long renderNode); private static native int nGetAllocatedSize(long renderNode); private static native void nRequestPositionUpdates(long renderNode, PositionUpdateListener callback); Loading