Support dump gfxinfo reset for process' without a Window
Bug: 199791928
Test: manual
Change-Id: I995d236c2c9d60194f72275a3da1c82340f77898
diff --git a/libs/hwui/Android.bp b/libs/hwui/Android.bp
index b931d03..fea1e15 100644
--- a/libs/hwui/Android.bp
+++ b/libs/hwui/Android.bp
@@ -272,7 +272,6 @@
"apex/android_bitmap.cpp",
"apex/android_canvas.cpp",
"apex/jni_runtime.cpp",
- "apex/renderthread.cpp",
],
},
host: {
diff --git a/libs/hwui/apex/include/android/graphics/renderthread.h b/libs/hwui/apex/include/android/graphics/renderthread.h
deleted file mode 100644
index 50280a6..0000000
--- a/libs/hwui/apex/include/android/graphics/renderthread.h
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
- * Copyright (C) 2019 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-#ifndef ANDROID_GRAPHICS_RENDERTHREAD_H
-#define ANDROID_GRAPHICS_RENDERTHREAD_H
-
-#include <cutils/compiler.h>
-#include <sys/cdefs.h>
-
-__BEGIN_DECLS
-
-/**
- * Dumps a textual representation of the graphics stats for this process.
- * @param fd The file descriptor that the available graphics stats will be appended to. The
- * function requires a valid fd, but does not persist or assume ownership of the fd
- * outside the scope of this function.
- */
-ANDROID_API void ARenderThread_dumpGraphicsMemory(int fd);
-
-__END_DECLS
-
-#endif // ANDROID_GRAPHICS_RENDERTHREAD_H
diff --git a/libs/hwui/apex/renderthread.cpp b/libs/hwui/apex/renderthread.cpp
deleted file mode 100644
index 5d26afe..0000000
--- a/libs/hwui/apex/renderthread.cpp
+++ /dev/null
@@ -1,25 +0,0 @@
-/*
- * Copyright (C) 2019 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include "android/graphics/renderthread.h"
-
-#include <renderthread/RenderProxy.h>
-
-using namespace android;
-
-void ARenderThread_dumpGraphicsMemory(int fd) {
- uirenderer::renderthread::RenderProxy::dumpGraphicsMemory(fd);
-}
diff --git a/libs/hwui/jni/android_graphics_HardwareRenderer.cpp b/libs/hwui/jni/android_graphics_HardwareRenderer.cpp
index e536950..bd93a4f 100644
--- a/libs/hwui/jni/android_graphics_HardwareRenderer.cpp
+++ b/libs/hwui/jni/android_graphics_HardwareRenderer.cpp
@@ -379,6 +379,13 @@
proxy->dumpProfileInfo(fd, dumpFlags);
}
+static void android_view_ThreadedRenderer_dumpGlobalProfileInfo(JNIEnv* env, jobject clazz,
+ jobject javaFileDescriptor,
+ jint dumpFlags) {
+ int fd = jniGetFDFromFileDescriptor(env, javaFileDescriptor);
+ RenderProxy::dumpGraphicsMemory(fd, true, dumpFlags & DumpFlags::Reset);
+}
+
static void android_view_ThreadedRenderer_addRenderNode(JNIEnv* env, jobject clazz,
jlong proxyPtr, jlong renderNodePtr, jboolean placeFront) {
RenderProxy* proxy = reinterpret_cast<RenderProxy*>(proxyPtr);
@@ -910,6 +917,8 @@
{"nNotifyFramePending", "(J)V", (void*)android_view_ThreadedRenderer_notifyFramePending},
{"nDumpProfileInfo", "(JLjava/io/FileDescriptor;I)V",
(void*)android_view_ThreadedRenderer_dumpProfileInfo},
+ {"nDumpGlobalProfileInfo", "(Ljava/io/FileDescriptor;I)V",
+ (void*)android_view_ThreadedRenderer_dumpGlobalProfileInfo},
{"setupShadersDiskCache", "(Ljava/lang/String;Ljava/lang/String;)V",
(void*)android_view_ThreadedRenderer_setupShadersDiskCache},
{"nAddRenderNode", "(JJZ)V", (void*)android_view_ThreadedRenderer_addRenderNode},
diff --git a/libs/hwui/libhwui.map.txt b/libs/hwui/libhwui.map.txt
index 77b8a44..087c006 100644
--- a/libs/hwui/libhwui.map.txt
+++ b/libs/hwui/libhwui.map.txt
@@ -1,4 +1,4 @@
-LIBHWUI {
+LIBHWUI { # platform-only /* HWUI isn't current a module, so all of these are still platform-only */
global:
/* listing of all C APIs to be exposed by libhwui to consumers outside of the module */
ABitmap_getInfoFromJava;
@@ -39,7 +39,6 @@
ARegionIterator_next;
ARegionIterator_getRect;
ARegionIterator_getTotalBounds;
- ARenderThread_dumpGraphicsMemory;
local:
*;
};
diff --git a/libs/hwui/renderthread/RenderProxy.cpp b/libs/hwui/renderthread/RenderProxy.cpp
index 72d4ac5..430c4d3 100644
--- a/libs/hwui/renderthread/RenderProxy.cpp
+++ b/libs/hwui/renderthread/RenderProxy.cpp
@@ -257,10 +257,15 @@
});
}
-void RenderProxy::dumpGraphicsMemory(int fd, bool includeProfileData) {
+void RenderProxy::dumpGraphicsMemory(int fd, bool includeProfileData, bool resetProfile) {
if (RenderThread::hasInstance()) {
auto& thread = RenderThread::getInstance();
- thread.queue().runSync([&]() { thread.dumpGraphicsMemory(fd, includeProfileData); });
+ thread.queue().runSync([&]() {
+ thread.dumpGraphicsMemory(fd, includeProfileData);
+ if (resetProfile) {
+ thread.globalProfileData()->reset();
+ }
+ });
}
}
diff --git a/libs/hwui/renderthread/RenderProxy.h b/libs/hwui/renderthread/RenderProxy.h
index 6417b38..6d46be4 100644
--- a/libs/hwui/renderthread/RenderProxy.h
+++ b/libs/hwui/renderthread/RenderProxy.h
@@ -108,7 +108,8 @@
// Not exported, only used for testing
void resetProfileInfo();
uint32_t frameTimePercentile(int p);
- static void dumpGraphicsMemory(int fd, bool includeProfileData = true);
+ static void dumpGraphicsMemory(int fd, bool includeProfileData = true,
+ bool resetProfile = false);
static void getMemoryUsage(size_t* cpuUsage, size_t* gpuUsage);
static void rotateProcessStatsBuffer();