summaryrefslogtreecommitdiff
path: root/core
diff options
context:
space:
mode:
authorAndreas Gampe <agampe@google.com>2017-02-20 16:18:24 -0800
committerAndreas Gampe <agampe@google.com>2017-02-20 16:18:24 -0800
commita7993241a96ff8832bac5fbc052d8a9ac6e72877 (patch)
treed0d7c7970a73d29272ea5e7f4525d997d1e7231e /core
parent88c0facc1e3bd88ddbf4cbb72b0bfa7a2db7c5fb (diff)
Graphics: Make SurfaceTexture compile-time initializable
Ensure that all static initializer code can be executed in the compiler. Move native field caching into the native method registration function. Bug: 34956610 Test: m Test: Device boots (Pixel) Change-Id: Icf68c8fbadcaaa133a152942a3a7ba7aba84a1df
Diffstat (limited to 'core')
-rw-r--r--core/jni/android/graphics/SurfaceTexture.cpp6
1 files changed, 5 insertions, 1 deletions
diff --git a/core/jni/android/graphics/SurfaceTexture.cpp b/core/jni/android/graphics/SurfaceTexture.cpp
index 00996730cb70..2b1da25c632d 100644
--- a/core/jni/android/graphics/SurfaceTexture.cpp
+++ b/core/jni/android/graphics/SurfaceTexture.cpp
@@ -34,6 +34,7 @@
#include "jni.h"
#include "JNIHelp.h"
+#include "ScopedLocalRef.h"
// ----------------------------------------------------------------------------
@@ -385,7 +386,6 @@ static jboolean SurfaceTexture_isReleased(JNIEnv* env, jobject thiz)
// ----------------------------------------------------------------------------
static const JNINativeMethod gSurfaceTextureMethods[] = {
- {"nativeClassInit", "()V", (void*)SurfaceTexture_classInit },
{"nativeInit", "(ZIZLjava/lang/ref/WeakReference;)V", (void*)SurfaceTexture_init },
{"nativeFinalize", "()V", (void*)SurfaceTexture_finalize },
{"nativeSetDefaultBufferSize", "(II)V", (void*)SurfaceTexture_setDefaultBufferSize },
@@ -401,6 +401,10 @@ static const JNINativeMethod gSurfaceTextureMethods[] = {
int register_android_graphics_SurfaceTexture(JNIEnv* env)
{
+ // Cache some fields.
+ ScopedLocalRef<jclass> klass(env, FindClassOrDie(env, kSurfaceTextureClassPathName));
+ SurfaceTexture_classInit(env, klass.get());
+
return RegisterMethodsOrDie(env, kSurfaceTextureClassPathName, gSurfaceTextureMethods,
NELEM(gSurfaceTextureMethods));
}