[android] Reuse Java Source objects by holding on to a strong reference in the C++ peer.
This commit is contained in:
@@ -30,8 +30,10 @@ namespace android {
|
||||
) {
|
||||
}
|
||||
|
||||
VectorSource::VectorSource(mbgl::style::VectorSource& coreSource)
|
||||
: Source(coreSource) {
|
||||
VectorSource::VectorSource(jni::JNIEnv& env,
|
||||
mbgl::style::Source& coreSource,
|
||||
AndroidRendererFrontend& frontend)
|
||||
: Source(env, coreSource, createJavaPeer(env), frontend) {
|
||||
}
|
||||
|
||||
VectorSource::~VectorSource() = default;
|
||||
@@ -56,9 +58,9 @@ namespace android {
|
||||
|
||||
jni::Class<VectorSource> VectorSource::javaClass;
|
||||
|
||||
jni::jobject* VectorSource::createJavaPeer(jni::JNIEnv& env) {
|
||||
jni::Object<Source> VectorSource::createJavaPeer(jni::JNIEnv& env) {
|
||||
static auto constructor = VectorSource::javaClass.template GetConstructor<jni::jlong>(env);
|
||||
return VectorSource::javaClass.New(env, constructor, reinterpret_cast<jni::jlong>(this));
|
||||
return jni::Object<Source>(VectorSource::javaClass.New(env, constructor, reinterpret_cast<jni::jlong>(this)).Get());
|
||||
}
|
||||
|
||||
void VectorSource::registerNative(jni::JNIEnv& env) {
|
||||
|
||||
Reference in New Issue
Block a user