Tim Murray | 12f511e | 2018-10-22 15:26:08 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2018 The Android Open Source Project |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | |
| 17 | #include "jni.h" |
| 18 | #include "GraphicsJNI.h" |
| 19 | #include <nativehelper/JNIHelp.h> |
| 20 | |
| 21 | #include <minikin/Layout.h> |
| 22 | #include <renderthread/RenderProxy.h> |
| 23 | |
| 24 | #include "core_jni_helpers.h" |
| 25 | #include <unistd.h> |
| 26 | |
| 27 | namespace android { |
| 28 | |
| 29 | static void android_app_ActivityThread_purgePendingResources(JNIEnv* env, jobject clazz) { |
| 30 | // Don't care about return values. |
| 31 | mallopt(M_PURGE, 0); |
| 32 | } |
| 33 | |
| 34 | static void |
| 35 | android_app_ActivityThread_dumpGraphics(JNIEnv* env, jobject clazz, jobject javaFileDescriptor) { |
| 36 | int fd = jniGetFDFromFileDescriptor(env, javaFileDescriptor); |
| 37 | android::uirenderer::renderthread::RenderProxy::dumpGraphicsMemory(fd); |
| 38 | minikin::Layout::dumpMinikinStats(fd); |
| 39 | } |
| 40 | |
| 41 | |
| 42 | static JNINativeMethod gActivityThreadMethods[] = { |
| 43 | // ------------ Regular JNI ------------------ |
| 44 | { "nPurgePendingResources", "()V", |
| 45 | (void*) android_app_ActivityThread_purgePendingResources }, |
| 46 | { "nDumpGraphicsInfo", "(Ljava/io/FileDescriptor;)V", |
| 47 | (void*) android_app_ActivityThread_dumpGraphics } |
| 48 | }; |
| 49 | |
| 50 | int register_android_app_ActivityThread(JNIEnv* env) { |
| 51 | return RegisterMethodsOrDie(env, "android/app/ActivityThread", |
| 52 | gActivityThreadMethods, NELEM(gActivityThreadMethods)); |
| 53 | } |
| 54 | |
| 55 | }; |