Add coffeecatch
This commit is contained in:
1215
android/cpp/coffeecatch.c
Normal file
1215
android/cpp/coffeecatch.c
Normal file
File diff suppressed because it is too large
Load Diff
1338
android/cpp/coffeecatch.c.orig
Normal file
1338
android/cpp/coffeecatch.c.orig
Normal file
File diff suppressed because it is too large
Load Diff
216
android/cpp/coffeecatch_r10c.diff
Normal file
216
android/cpp/coffeecatch_r10c.diff
Normal file
@@ -0,0 +1,216 @@
|
||||
diff --git a/coffeecatch.c b/coffeecatch.c
|
||||
index 448fe0f..f39fcdb 100644
|
||||
--- a/coffeecatch.c
|
||||
+++ b/coffeecatch.c
|
||||
@@ -43,10 +43,7 @@
|
||||
#include <assert.h>
|
||||
#include <signal.h>
|
||||
#include <setjmp.h>
|
||||
-#if defined(__ANDROID__) && !defined(__BIONIC_HAVE_UCONTEXT_T) && \
|
||||
- defined(__arm__) && !defined(__BIONIC_HAVE_STRUCT_SIGCONTEXT)
|
||||
-#include <asm/sigcontext.h>
|
||||
-#endif
|
||||
+#include <sys/ucontext.h>
|
||||
#if (defined(USE_UNWIND) && !defined(USE_CORKSCREW))
|
||||
#include <unwind.h>
|
||||
#endif
|
||||
@@ -88,154 +85,34 @@ static const int native_sig_catch[SIG_CATCH_COUNT + 1]
|
||||
/* Maximum value of a caught signal. */
|
||||
#define SIG_NUMBER_MAX 32
|
||||
|
||||
-#if (defined(__ANDROID__) && (!defined(__BIONIC_HAVE_UCONTEXT_T)))
|
||||
-#ifndef ucontext_h_seen
|
||||
-#define ucontext_h_seen
|
||||
-
|
||||
-/* stack_t definition */
|
||||
-#include <asm/signal.h>
|
||||
-
|
||||
-#if defined(__arm__)
|
||||
-
|
||||
-/* Taken from richard.quirk's header file. (Android does not have it) */
|
||||
-
|
||||
-typedef struct ucontext {
|
||||
- unsigned long uc_flags;
|
||||
- struct ucontext *uc_link;
|
||||
- stack_t uc_stack;
|
||||
- struct sigcontext uc_mcontext;
|
||||
- unsigned long uc_sigmask;
|
||||
-} ucontext_t;
|
||||
-
|
||||
-#elif defined(__i386__)
|
||||
-
|
||||
-/* Taken from Google Breakpad. */
|
||||
-
|
||||
-/* 80-bit floating-point register */
|
||||
-struct _libc_fpreg {
|
||||
- unsigned short significand[4];
|
||||
- unsigned short exponent;
|
||||
-};
|
||||
-
|
||||
-/* Simple floating-point state, see FNSTENV instruction */
|
||||
-struct _libc_fpstate {
|
||||
- unsigned long cw;
|
||||
- unsigned long sw;
|
||||
- unsigned long tag;
|
||||
- unsigned long ipoff;
|
||||
- unsigned long cssel;
|
||||
- unsigned long dataoff;
|
||||
- unsigned long datasel;
|
||||
- struct _libc_fpreg _st[8];
|
||||
- unsigned long status;
|
||||
-};
|
||||
-
|
||||
-typedef uint32_t greg_t;
|
||||
-
|
||||
-typedef struct {
|
||||
- uint32_t gregs[19];
|
||||
- struct _libc_fpstate* fpregs;
|
||||
- uint32_t oldmask;
|
||||
- uint32_t cr2;
|
||||
-} mcontext_t;
|
||||
-
|
||||
-enum {
|
||||
- REG_GS = 0,
|
||||
- REG_FS,
|
||||
- REG_ES,
|
||||
- REG_DS,
|
||||
- REG_EDI,
|
||||
- REG_ESI,
|
||||
- REG_EBP,
|
||||
- REG_ESP,
|
||||
- REG_EBX,
|
||||
- REG_EDX,
|
||||
- REG_ECX,
|
||||
- REG_EAX,
|
||||
- REG_TRAPNO,
|
||||
- REG_ERR,
|
||||
- REG_EIP,
|
||||
- REG_CS,
|
||||
- REG_EFL,
|
||||
- REG_UESP,
|
||||
- REG_SS,
|
||||
-};
|
||||
-
|
||||
-typedef struct ucontext {
|
||||
- uint32_t uc_flags;
|
||||
- struct ucontext* uc_link;
|
||||
- stack_t uc_stack;
|
||||
- mcontext_t uc_mcontext;
|
||||
-} ucontext_t;
|
||||
-
|
||||
-#elif defined(__mips__)
|
||||
-
|
||||
-/* Taken from Google Breakpad. */
|
||||
-
|
||||
-typedef struct {
|
||||
- uint32_t regmask;
|
||||
- uint32_t status;
|
||||
- uint64_t pc;
|
||||
- uint64_t gregs[32];
|
||||
- uint64_t fpregs[32];
|
||||
- uint32_t acx;
|
||||
- uint32_t fpc_csr;
|
||||
- uint32_t fpc_eir;
|
||||
- uint32_t used_math;
|
||||
- uint32_t dsp;
|
||||
- uint64_t mdhi;
|
||||
- uint64_t mdlo;
|
||||
- uint32_t hi1;
|
||||
- uint32_t lo1;
|
||||
- uint32_t hi2;
|
||||
- uint32_t lo2;
|
||||
- uint32_t hi3;
|
||||
- uint32_t lo3;
|
||||
-} mcontext_t;
|
||||
-
|
||||
-typedef struct ucontext {
|
||||
- uint32_t uc_flags;
|
||||
- struct ucontext* uc_link;
|
||||
- stack_t uc_stack;
|
||||
- mcontext_t uc_mcontext;
|
||||
-} ucontext_t;
|
||||
-
|
||||
-#else
|
||||
-#error "Architecture is not supported (unknown ucontext layout)"
|
||||
-#endif
|
||||
-
|
||||
-#endif
|
||||
-
|
||||
#ifdef USE_CORKSCREW
|
||||
typedef struct map_info_t map_info_t;
|
||||
/* Extracted from Android's include/corkscrew/backtrace.h */
|
||||
-typedef struct {
|
||||
- uintptr_t absolute_pc;
|
||||
- uintptr_t stack_top;
|
||||
- size_t stack_size;
|
||||
-} backtrace_frame_t;
|
||||
-typedef struct {
|
||||
- uintptr_t relative_pc;
|
||||
- uintptr_t relative_symbol_addr;
|
||||
- char* map_name;
|
||||
- char* symbol_name;
|
||||
- char* demangled_name;
|
||||
+typedef struct {
|
||||
+ uintptr_t absolute_pc;
|
||||
+ uintptr_t stack_top;
|
||||
+ size_t stack_size;
|
||||
+} backtrace_frame_t;
|
||||
+typedef struct {
|
||||
+ uintptr_t relative_pc;
|
||||
+ uintptr_t relative_symbol_addr;
|
||||
+ char* map_name;
|
||||
+ char* symbol_name;
|
||||
+ char* demangled_name;
|
||||
} backtrace_symbol_t;
|
||||
/* Extracted from Android's libcorkscrew/arch-arm/backtrace-arm.c */
|
||||
-typedef ssize_t (*t_unwind_backtrace_signal_arch)
|
||||
-(siginfo_t* si, void* sc, const map_info_t* lst, backtrace_frame_t* bt,
|
||||
-size_t ignore_depth, size_t max_depth);
|
||||
-typedef map_info_t* (*t_acquire_my_map_info_list)();
|
||||
-typedef void (*t_release_my_map_info_list)(map_info_t* milist);
|
||||
-typedef void (*t_get_backtrace_symbols)(const backtrace_frame_t* backtrace,
|
||||
+typedef ssize_t (*t_unwind_backtrace_signal_arch)
|
||||
+(siginfo_t* si, void* sc, const map_info_t* lst, backtrace_frame_t* bt,
|
||||
+size_t ignore_depth, size_t max_depth);
|
||||
+typedef map_info_t* (*t_acquire_my_map_info_list)();
|
||||
+typedef void (*t_release_my_map_info_list)(map_info_t* milist);
|
||||
+typedef void (*t_get_backtrace_symbols)(const backtrace_frame_t* backtrace,
|
||||
size_t frames,
|
||||
backtrace_symbol_t* symbols);
|
||||
typedef void (*t_free_backtrace_symbols)(backtrace_symbol_t* symbols,
|
||||
size_t frames);
|
||||
#endif
|
||||
|
||||
-#endif
|
||||
-
|
||||
/* Process-wide crash handler structure. */
|
||||
typedef struct native_code_global_struct {
|
||||
/* Initialized. */
|
||||
@@ -341,7 +218,7 @@ static ssize_t coffeecatch_backtrace_signal(siginfo_t* si, void* sc,
|
||||
&& acquire_my_map_info_list != NULL
|
||||
&& release_my_map_info_list != NULL) {
|
||||
map_info_t*const info = acquire_my_map_info_list();
|
||||
- const ssize_t size =
|
||||
+ const ssize_t size =
|
||||
unwind_backtrace_signal_arch(si, sc, info, frames, ignore_depth,
|
||||
max_depth);
|
||||
release_my_map_info_list(info);
|
||||
@@ -1073,12 +950,12 @@ static uintptr_t coffeecatch_get_pc_from_ucontext(const ucontext_t *uc) {
|
||||
return uc->uc_mcontext.regs->nip;
|
||||
#elif (defined(__hppa__))
|
||||
return uc->uc_mcontext.sc_iaoq[0] & ~0x3UL;
|
||||
-#elif (defined(__sparc__) && defined (__arch64__))
|
||||
- return uc->uc_mcontext.mc_gregs[MC_PC];
|
||||
-#elif (defined(__sparc__) && !defined (__arch64__))
|
||||
- return uc->uc_mcontext.gregs[REG_PC];
|
||||
-#elif (defined(__mips__))
|
||||
- return uc->uc_mcontext.gregs[31];
|
||||
+#elif (defined(__sparc__) && defined (__arch64__))
|
||||
+ return uc->uc_mcontext.mc_gregs[MC_PC];
|
||||
+#elif (defined(__sparc__) && !defined (__arch64__))
|
||||
+ return uc->uc_mcontext.gregs[REG_PC];
|
||||
+#elif (defined(__mips__))
|
||||
+ return uc->uc_mcontext.gregs[31];
|
||||
#else
|
||||
#error "Architecture is unknown, please report me!"
|
||||
#endif
|
||||
185
android/cpp/coffeejni.c
Normal file
185
android/cpp/coffeejni.c
Normal file
@@ -0,0 +1,185 @@
|
||||
/* CoffeeCatch, a tiny native signal handler/catcher for JNI code.
|
||||
* (especially for Android/Dalvik)
|
||||
*
|
||||
* Copyright (c) 2013, Xavier Roche (http://www.httrack.com/)
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this
|
||||
* list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
|
||||
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef COFFEECATCH_JNI_H
|
||||
#define COFFEECATCH_JNI_H
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <stdint.h>
|
||||
#include <sys/types.h>
|
||||
#include <jni.h>
|
||||
#include <assert.h>
|
||||
#include <coffeecatch/coffeecatch.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef struct t_bt_fun {
|
||||
JNIEnv* env;
|
||||
jclass cls;
|
||||
jclass cls_ste;
|
||||
jmethodID cons_ste;
|
||||
jobjectArray elements;
|
||||
size_t size;
|
||||
size_t index;
|
||||
} t_bt_fun;
|
||||
|
||||
static char* bt_print(const char *function, uintptr_t offset) {
|
||||
if (function != NULL) {
|
||||
char buffer[256];
|
||||
snprintf(buffer, sizeof(buffer), "%s:%p", function, (void*) offset);
|
||||
return strdup(buffer);
|
||||
} else {
|
||||
return "<unknown>";
|
||||
}
|
||||
}
|
||||
|
||||
static char* bt_addr(uintptr_t addr) {
|
||||
char buffer[32];
|
||||
snprintf(buffer, sizeof(buffer), "%p", (void*) addr);
|
||||
return strdup(buffer);
|
||||
}
|
||||
|
||||
#define IS_VALID_CLASS_CHAR(C) ( \
|
||||
((C) >= 'a' && (C) <= 'z') \
|
||||
|| ((C) >= 'A' && (C) <= 'Z') \
|
||||
|| ((C) >= '0' && (C) <= '9') \
|
||||
|| (C) == '_' \
|
||||
)
|
||||
|
||||
static char* bt_module(const char *module) {
|
||||
if (module != NULL) {
|
||||
size_t i;
|
||||
char *copy;
|
||||
if (*module == '/') {
|
||||
module++;
|
||||
}
|
||||
copy = strdup(module);
|
||||
/* Pseudo-java-class. */
|
||||
for(i = 0; copy[i] != '\0'; i++) {
|
||||
if (copy[i] == '/') {
|
||||
copy[i] = '.';
|
||||
} else if (!IS_VALID_CLASS_CHAR(copy[i])) {
|
||||
copy[i] = '_';
|
||||
}
|
||||
}
|
||||
return copy;
|
||||
} else {
|
||||
return "<unknown>";
|
||||
}
|
||||
}
|
||||
|
||||
static void bt_fun(void *arg, const char *module, uintptr_t addr,
|
||||
const char *function, uintptr_t offset) {
|
||||
t_bt_fun *const t = (t_bt_fun*) arg;
|
||||
JNIEnv*const env = t->env;
|
||||
jstring declaringClass = (*env)->NewStringUTF(env, bt_module(module));
|
||||
jstring methodName = (*env)->NewStringUTF(env, bt_addr(addr));
|
||||
jstring fileName = (*env)->NewStringUTF(env, bt_print(function, offset));
|
||||
const int lineNumber = function != NULL ? 0 : -2; /* "-2" is "inside JNI code" */
|
||||
jobject trace = (*env)->NewObject(env, t->cls_ste, t->cons_ste,
|
||||
declaringClass, methodName, fileName,
|
||||
lineNumber);
|
||||
if (t->index < t->size) {
|
||||
(*t->env)->SetObjectArrayElement(t->env, t->elements, t->index++, trace);
|
||||
}
|
||||
}
|
||||
|
||||
void coffeecatch_throw_exception(JNIEnv* env) {
|
||||
jclass cls = (*env)->FindClass(env, "java/lang/Error");
|
||||
jclass cls_ste = (*env)->FindClass(env, "java/lang/StackTraceElement");
|
||||
|
||||
jmethodID cons = (*env)->GetMethodID(env, cls, "<init>", "(Ljava/lang/String;)V");
|
||||
jmethodID cons_cause = (*env)->GetMethodID(env, cls, "<init>", "(Ljava/lang/String;Ljava/lang/Throwable;)V");
|
||||
jmethodID cons_ste = (*env)->GetMethodID(env, cls_ste, "<init>",
|
||||
"(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;I)V");
|
||||
jmethodID meth_sste = (*env)->GetMethodID(env, cls, "setStackTrace",
|
||||
"([Ljava/lang/StackTraceElement;)V");
|
||||
|
||||
/* Exception message. */
|
||||
const char*const message = coffeecatch_get_message();
|
||||
jstring str = (*env)->NewStringUTF(env, strdup(message));
|
||||
|
||||
/* Final exception. */
|
||||
jthrowable exception;
|
||||
|
||||
/* Add pseudo-stack trace. */
|
||||
const ssize_t bt_size = coffeecatch_get_backtrace_size();
|
||||
|
||||
assert(cls != NULL);
|
||||
assert(cls_ste != NULL);
|
||||
assert(cons != NULL);
|
||||
assert(cons_cause != NULL);
|
||||
assert(cons_ste != NULL);
|
||||
assert(meth_sste != NULL);
|
||||
|
||||
assert(message != NULL);
|
||||
assert(str != NULL);
|
||||
|
||||
/* Can we produce a stack trace ? */
|
||||
if (bt_size > 0) {
|
||||
/* Create secondary exception. */
|
||||
jthrowable cause = (jthrowable) (*env)->NewObject(env, cls, cons, str);
|
||||
|
||||
/* Stack trace. */
|
||||
jobjectArray elements =
|
||||
(*env)->NewObjectArray(env, bt_size, cls_ste, NULL);
|
||||
if (elements != NULL) {
|
||||
t_bt_fun t;
|
||||
t.env = env;
|
||||
t.cls = cls;
|
||||
t.cls_ste = cls_ste;
|
||||
t.cons_ste = cons_ste;
|
||||
t.elements = elements;
|
||||
t.index = 0;
|
||||
t.size = bt_size;
|
||||
coffeecatch_get_backtrace_info(bt_fun, &t);
|
||||
(*env)->CallVoidMethod(env, cause, meth_sste, elements);
|
||||
}
|
||||
|
||||
/* Primary exception */
|
||||
exception = (jthrowable) (*env)->NewObject(env, cls, cons_cause, str, cause);
|
||||
} else {
|
||||
/* Simple exception */
|
||||
exception = (jthrowable) (*env)->NewObject(env, cls, cons, str);
|
||||
}
|
||||
|
||||
/* Throw exception. */
|
||||
if (exception != NULL) {
|
||||
(*env)->Throw(env, exception);
|
||||
} else {
|
||||
(*env)->ThrowNew(env, cls, strdup(message));
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -11,6 +11,8 @@
|
||||
|
||||
#include <android/native_window_jni.h>
|
||||
|
||||
#include <coffeecatch/coffeejni.h>
|
||||
|
||||
#include <mbgl/android/jni.hpp>
|
||||
#include <mbgl/android/native_map_view.hpp>
|
||||
#include <mbgl/map/map.hpp>
|
||||
@@ -144,7 +146,8 @@ jlong JNICALL nativeCreate(JNIEnv* env, jobject obj, jstring cache_path_, jstrin
|
||||
mbgl::Log::Debug(mbgl::Event::JNI, "nativeCreate");
|
||||
cache_path = std_string_from_jstring(env, cache_path_);
|
||||
data_path = std_string_from_jstring(env, data_path_);
|
||||
NativeMapView* native_map_view = new NativeMapView(env, obj);
|
||||
NativeMapView* native_map_view = nullptr;
|
||||
COFFEE_TRY_JNI(env, native_map_view = new NativeMapView(env, obj));
|
||||
if (native_map_view == nullptr) {
|
||||
throw_error(env, "Unable to create NativeMapView.");
|
||||
return 0;
|
||||
@@ -165,7 +168,9 @@ void JNICALL nativeInitializeDisplay(JNIEnv* env, jobject obj, jlong native_map_
|
||||
mbgl::Log::Debug(mbgl::Event::JNI, "nativeInitializeDisplay");
|
||||
assert(native_map_view_ptr != 0);
|
||||
NativeMapView* native_map_view = reinterpret_cast<NativeMapView*>(native_map_view_ptr);
|
||||
if (!native_map_view->initializeDisplay()) {
|
||||
bool ret = false;
|
||||
COFFEE_TRY_JNI(env, ret = native_map_view->initializeDisplay());
|
||||
if (!ret) {
|
||||
throw_error(env, "Unable to initialize GL display.");
|
||||
}
|
||||
}
|
||||
@@ -174,14 +179,16 @@ void JNICALL nativeTerminateDisplay(JNIEnv* env, jobject obj, jlong native_map_v
|
||||
mbgl::Log::Debug(mbgl::Event::JNI, "nativeTerminateDisplay");
|
||||
assert(native_map_view_ptr != 0);
|
||||
NativeMapView* native_map_view = reinterpret_cast<NativeMapView*>(native_map_view_ptr);
|
||||
native_map_view->terminateDisplay();
|
||||
COFFEE_TRY_JNI(env, native_map_view->terminateDisplay());
|
||||
}
|
||||
|
||||
void JNICALL nativeInitializeContext(JNIEnv* env, jobject obj, jlong native_map_view_ptr) {
|
||||
mbgl::Log::Debug(mbgl::Event::JNI, "nativeInitializeContext");
|
||||
assert(native_map_view_ptr != 0);
|
||||
NativeMapView* native_map_view = reinterpret_cast<NativeMapView*>(native_map_view_ptr);
|
||||
if (!native_map_view->initializeContext()) {
|
||||
bool ret = false;
|
||||
COFFEE_TRY_JNI(env, ret = native_map_view->initializeContext());
|
||||
if (!ret) {
|
||||
throw_error(env, "Unable to initialize GL context.");
|
||||
}
|
||||
}
|
||||
@@ -190,14 +197,16 @@ void JNICALL nativeTerminateContext(JNIEnv* env, jobject obj, jlong native_map_v
|
||||
mbgl::Log::Debug(mbgl::Event::JNI, "nativeTerminateContext");
|
||||
assert(native_map_view_ptr != 0);
|
||||
NativeMapView* native_map_view = reinterpret_cast<NativeMapView*>(native_map_view_ptr);
|
||||
native_map_view->terminateContext();
|
||||
COFFEE_TRY_JNI(env, native_map_view->terminateContext());
|
||||
}
|
||||
|
||||
void JNICALL nativeCreateSurface(JNIEnv* env, jobject obj, jlong native_map_view_ptr, jobject surface) {
|
||||
mbgl::Log::Debug(mbgl::Event::JNI, "nativeCreateSurface");
|
||||
assert(native_map_view_ptr != 0);
|
||||
NativeMapView* native_map_view = reinterpret_cast<NativeMapView*>(native_map_view_ptr);
|
||||
if (!native_map_view->createSurface(ANativeWindow_fromSurface(env, surface))) {
|
||||
bool ret = false;
|
||||
COFFEE_TRY_JNI(env, native_map_view->createSurface(ANativeWindow_fromSurface(env, surface)));
|
||||
if (!ret) {
|
||||
throw_error(env, "Unable to create GL surface.");
|
||||
}
|
||||
}
|
||||
@@ -206,84 +215,86 @@ void JNICALL nativeDestroySurface(JNIEnv* env, jobject obj, jlong native_map_vie
|
||||
mbgl::Log::Debug(mbgl::Event::JNI, "nativeDestroySurface");
|
||||
assert(native_map_view_ptr != 0);
|
||||
NativeMapView* native_map_view = reinterpret_cast<NativeMapView*>(native_map_view_ptr);
|
||||
native_map_view->destroySurface();
|
||||
COFFEE_TRY_JNI(env, native_map_view->destroySurface());
|
||||
}
|
||||
|
||||
void JNICALL nativeStart(JNIEnv* env, jobject obj, jlong native_map_view_ptr) {
|
||||
mbgl::Log::Debug(mbgl::Event::JNI, "nativeStart");
|
||||
assert(native_map_view_ptr != 0);
|
||||
NativeMapView* native_map_view = reinterpret_cast<NativeMapView*>(native_map_view_ptr);
|
||||
native_map_view->start();
|
||||
COFFEE_TRY_JNI(env, native_map_view->start());
|
||||
}
|
||||
|
||||
void JNICALL nativeStop(JNIEnv* env, jobject obj, jlong native_map_view_ptr) {
|
||||
mbgl::Log::Debug(mbgl::Event::JNI, "nativeStop");
|
||||
assert(native_map_view_ptr != 0);
|
||||
NativeMapView* native_map_view = reinterpret_cast<NativeMapView*>(native_map_view_ptr);
|
||||
native_map_view->stop();
|
||||
COFFEE_TRY_JNI(env, native_map_view->stop());
|
||||
}
|
||||
|
||||
void JNICALL nativePause(JNIEnv* env, jobject obj, jlong native_map_view_ptr) {
|
||||
mbgl::Log::Debug(mbgl::Event::JNI, "nativePause");
|
||||
assert(native_map_view_ptr != 0);
|
||||
NativeMapView* native_map_view = reinterpret_cast<NativeMapView*>(native_map_view_ptr);
|
||||
native_map_view->pause();
|
||||
COFFEE_TRY_JNI(env, native_map_view->pause());
|
||||
}
|
||||
|
||||
void JNICALL nativeResume(JNIEnv* env, jobject obj, jlong native_map_view_ptr) {
|
||||
mbgl::Log::Debug(mbgl::Event::JNI, "nativeResume");
|
||||
assert(native_map_view_ptr != 0);
|
||||
NativeMapView* native_map_view = reinterpret_cast<NativeMapView*>(native_map_view_ptr);
|
||||
native_map_view->resume();
|
||||
COFFEE_TRY_JNI(env, native_map_view->resume());
|
||||
}
|
||||
|
||||
void JNICALL nativeRun(JNIEnv* env, jobject obj, jlong native_map_view_ptr) {
|
||||
mbgl::Log::Debug(mbgl::Event::JNI, "nativeRun");
|
||||
assert(native_map_view_ptr != 0);
|
||||
NativeMapView* native_map_view = reinterpret_cast<NativeMapView*>(native_map_view_ptr);
|
||||
native_map_view->getMap().run();
|
||||
COFFEE_TRY_JNI(env, native_map_view->getMap().run());
|
||||
}
|
||||
|
||||
void JNICALL nativeRerender(JNIEnv* env, jobject obj, jlong native_map_view_ptr) {
|
||||
mbgl::Log::Debug(mbgl::Event::JNI, "nativeRerender");
|
||||
assert(native_map_view_ptr != 0);
|
||||
NativeMapView* native_map_view = reinterpret_cast<NativeMapView*>(native_map_view_ptr);
|
||||
native_map_view->getMap().rerender();
|
||||
COFFEE_TRY_JNI(env, native_map_view->getMap().rerender());
|
||||
}
|
||||
|
||||
void JNICALL nativeUpdate(JNIEnv* env, jobject obj, jlong native_map_view_ptr) {
|
||||
mbgl::Log::Debug(mbgl::Event::JNI, "nativeUpdate");
|
||||
assert(native_map_view_ptr != 0);
|
||||
NativeMapView* native_map_view = reinterpret_cast<NativeMapView*>(native_map_view_ptr);
|
||||
native_map_view->getMap().update();
|
||||
COFFEE_TRY_JNI(env, native_map_view->getMap().update());
|
||||
}
|
||||
|
||||
void JNICALL nativeCleanup(JNIEnv* env, jobject obj, jlong native_map_view_ptr) {
|
||||
mbgl::Log::Debug(mbgl::Event::JNI, "nativeCleanup");
|
||||
assert(native_map_view_ptr != 0);
|
||||
NativeMapView* native_map_view = reinterpret_cast<NativeMapView*>(native_map_view_ptr);
|
||||
native_map_view->getMap().cleanup();
|
||||
COFFEE_TRY_JNI(env, native_map_view->getMap().cleanup());
|
||||
}
|
||||
|
||||
void JNICALL nativeTerminate(JNIEnv* env, jobject obj, jlong native_map_view_ptr) {
|
||||
mbgl::Log::Debug(mbgl::Event::JNI, "nativeTerminate");
|
||||
assert(native_map_view_ptr != 0);
|
||||
NativeMapView* native_map_view = reinterpret_cast<NativeMapView*>(native_map_view_ptr);
|
||||
native_map_view->getMap().terminate();
|
||||
COFFEE_TRY_JNI(env, native_map_view->getMap().terminate());
|
||||
}
|
||||
|
||||
jboolean JNICALL nativeNeedsSwap(JNIEnv* env, jobject obj, jlong native_map_view_ptr) {
|
||||
mbgl::Log::Debug(mbgl::Event::JNI, "nativeNeedsSwap");
|
||||
assert(native_map_view_ptr != 0);
|
||||
NativeMapView* native_map_view = reinterpret_cast<NativeMapView*>(native_map_view_ptr);
|
||||
return native_map_view->getMap().needsSwap();
|
||||
jboolean ret = false;
|
||||
COFFEE_TRY_JNI(env, ret = native_map_view->getMap().needsSwap());
|
||||
return ret;
|
||||
}
|
||||
|
||||
void JNICALL nativeSwapped(JNIEnv* env, jobject obj, jlong native_map_view_ptr) {
|
||||
mbgl::Log::Debug(mbgl::Event::JNI, "nativeSwapped");
|
||||
assert(native_map_view_ptr != 0);
|
||||
NativeMapView* native_map_view = reinterpret_cast<NativeMapView*>(native_map_view_ptr);
|
||||
native_map_view->getMap().swapped();
|
||||
COFFEE_TRY_JNI(env, (native_map_view->getMap().swapped()));
|
||||
}
|
||||
|
||||
void JNICALL nativeResize(JNIEnv* env, jobject obj, jlong native_map_view_ptr, jint width, jint height, jfloat ratio) {
|
||||
@@ -294,7 +305,7 @@ void JNICALL nativeResize(JNIEnv* env, jobject obj, jlong native_map_view_ptr, j
|
||||
assert(width <= UINT16_MAX);
|
||||
assert(height <= UINT16_MAX);
|
||||
NativeMapView* native_map_view = reinterpret_cast<NativeMapView*>(native_map_view_ptr);
|
||||
native_map_view->getMap().resize(width, height, ratio);
|
||||
COFFEE_TRY_JNI(env, native_map_view->getMap().resize(width, height, ratio));
|
||||
}
|
||||
|
||||
void JNICALL nativeResize(JNIEnv* env, jobject obj, jlong native_map_view_ptr, jint width, jint height, jfloat ratio, jint fb_width, jint fb_height) {
|
||||
@@ -309,21 +320,23 @@ void JNICALL nativeResize(JNIEnv* env, jobject obj, jlong native_map_view_ptr, j
|
||||
assert(fb_width <= UINT16_MAX);
|
||||
assert(fb_height <= UINT16_MAX);
|
||||
NativeMapView* native_map_view = reinterpret_cast<NativeMapView*>(native_map_view_ptr);
|
||||
native_map_view->getMap().resize(width, height, ratio, fb_width, fb_height);
|
||||
COFFEE_TRY_JNI(env, native_map_view->getMap().resize(width, height, ratio, fb_width, fb_height));
|
||||
}
|
||||
|
||||
void JNICALL nativeSetAppliedClasses(JNIEnv* env, jobject obj, jlong native_map_view_ptr, jobject classes) {
|
||||
mbgl::Log::Debug(mbgl::Event::JNI, "nativeSetAppliedClasses");
|
||||
assert(native_map_view_ptr != 0);
|
||||
NativeMapView* native_map_view = reinterpret_cast<NativeMapView*>(native_map_view_ptr);
|
||||
native_map_view->getMap().setAppliedClasses(std_vector_string_from_jobject(env, classes));
|
||||
COFFEE_TRY_JNI(env, native_map_view->getMap().setAppliedClasses(std_vector_string_from_jobject(env, classes)));
|
||||
}
|
||||
|
||||
jobject JNICALL nativeGetAppliedClasses(JNIEnv* env, jobject obj, jlong native_map_view_ptr) {
|
||||
mbgl::Log::Debug(mbgl::Event::JNI, "nativeGetAppliedClasses");
|
||||
assert(native_map_view_ptr != 0);
|
||||
NativeMapView* native_map_view = reinterpret_cast<NativeMapView*>(native_map_view_ptr);
|
||||
return std_vector_string_to_jobject(env, native_map_view->getMap().getAppliedClasses());
|
||||
jobject ret = nullptr;
|
||||
COFFEE_TRY_JNI(env, ret = std_vector_string_to_jobject(env, native_map_view->getMap().getAppliedClasses()));
|
||||
return ret;
|
||||
}
|
||||
|
||||
void JNICALL nativeSetDefaultTransitionDuration(JNIEnv* env, jobject obj, jlong native_map_view_ptr, jlong duration_milliseconds) {
|
||||
@@ -331,56 +344,60 @@ void JNICALL nativeSetDefaultTransitionDuration(JNIEnv* env, jobject obj, jlong
|
||||
assert(native_map_view_ptr != 0);
|
||||
assert(duration_milliseconds >= 0);
|
||||
NativeMapView* native_map_view = reinterpret_cast<NativeMapView*>(native_map_view_ptr);
|
||||
native_map_view->getMap().setDefaultTransitionDuration(duration_milliseconds);
|
||||
COFFEE_TRY_JNI(env, native_map_view->getMap().setDefaultTransitionDuration(duration_milliseconds));
|
||||
}
|
||||
|
||||
void JNICALL nativeSetStyleURL(JNIEnv* env, jobject obj, jlong native_map_view_ptr, jstring url) {
|
||||
mbgl::Log::Debug(mbgl::Event::JNI, "nativeSetStyleURL");
|
||||
assert(native_map_view_ptr != 0);
|
||||
NativeMapView* native_map_view = reinterpret_cast<NativeMapView*>(native_map_view_ptr);
|
||||
native_map_view->getMap().setStyleURL(std_string_from_jstring(env, url));
|
||||
COFFEE_TRY_JNI(env, native_map_view->getMap().setStyleURL(std_string_from_jstring(env, url)));
|
||||
}
|
||||
|
||||
void JNICALL nativeSetStyleJSON(JNIEnv* env, jobject obj, jlong native_map_view_ptr, jstring new_style_json, jstring base) {
|
||||
mbgl::Log::Debug(mbgl::Event::JNI, "nativeSetStyleJSON");
|
||||
assert(native_map_view_ptr != 0);
|
||||
NativeMapView* native_map_view = reinterpret_cast<NativeMapView*>(native_map_view_ptr);
|
||||
native_map_view->getMap().setStyleJSON(std_string_from_jstring(env, new_style_json), std_string_from_jstring(env, base));
|
||||
COFFEE_TRY_JNI(env, native_map_view->getMap().setStyleJSON(std_string_from_jstring(env, new_style_json), std_string_from_jstring(env, base)));
|
||||
}
|
||||
|
||||
jstring JNICALL nativeGetStyleJSON(JNIEnv* env, jobject obj, jlong native_map_view_ptr) {
|
||||
mbgl::Log::Debug(mbgl::Event::JNI, "nativeGetStyleJSON");
|
||||
assert(native_map_view_ptr != 0);
|
||||
NativeMapView* native_map_view = reinterpret_cast<NativeMapView*>(native_map_view_ptr);
|
||||
return std_string_to_jstring(env, native_map_view->getMap().getStyleJSON());
|
||||
jstring ret = nullptr;
|
||||
COFFEE_TRY_JNI(env, ret = std_string_to_jstring(env, native_map_view->getMap().getStyleJSON()));
|
||||
return ret;
|
||||
}
|
||||
|
||||
void JNICALL nativeSetAccessToken(JNIEnv* env, jobject obj, jlong native_map_view_ptr, jstring access_token) {
|
||||
mbgl::Log::Debug(mbgl::Event::JNI, "nativeSetAccessToken");
|
||||
assert(native_map_view_ptr != 0);
|
||||
NativeMapView* native_map_view = reinterpret_cast<NativeMapView*>(native_map_view_ptr);
|
||||
native_map_view->getMap().setAccessToken(std_string_from_jstring(env, access_token));
|
||||
COFFEE_TRY_JNI(env, native_map_view->getMap().setAccessToken(std_string_from_jstring(env, access_token)));
|
||||
}
|
||||
|
||||
jstring JNICALL nativeGetAccessToken(JNIEnv* env, jobject obj, jlong native_map_view_ptr) {
|
||||
mbgl::Log::Debug(mbgl::Event::JNI, "nativeGetAccessToken");
|
||||
assert(native_map_view_ptr != 0);
|
||||
NativeMapView* native_map_view = reinterpret_cast<NativeMapView*>(native_map_view_ptr);
|
||||
return std_string_to_jstring(env, native_map_view->getMap().getAccessToken());
|
||||
jstring ret = nullptr;
|
||||
COFFEE_TRY_JNI(env, ret = std_string_to_jstring(env, native_map_view->getMap().getAccessToken()));
|
||||
return ret;
|
||||
}
|
||||
|
||||
void JNICALL nativeCancelTransitions(JNIEnv* env, jobject obj, jlong native_map_view_ptr) {
|
||||
mbgl::Log::Debug(mbgl::Event::JNI, "nativeCancelTransitions");
|
||||
assert(native_map_view_ptr != 0);
|
||||
NativeMapView* native_map_view = reinterpret_cast<NativeMapView*>(native_map_view_ptr);
|
||||
native_map_view->getMap().cancelTransitions();
|
||||
COFFEE_TRY_JNI(env, native_map_view->getMap().cancelTransitions());
|
||||
}
|
||||
|
||||
void JNICALL nativeMoveBy(JNIEnv* env, jobject obj, jlong native_map_view_ptr, jdouble dx, jdouble dy, jdouble duration) {
|
||||
mbgl::Log::Debug(mbgl::Event::JNI, "nativeMoveBy");
|
||||
assert(native_map_view_ptr != 0);
|
||||
NativeMapView* native_map_view = reinterpret_cast<NativeMapView*>(native_map_view_ptr);
|
||||
native_map_view->getMap().moveBy(dx, dy, duration);
|
||||
COFFEE_TRY_JNI(env, native_map_view->getMap().moveBy(dx, dy, duration));
|
||||
}
|
||||
|
||||
void JNICALL nativeSetLonLat(JNIEnv* env, jobject obj, jlong native_map_view_ptr, jobject lon_lat, jdouble duration) {
|
||||
@@ -400,15 +417,15 @@ void JNICALL nativeSetLonLat(JNIEnv* env, jobject obj, jlong native_map_view_ptr
|
||||
return;
|
||||
}
|
||||
|
||||
native_map_view->getMap().setLonLat(lon, lat, duration);
|
||||
COFFEE_TRY_JNI(env, native_map_view->getMap().setLonLat(lon, lat, duration));
|
||||
}
|
||||
|
||||
jobject JNICALL nativeGetLonLat(JNIEnv* env, jobject obj, jlong native_map_view_ptr) {
|
||||
mbgl::Log::Debug(mbgl::Event::JNI, "nativeGetLonLat");
|
||||
assert(native_map_view_ptr != 0);
|
||||
NativeMapView* native_map_view = reinterpret_cast<NativeMapView*>(native_map_view_ptr);
|
||||
double lon, lat;
|
||||
native_map_view->getMap().getLonLat(lon, lat);
|
||||
double lon = 0.0, lat = 0.0;
|
||||
COFFEE_TRY_JNI(env, native_map_view->getMap().getLonLat(lon, lat));
|
||||
|
||||
jobject ret = env->NewObject(lon_lat_class, lon_lat_constructor_id, lon, lat);
|
||||
if (ret == nullptr) {
|
||||
@@ -423,56 +440,60 @@ void JNICALL nativeStartPanning(JNIEnv* env, jobject obj, jlong native_map_view_
|
||||
mbgl::Log::Debug(mbgl::Event::JNI, "nativeStartPanning");
|
||||
assert(native_map_view_ptr != 0);
|
||||
NativeMapView* native_map_view = reinterpret_cast<NativeMapView*>(native_map_view_ptr);
|
||||
native_map_view->getMap().startPanning();
|
||||
COFFEE_TRY_JNI(env, native_map_view->getMap().startPanning());
|
||||
}
|
||||
|
||||
void JNICALL nativeStopPanning(JNIEnv* env, jobject obj, jlong native_map_view_ptr) {
|
||||
mbgl::Log::Debug(mbgl::Event::JNI, "nativeStopPanning");
|
||||
assert(native_map_view_ptr != 0);
|
||||
NativeMapView* native_map_view = reinterpret_cast<NativeMapView*>(native_map_view_ptr);
|
||||
native_map_view->getMap().stopPanning();
|
||||
COFFEE_TRY_JNI(env, native_map_view->getMap().stopPanning());
|
||||
}
|
||||
|
||||
void JNICALL nativeResetPosition(JNIEnv* env, jobject obj, jlong native_map_view_ptr) {
|
||||
mbgl::Log::Debug(mbgl::Event::JNI, "nativeResetPosition");
|
||||
assert(native_map_view_ptr != 0);
|
||||
NativeMapView* native_map_view = reinterpret_cast<NativeMapView*>(native_map_view_ptr);
|
||||
native_map_view->getMap().resetPosition();
|
||||
COFFEE_TRY_JNI(env, native_map_view->getMap().resetPosition());
|
||||
}
|
||||
|
||||
void JNICALL nativeScaleBy(JNIEnv* env, jobject obj, jlong native_map_view_ptr, jdouble ds, jdouble cx, jdouble cy, jdouble duration) {
|
||||
mbgl::Log::Debug(mbgl::Event::JNI, "nativeScaleBy");
|
||||
assert(native_map_view_ptr != 0);
|
||||
NativeMapView* native_map_view = reinterpret_cast<NativeMapView*>(native_map_view_ptr);
|
||||
native_map_view->getMap().scaleBy(ds, cx, cy, duration);
|
||||
COFFEE_TRY_JNI(env, native_map_view->getMap().scaleBy(ds, cx, cy, duration));
|
||||
}
|
||||
|
||||
void JNICALL nativeSetScale(JNIEnv* env, jobject obj, jlong native_map_view_ptr, jdouble scale, jdouble cx, jdouble cy, jdouble duration) {
|
||||
mbgl::Log::Debug(mbgl::Event::JNI, "nativeSetScale");
|
||||
assert(native_map_view_ptr != 0);
|
||||
NativeMapView* native_map_view = reinterpret_cast<NativeMapView*>(native_map_view_ptr);
|
||||
native_map_view->getMap().setScale(scale, cx, cy, duration);
|
||||
COFFEE_TRY_JNI(env, native_map_view->getMap().setScale(scale, cx, cy, duration));
|
||||
}
|
||||
|
||||
jdouble JNICALL nativeGetScale(JNIEnv* env, jobject obj, jlong native_map_view_ptr) {
|
||||
mbgl::Log::Debug(mbgl::Event::JNI, "nativeGetScale");
|
||||
assert(native_map_view_ptr != 0);
|
||||
NativeMapView* native_map_view = reinterpret_cast<NativeMapView*>(native_map_view_ptr);
|
||||
return native_map_view->getMap().getScale();
|
||||
jdouble ret = 0.0;
|
||||
COFFEE_TRY_JNI(env, ret = native_map_view->getMap().getScale());
|
||||
return ret;
|
||||
}
|
||||
|
||||
void JNICALL nativeSetZoom(JNIEnv* env, jobject obj, jlong native_map_view_ptr, jdouble zoom, jdouble duration) {
|
||||
mbgl::Log::Debug(mbgl::Event::JNI, "nativeSetZoom");
|
||||
assert(native_map_view_ptr != 0);
|
||||
NativeMapView* native_map_view = reinterpret_cast<NativeMapView*>(native_map_view_ptr);
|
||||
native_map_view->getMap().setZoom(zoom, duration);
|
||||
COFFEE_TRY_JNI(env, native_map_view->getMap().setZoom(zoom, duration));
|
||||
}
|
||||
|
||||
jdouble JNICALL nativeGetZoom(JNIEnv* env, jobject obj, jlong native_map_view_ptr) {
|
||||
mbgl::Log::Debug(mbgl::Event::JNI, "nativeGetZoom");
|
||||
assert(native_map_view_ptr != 0);
|
||||
NativeMapView* native_map_view = reinterpret_cast<NativeMapView*>(native_map_view_ptr);
|
||||
return native_map_view->getMap().getZoom();
|
||||
jdouble ret = 0.0;
|
||||
COFFEE_TRY_JNI(env, ret = native_map_view->getMap().getZoom());
|
||||
return ret;
|
||||
}
|
||||
|
||||
void JNICALL nativeSetLonLatZoom(JNIEnv* env, jobject obj, jlong native_map_view_ptr, jobject lon_lat_zoom, jdouble duration) {
|
||||
@@ -498,15 +519,15 @@ void JNICALL nativeSetLonLatZoom(JNIEnv* env, jobject obj, jlong native_map_view
|
||||
return;
|
||||
}
|
||||
|
||||
native_map_view->getMap().setLonLatZoom(lon, lat, zoom, duration);
|
||||
COFFEE_TRY_JNI(env, native_map_view->getMap().setLonLatZoom(lon, lat, zoom, duration));
|
||||
}
|
||||
|
||||
jobject JNICALL nativeGetLonLatZoom(JNIEnv* env, jobject obj, jlong native_map_view_ptr) {
|
||||
mbgl::Log::Debug(mbgl::Event::JNI, "nativeGetLonLatZoom");
|
||||
assert(native_map_view_ptr != 0);
|
||||
NativeMapView* native_map_view = reinterpret_cast<NativeMapView*>(native_map_view_ptr);
|
||||
double lon, lat, zoom;
|
||||
native_map_view->getMap().getLonLatZoom(lon, lat, zoom);
|
||||
double lon = 0.0, lat = 0.0, zoom = 0.0;
|
||||
COFFEE_TRY_JNI(env, native_map_view->getMap().getLonLatZoom(lon, lat, zoom));
|
||||
|
||||
jobject ret = env->NewObject(lon_lat_zoom_class, lon_lat_zoom_constructor_id, lon, lat, zoom);
|
||||
if (ret == nullptr) {
|
||||
@@ -521,119 +542,129 @@ void JNICALL nativeResetZoom(JNIEnv* env, jobject obj, jlong native_map_view_ptr
|
||||
mbgl::Log::Debug(mbgl::Event::JNI, "nativeResetZoom");
|
||||
assert(native_map_view_ptr != 0);
|
||||
NativeMapView* native_map_view = reinterpret_cast<NativeMapView*>(native_map_view_ptr);
|
||||
native_map_view->getMap().resetZoom();
|
||||
COFFEE_TRY_JNI(env, native_map_view->getMap().resetZoom());
|
||||
}
|
||||
|
||||
void JNICALL nativeStartScaling(JNIEnv* env, jobject obj, jlong native_map_view_ptr) {
|
||||
mbgl::Log::Debug(mbgl::Event::JNI, "nativeStartScaling");
|
||||
assert(native_map_view_ptr != 0);
|
||||
NativeMapView* native_map_view = reinterpret_cast<NativeMapView*>(native_map_view_ptr);
|
||||
native_map_view->getMap().startScaling();
|
||||
COFFEE_TRY_JNI(env, native_map_view->getMap().startScaling());
|
||||
}
|
||||
|
||||
void JNICALL nativeStopScaling(JNIEnv* env, jobject obj, jlong native_map_view_ptr) {
|
||||
mbgl::Log::Debug(mbgl::Event::JNI, "nativeStopScaling");
|
||||
assert(native_map_view_ptr != 0);
|
||||
NativeMapView* native_map_view = reinterpret_cast<NativeMapView*>(native_map_view_ptr);
|
||||
native_map_view->getMap().stopScaling();
|
||||
COFFEE_TRY_JNI(env, native_map_view->getMap().stopScaling());
|
||||
}
|
||||
|
||||
jdouble JNICALL nativeGetMinZoom(JNIEnv* env, jobject obj, jlong native_map_view_ptr) {
|
||||
mbgl::Log::Debug(mbgl::Event::JNI, "nativeGetMinZoom");
|
||||
assert(native_map_view_ptr != 0);
|
||||
NativeMapView* native_map_view = reinterpret_cast<NativeMapView*>(native_map_view_ptr);
|
||||
return native_map_view->getMap().getMinZoom();
|
||||
jdouble ret = 0.0;
|
||||
COFFEE_TRY_JNI(env, ret = native_map_view->getMap().getMinZoom());
|
||||
return ret;
|
||||
}
|
||||
|
||||
jdouble JNICALL nativeGetMaxZoom(JNIEnv* env, jobject obj, jlong native_map_view_ptr) {
|
||||
mbgl::Log::Debug(mbgl::Event::JNI, "nativeGetMaxZoom");
|
||||
assert(native_map_view_ptr != 0);
|
||||
NativeMapView* native_map_view = reinterpret_cast<NativeMapView*>(native_map_view_ptr);
|
||||
return native_map_view->getMap().getMaxZoom();
|
||||
jdouble ret = 0.0;
|
||||
COFFEE_TRY_JNI(env, ret = native_map_view->getMap().getMaxZoom());
|
||||
return ret;
|
||||
}
|
||||
|
||||
void JNICALL nativeRotateBy(JNIEnv* env, jobject obj, jlong native_map_view_ptr, jdouble sx, jdouble sy, jdouble ex, jdouble ey, jdouble duration) {
|
||||
mbgl::Log::Debug(mbgl::Event::JNI, "nativeRotateBy");
|
||||
assert(native_map_view_ptr != 0);
|
||||
NativeMapView* native_map_view = reinterpret_cast<NativeMapView*>(native_map_view_ptr);
|
||||
native_map_view->getMap().rotateBy(sx, sy, ex, ey, duration);
|
||||
COFFEE_TRY_JNI(env, native_map_view->getMap().rotateBy(sx, sy, ex, ey, duration));
|
||||
}
|
||||
|
||||
void JNICALL nativeSetBearing(JNIEnv* env, jobject obj, jlong native_map_view_ptr, jdouble degrees, jdouble duration) {
|
||||
mbgl::Log::Debug(mbgl::Event::JNI, "nativeSetBearing");
|
||||
assert(native_map_view_ptr != 0);
|
||||
NativeMapView* native_map_view = reinterpret_cast<NativeMapView*>(native_map_view_ptr);
|
||||
native_map_view->getMap().setBearing(degrees, duration);
|
||||
COFFEE_TRY_JNI(env, native_map_view->getMap().setBearing(degrees, duration));
|
||||
}
|
||||
|
||||
void JNICALL nativeSetBearing(JNIEnv* env, jobject obj, jlong native_map_view_ptr, jdouble degrees, jdouble cx, jdouble cy) {
|
||||
mbgl::Log::Debug(mbgl::Event::JNI, "nativeSetBearing");
|
||||
assert(native_map_view_ptr != 0);
|
||||
NativeMapView* native_map_view = reinterpret_cast<NativeMapView*>(native_map_view_ptr);
|
||||
native_map_view->getMap().setBearing(degrees, cx, cy);
|
||||
COFFEE_TRY_JNI(env, native_map_view->getMap().setBearing(degrees, cx, cy));
|
||||
}
|
||||
|
||||
jdouble JNICALL nativeGetBearing(JNIEnv* env, jobject obj, jlong native_map_view_ptr) {
|
||||
mbgl::Log::Debug(mbgl::Event::JNI, "nativeGetBearing");
|
||||
assert(native_map_view_ptr != 0);
|
||||
NativeMapView* native_map_view = reinterpret_cast<NativeMapView*>(native_map_view_ptr);
|
||||
return native_map_view->getMap().getBearing();
|
||||
jdouble ret = 0.0;
|
||||
COFFEE_TRY_JNI(env, ret = native_map_view->getMap().getBearing());
|
||||
return ret;
|
||||
}
|
||||
|
||||
void JNICALL nativeResetNorth(JNIEnv* env, jobject obj, jlong native_map_view_ptr) {
|
||||
mbgl::Log::Debug(mbgl::Event::JNI, "nativeResetNorth");
|
||||
assert(native_map_view_ptr != 0);
|
||||
NativeMapView* native_map_view = reinterpret_cast<NativeMapView*>(native_map_view_ptr);
|
||||
native_map_view->getMap().resetNorth();
|
||||
COFFEE_TRY_JNI(env, native_map_view->getMap().resetNorth());
|
||||
}
|
||||
|
||||
void JNICALL nativeStartRotating(JNIEnv* env, jobject obj, jlong native_map_view_ptr) {
|
||||
mbgl::Log::Debug(mbgl::Event::JNI, "nativeStartRotating");
|
||||
assert(native_map_view_ptr != 0);
|
||||
NativeMapView* native_map_view = reinterpret_cast<NativeMapView*>(native_map_view_ptr);
|
||||
native_map_view->getMap().startRotating();
|
||||
COFFEE_TRY_JNI(env, native_map_view->getMap().startRotating());
|
||||
}
|
||||
|
||||
void JNICALL nativeStopRotating(JNIEnv* env, jobject obj, jlong native_map_view_ptr) {
|
||||
mbgl::Log::Debug(mbgl::Event::JNI, "nativeStopRotating");
|
||||
assert(native_map_view_ptr != 0);
|
||||
NativeMapView* native_map_view = reinterpret_cast<NativeMapView*>(native_map_view_ptr);
|
||||
native_map_view->getMap().stopRotating();
|
||||
COFFEE_TRY_JNI(env, native_map_view->getMap().stopRotating());
|
||||
}
|
||||
|
||||
jboolean JNICALL nativeCanRotate(JNIEnv* env, jobject obj, jlong native_map_view_ptr) {
|
||||
mbgl::Log::Debug(mbgl::Event::JNI, "nativeCanRotate");
|
||||
assert(native_map_view_ptr != 0);
|
||||
NativeMapView* native_map_view = reinterpret_cast<NativeMapView*>(native_map_view_ptr);
|
||||
return native_map_view->getMap().canRotate();
|
||||
jboolean ret = false;
|
||||
COFFEE_TRY_JNI(env, ret = native_map_view->getMap().canRotate());
|
||||
return ret;
|
||||
}
|
||||
|
||||
void JNICALL nativeSetDebug(JNIEnv* env, jobject obj, jlong native_map_view_ptr, jboolean debug) {
|
||||
mbgl::Log::Debug(mbgl::Event::JNI, "nativeSetDebug");
|
||||
assert(native_map_view_ptr != 0);
|
||||
NativeMapView* native_map_view = reinterpret_cast<NativeMapView*>(native_map_view_ptr);
|
||||
native_map_view->getMap().setDebug(debug);
|
||||
COFFEE_TRY_JNI(env, native_map_view->getMap().setDebug(debug));
|
||||
}
|
||||
|
||||
void JNICALL nativeToggleDebug(JNIEnv* env, jobject obj, jlong native_map_view_ptr) {
|
||||
mbgl::Log::Debug(mbgl::Event::JNI, "nativeToggleDebug");
|
||||
assert(native_map_view_ptr != 0);
|
||||
NativeMapView* native_map_view = reinterpret_cast<NativeMapView*>(native_map_view_ptr);
|
||||
native_map_view->getMap().toggleDebug();
|
||||
COFFEE_TRY_JNI(env, native_map_view->getMap().toggleDebug());
|
||||
}
|
||||
|
||||
jboolean JNICALL nativeGetDebug(JNIEnv* env, jobject obj, jlong native_map_view_ptr) {
|
||||
mbgl::Log::Debug(mbgl::Event::JNI, "nativeGetDebug");
|
||||
assert(native_map_view_ptr != 0);
|
||||
NativeMapView* native_map_view = reinterpret_cast<NativeMapView*>(native_map_view_ptr);
|
||||
return native_map_view->getMap().getDebug();
|
||||
jboolean ret = false;
|
||||
COFFEE_TRY_JNI(env, ret = native_map_view->getMap().getDebug());
|
||||
return ret;
|
||||
}
|
||||
|
||||
void JNICALL nativeSetReachability(JNIEnv* env, jobject obj, jlong native_map_view_ptr, jboolean status) {
|
||||
mbgl::Log::Debug(mbgl::Event::JNI, "nativeSetReachability");
|
||||
assert(native_map_view_ptr != 0);
|
||||
NativeMapView* native_map_view = reinterpret_cast<NativeMapView*>(native_map_view_ptr);
|
||||
native_map_view->getMap().setReachability(status);
|
||||
COFFEE_TRY_JNI(env, native_map_view->getMap().setReachability(status));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -645,7 +676,7 @@ extern "C" JNIEXPORT jint JNICALL JNI_OnLoad(JavaVM *vm, void *reserved) {
|
||||
|
||||
mbgl::Log::Debug(mbgl::Event::JNI, "JNI_OnLoad");
|
||||
|
||||
JNIEnv* env = nullptr;
|
||||
JNIEnv* env = nullptr;
|
||||
jint ret = vm->GetEnv(reinterpret_cast<void**>(&env), JNI_VERSION_1_6);
|
||||
if (ret != JNI_OK) {
|
||||
mbgl::Log::Error(mbgl::Event::JNI, "GetEnv() failed with %i", ret);
|
||||
|
||||
@@ -329,7 +329,7 @@ bool NativeMapView::createSurface(ANativeWindow* window_) {
|
||||
log_gl_string(GL_SHADING_LANGUAGE_VERSION, "SL Version"); // In the emulator this returns NULL with error code 0? https://code.google.com/p/android/issues/detail?id=78977
|
||||
log_gl_string(GL_EXTENSIONS, "Extensions");
|
||||
|
||||
loadExtensions();
|
||||
loadExtensions();
|
||||
|
||||
if (!eglMakeCurrent(display, EGL_NO_SURFACE, EGL_NO_SURFACE,
|
||||
EGL_NO_CONTEXT)) {
|
||||
@@ -449,7 +449,7 @@ EGLConfig NativeMapView::chooseConfig(const EGLConfig configs[],
|
||||
eglGetError());
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
||||
mbgl::Log::Info(mbgl::Event::OpenGL, "Caveat: %d", caveat);
|
||||
mbgl::Log::Info(mbgl::Event::OpenGL, "Conformant: %d", conformant);
|
||||
mbgl::Log::Info(mbgl::Event::OpenGL, "Color: %d", bits);
|
||||
@@ -508,7 +508,7 @@ void NativeMapView::start() {
|
||||
|
||||
assert(display != EGL_NO_DISPLAY);
|
||||
assert(context != EGL_NO_CONTEXT);
|
||||
|
||||
|
||||
map.start(true);
|
||||
}
|
||||
|
||||
@@ -520,7 +520,7 @@ void NativeMapView::loadExtensions() {
|
||||
}
|
||||
|
||||
std::string extensions(reinterpret_cast<const char*>(str));
|
||||
|
||||
|
||||
if (extensions.find("GL_OES_vertex_array_object") != std::string::npos) {
|
||||
mbgl::Log::Info(mbgl::Event::OpenGL, "Using GL_OES_vertex_array_object.");
|
||||
gl::BindVertexArray = (gl::PFNGLBINDVERTEXARRAYPROC)eglGetProcAddress("glBindVertexArrayOES");
|
||||
@@ -543,7 +543,7 @@ void NativeMapView::stop() {
|
||||
|
||||
assert(display != EGL_NO_DISPLAY);
|
||||
assert(context != EGL_NO_CONTEXT);
|
||||
|
||||
|
||||
map.stop();
|
||||
}
|
||||
|
||||
@@ -553,7 +553,7 @@ void NativeMapView::pause(bool wait_for_pause) {
|
||||
|
||||
assert(display != EGL_NO_DISPLAY);
|
||||
assert(context != EGL_NO_CONTEXT);
|
||||
|
||||
|
||||
map.pause(wait_for_pause);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user