diff options
author | Asheem Mamoowala <asheem.mamoowala@mapbox.com> | 2017-11-13 16:06:26 -0800 |
---|---|---|
committer | Asheem Mamoowala <asheem.mamoowala@mapbox.com> | 2017-11-22 13:56:38 -0800 |
commit | f06ebcc96791838acb485fc37877725a443ca8f5 (patch) | |
tree | 54b32821974703a3fae30ee86668bba4115f06e9 /platform/android/src/style/sources/sources.cpp | |
parent | 3067b77c650f5dea0c00a7a92a9fc927e028c742 (diff) | |
download | qtlocation-mapboxgl-f06ebcc96791838acb485fc37877725a443ca8f5.tar.gz |
[android] Reuse Java Source objects by holding on to a strong reference in the C++ peer.
Diffstat (limited to 'platform/android/src/style/sources/sources.cpp')
-rw-r--r-- | platform/android/src/style/sources/sources.cpp | 62 |
1 files changed, 0 insertions, 62 deletions
diff --git a/platform/android/src/style/sources/sources.cpp b/platform/android/src/style/sources/sources.cpp deleted file mode 100644 index 72d7bcda8c..0000000000 --- a/platform/android/src/style/sources/sources.cpp +++ /dev/null @@ -1,62 +0,0 @@ -#include "sources.hpp" - -#include <mbgl/style/source.hpp> -#include <mbgl/style/sources/geojson_source.hpp> -#include <mbgl/style/sources/image_source.hpp> -#include <mbgl/style/sources/raster_source.hpp> -#include <mbgl/style/sources/vector_source.hpp> - -#include "source.hpp" -#include "geojson_source.hpp" -#include "image_source.hpp" -#include "raster_source.hpp" -#include "unknown_source.hpp" -#include "vector_source.hpp" -#include "custom_geometry_source.hpp" - -namespace { - - using namespace mbgl::android; - - Source* initializeSourcePeer(mbgl::style::Source& coreSource) { - Source* source; - if (coreSource.is<mbgl::style::VectorSource>()) { - source = new VectorSource(*coreSource.as<mbgl::style::VectorSource>()); - } else if (coreSource.is<mbgl::style::RasterSource>()) { - source = new RasterSource(*coreSource.as<mbgl::style::RasterSource>()); - } else if (coreSource.is<mbgl::style::GeoJSONSource>()) { - source = new GeoJSONSource(*coreSource.as<mbgl::style::GeoJSONSource>()); - } else if (coreSource.is<mbgl::style::ImageSource>()) { - source = new ImageSource(*coreSource.as<mbgl::style::ImageSource>()); - } else { - source = new UnknownSource(coreSource); - } - - return source; - } -} // namespace - -namespace mbgl { -namespace android { - - -jni::jobject* createJavaSourcePeer(jni::JNIEnv& env, AndroidRendererFrontend& frontend, mbgl::style::Source& coreSource) { - std::unique_ptr<Source> peerSource = std::unique_ptr<Source>(initializeSourcePeer(coreSource)); - peerSource->setRendererFrontend(frontend); - jni::jobject* result = peerSource->createJavaPeer(env); - peerSource.release(); - return result; -} - -void registerNativeSources(jni::JNIEnv& env) { - Source::registerNative(env); - GeoJSONSource::registerNative(env); - ImageSource::registerNative(env); - RasterSource::registerNative(env); - UnknownSource::registerNative(env); - VectorSource::registerNative(env); - CustomGeometrySource::registerNative(env); -} - -} -} |