Chromium Code Reviews| Index: third_party/gvr-android-sdk/display_synchronizer_jni.h |
| diff --git a/third_party/gvr-android-sdk/display_synchronizer_jni.h b/third_party/gvr-android-sdk/display_synchronizer_jni.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..33dcae2670dad6e0254e41c45107c24c9c0616fd |
| --- /dev/null |
| +++ b/third_party/gvr-android-sdk/display_synchronizer_jni.h |
| @@ -0,0 +1,137 @@ |
| +// Copyright 2014 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +// This file is of the same format as file that generated by |
| +// base/android/jni_generator/jni_generator.py |
| +// For |
| +// com/google/vr/cardboard/DisplaySynchronizer |
| + |
| +// Local modification includes: |
| +// 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.
|
| +// 2. Use absolute path instead of relative path. |
| +// 3. Removed all helper functions such as: Create. |
| +// 4. Added function RegisterDisplaySynchronizerNatives at the end of this file. |
| + |
| +#ifndef com_google_vr_cardboard_DisplaySynchronizer_JNI |
| +#define com_google_vr_cardboard_DisplaySynchronizer_JNI |
| + |
| +#include "base/android/jni_android.h" |
| +// ---------------------------------------------------------------------------- |
| +// Native JNI methods |
| +// ---------------------------------------------------------------------------- |
| +#include <jni.h> |
| + |
| +#include "base/android/jni_generator/jni_generator_helper.h" |
| + |
| +#include "base/android/jni_int_wrapper.h" |
| + |
| +// Step 1: forward declarations. |
| +namespace { |
| + |
| +const char kDisplaySynchronizerClassPath[] = |
| + "com/google/vr/cardboard/DisplaySynchronizer"; |
| +// Leaking this jclass as we cannot use LazyInstance from some threads. |
| +base::subtle::AtomicWord g_DisplaySynchronizer_clazz __attribute__((unused)) = |
| + 0; |
| +#define DisplaySynchronizer_clazz(env) \ |
| + base::android::LazyGetClass(env, kDisplaySynchronizerClassPath, \ |
| + &g_DisplaySynchronizer_clazz) |
| + |
| +} // namespace |
| + |
| +namespace DisplaySynchronizer { |
| + |
| +extern "C" __attribute__((visibility("default"))) jlong |
| +Java_com_google_vr_cardboard_DisplaySynchronizer_nativeCreate( |
| + JNIEnv* env, |
| + jobject jcaller, |
| + jclass classLoader, |
| + jobject appContext); |
| + |
| +// Step 2: method stubs. |
| +extern "C" __attribute__((visibility("default"))) void |
| +Java_com_google_vr_cardboard_DisplaySynchronizer_nativeDestroy( |
| + JNIEnv* env, |
| + jobject jcaller, |
| + jlong nativeDisplaySynchronizer); |
| + |
| +extern "C" __attribute__((visibility("default"))) void |
| +Java_com_google_vr_cardboard_DisplaySynchronizer_nativeReset( |
| + JNIEnv* env, |
| + jobject jcaller, |
| + jlong nativeDisplaySynchronizer, |
| + jlong expectedInterval, |
| + jlong vsyncOffset); |
| + |
| +extern "C" __attribute__((visibility("default"))) void |
| +Java_com_google_vr_cardboard_DisplaySynchronizer_nativeUpdate( |
| + JNIEnv* env, |
| + jobject jcaller, |
| + jlong nativeDisplaySynchronizer, |
| + jlong syncTime, |
| + jint currentRotation); |
| + |
| +// Step 3: RegisterNatives. |
| + |
| +static const JNINativeMethod kMethodsDisplaySynchronizer[] = { |
| + {"nativeCreate", |
| + "(" |
| + "Ljava/lang/ClassLoader;" |
| + "Landroid/content/Context;" |
| + ")" |
| + "J", |
| + reinterpret_cast<void*>( |
| + Java_com_google_vr_cardboard_DisplaySynchronizer_nativeCreate)}, |
| + {"nativeDestroy", |
| + "(" |
| + "J" |
| + ")" |
| + "V", |
| + reinterpret_cast<void*>( |
| + Java_com_google_vr_cardboard_DisplaySynchronizer_nativeDestroy)}, |
| + {"nativeReset", |
| + "(" |
| + "J" |
| + "J" |
| + "J" |
| + ")" |
| + "V", |
| + reinterpret_cast<void*>( |
| + Java_com_google_vr_cardboard_DisplaySynchronizer_nativeReset)}, |
| + {"nativeUpdate", |
| + "(" |
| + "J" |
| + "J" |
| + "I" |
| + ")" |
| + "V", |
| + reinterpret_cast<void*>( |
| + Java_com_google_vr_cardboard_DisplaySynchronizer_nativeUpdate)}, |
| +}; |
| + |
| +static bool RegisterNativesImpl(JNIEnv* env) { |
| + if (base::android::IsManualJniRegistrationDisabled()) |
| + return true; |
| + |
| + const int kMethodsDisplaySynchronizerSize = |
| + arraysize(kMethodsDisplaySynchronizer); |
| + |
| + if (env->RegisterNatives(DisplaySynchronizer_clazz(env), |
| + kMethodsDisplaySynchronizer, |
| + kMethodsDisplaySynchronizerSize) < 0) { |
| + jni_generator::HandleRegistrationError(env, DisplaySynchronizer_clazz(env), |
| + __FILE__); |
| + return false; |
| + } |
| + |
| + return true; |
| +} |
| + |
| +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.
|
| + return RegisterNativesImpl(env); |
| +} |
| + |
| +} // namespace DisplaySynchronizer |
| + |
| +#endif // com_google_vr_cardboard_DisplaySynchronizer_JNI |