Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 // This file is of the same format as file that generated by | |
| 6 // base/android/jni_generator/jni_generator.py | |
| 7 // For | |
| 8 // com/google/vr/cardboard/DisplaySynchronizer | |
| 9 | |
| 10 // Local modification includes: | |
| 11 // 1. Remove all implementaiton, only keep definition. | |
|
agrieve
2016/11/10 19:16:29
I think it would be better to add a flag to the jn
bshe
2016/11/10 20:59:25
Do you see it as a blocking issue for this CL? Wou
agrieve
2016/11/10 21:47:04
That's fine. Please file a bug for a follow-up.
bshe
2016/11/11 17:43:02
crbug.com/664306 is created.
| |
| 12 // 2. Use absolute path instead of relative path. | |
| 13 // 3. Removed all helper functions such as: Create. | |
| 14 // 4. Added function RegisterDisplaySynchronizerNatives at the end of this file. | |
| 15 | |
| 16 #ifndef com_google_vr_cardboard_DisplaySynchronizer_JNI | |
| 17 #define com_google_vr_cardboard_DisplaySynchronizer_JNI | |
| 18 | |
| 19 #include "base/android/jni_android.h" | |
| 20 // ---------------------------------------------------------------------------- | |
| 21 // Native JNI methods | |
| 22 // ---------------------------------------------------------------------------- | |
| 23 #include <jni.h> | |
| 24 | |
| 25 #include "base/android/jni_generator/jni_generator_helper.h" | |
| 26 | |
| 27 #include "base/android/jni_int_wrapper.h" | |
| 28 | |
| 29 // Step 1: forward declarations. | |
| 30 namespace { | |
| 31 | |
| 32 const char kDisplaySynchronizerClassPath[] = | |
| 33 "com/google/vr/cardboard/DisplaySynchronizer"; | |
| 34 // Leaking this jclass as we cannot use LazyInstance from some threads. | |
| 35 base::subtle::AtomicWord g_DisplaySynchronizer_clazz __attribute__((unused)) = | |
| 36 0; | |
| 37 #define DisplaySynchronizer_clazz(env) \ | |
| 38 base::android::LazyGetClass(env, kDisplaySynchronizerClassPath, \ | |
| 39 &g_DisplaySynchronizer_clazz) | |
| 40 | |
| 41 } // namespace | |
| 42 | |
| 43 namespace DisplaySynchronizer { | |
| 44 | |
| 45 extern "C" __attribute__((visibility("default"))) jlong | |
| 46 Java_com_google_vr_cardboard_DisplaySynchronizer_nativeCreate( | |
| 47 JNIEnv* env, | |
| 48 jobject jcaller, | |
| 49 jclass classLoader, | |
| 50 jobject appContext); | |
| 51 | |
| 52 // Step 2: method stubs. | |
| 53 extern "C" __attribute__((visibility("default"))) void | |
| 54 Java_com_google_vr_cardboard_DisplaySynchronizer_nativeDestroy( | |
| 55 JNIEnv* env, | |
| 56 jobject jcaller, | |
| 57 jlong nativeDisplaySynchronizer); | |
| 58 | |
| 59 extern "C" __attribute__((visibility("default"))) void | |
| 60 Java_com_google_vr_cardboard_DisplaySynchronizer_nativeReset( | |
| 61 JNIEnv* env, | |
| 62 jobject jcaller, | |
| 63 jlong nativeDisplaySynchronizer, | |
| 64 jlong expectedInterval, | |
| 65 jlong vsyncOffset); | |
| 66 | |
| 67 extern "C" __attribute__((visibility("default"))) void | |
| 68 Java_com_google_vr_cardboard_DisplaySynchronizer_nativeUpdate( | |
| 69 JNIEnv* env, | |
| 70 jobject jcaller, | |
| 71 jlong nativeDisplaySynchronizer, | |
| 72 jlong syncTime, | |
| 73 jint currentRotation); | |
| 74 | |
| 75 // Step 3: RegisterNatives. | |
| 76 | |
| 77 static const JNINativeMethod kMethodsDisplaySynchronizer[] = { | |
| 78 {"nativeCreate", | |
| 79 "(" | |
| 80 "Ljava/lang/ClassLoader;" | |
| 81 "Landroid/content/Context;" | |
| 82 ")" | |
| 83 "J", | |
| 84 reinterpret_cast<void*>( | |
| 85 Java_com_google_vr_cardboard_DisplaySynchronizer_nativeCreate)}, | |
| 86 {"nativeDestroy", | |
| 87 "(" | |
| 88 "J" | |
| 89 ")" | |
| 90 "V", | |
| 91 reinterpret_cast<void*>( | |
| 92 Java_com_google_vr_cardboard_DisplaySynchronizer_nativeDestroy)}, | |
| 93 {"nativeReset", | |
| 94 "(" | |
| 95 "J" | |
| 96 "J" | |
| 97 "J" | |
| 98 ")" | |
| 99 "V", | |
| 100 reinterpret_cast<void*>( | |
| 101 Java_com_google_vr_cardboard_DisplaySynchronizer_nativeReset)}, | |
| 102 {"nativeUpdate", | |
| 103 "(" | |
| 104 "J" | |
| 105 "J" | |
| 106 "I" | |
| 107 ")" | |
| 108 "V", | |
| 109 reinterpret_cast<void*>( | |
| 110 Java_com_google_vr_cardboard_DisplaySynchronizer_nativeUpdate)}, | |
| 111 }; | |
| 112 | |
| 113 static bool RegisterNativesImpl(JNIEnv* env) { | |
| 114 if (base::android::IsManualJniRegistrationDisabled()) | |
| 115 return true; | |
| 116 | |
| 117 const int kMethodsDisplaySynchronizerSize = | |
| 118 arraysize(kMethodsDisplaySynchronizer); | |
| 119 | |
| 120 if (env->RegisterNatives(DisplaySynchronizer_clazz(env), | |
| 121 kMethodsDisplaySynchronizer, | |
| 122 kMethodsDisplaySynchronizerSize) < 0) { | |
| 123 jni_generator::HandleRegistrationError(env, DisplaySynchronizer_clazz(env), | |
| 124 __FILE__); | |
| 125 return false; | |
| 126 } | |
| 127 | |
| 128 return true; | |
| 129 } | |
| 130 | |
| 131 bool RegisterDisplaySynchronizerNatives(JNIEnv* env) { | |
|
agrieve
2016/11/10 19:16:30
As a non-static function, this shouldn't be in a .
bshe
2016/11/10 20:59:25
Changed it to static. It is simply a wrapper.
| |
| 132 return RegisterNativesImpl(env); | |
| 133 } | |
| 134 | |
| 135 } // namespace DisplaySynchronizer | |
| 136 | |
| 137 #endif // com_google_vr_cardboard_DisplaySynchronizer_JNI | |
| OLD | NEW |