diff options
author | Ivo van Dongen <info@ivovandongen.nl> | 2017-06-27 17:04:09 -0700 |
---|---|---|
committer | Ivo van Dongen <ivovandongen@users.noreply.github.com> | 2017-07-18 10:45:12 +0200 |
commit | d68d8a7846ef0b4d06c31e0ed451b31354a7dec9 (patch) | |
tree | 8236d0ce48b0d90baab947e044ce3a61aa9a615b /platform/android | |
parent | b6d56ad634e2b3048e97bedd9f674aa4ec975453 (diff) | |
download | qtlocation-mapboxgl-d68d8a7846ef0b4d06c31e0ed451b31354a7dec9.tar.gz |
[android] rendering interface changes
Diffstat (limited to 'platform/android')
19 files changed, 229 insertions, 68 deletions
diff --git a/platform/android/config.cmake b/platform/android/config.cmake index 9fdbfa1b45..7b0c8d60f2 100644 --- a/platform/android/config.cmake +++ b/platform/android/config.cmake @@ -57,8 +57,6 @@ macro(mbgl_platform_core) PRIVATE platform/default/bidi.cpp PRIVATE platform/default/thread_local.cpp PRIVATE platform/default/utf.cpp - PRIVATE platform/default/mbgl/renderer/default_render_bridge.cpp - PRIVATE platform/default/mbgl/renderer/default_render_bridge.hpp # Image handling PRIVATE platform/default/png_writer.cpp @@ -73,6 +71,10 @@ macro(mbgl_platform_core) PRIVATE platform/default/mbgl/util/shared_thread_pool.hpp PRIVATE platform/default/mbgl/util/default_thread_pool.cpp PRIVATE platform/default/mbgl/util/default_thread_pool.hpp + + # Rendering + PRIVATE platform/android/src/android_renderer_frontend.cpp + PRIVATE platform/android/src/android_renderer_frontend.hpp ) target_include_directories(mbgl-core diff --git a/platform/android/src/android_renderer_frontend.cpp b/platform/android/src/android_renderer_frontend.cpp new file mode 100644 index 0000000000..acb1c74557 --- /dev/null +++ b/platform/android/src/android_renderer_frontend.cpp @@ -0,0 +1,70 @@ +#include "android_renderer_frontend.hpp" + +#include <mbgl/map/view.hpp> +#include <mbgl/renderer/renderer.hpp> + +namespace mbgl { +namespace android { + +AndroidRendererFrontend::AndroidRendererFrontend( + std::unique_ptr<Renderer> renderer_, + InvalidateCallback invalidate) + : renderer(std::move(renderer_)) + , asyncInvalidate([=, invalidate=std::move(invalidate)]() { + invalidate(); + }) { +} + +AndroidRendererFrontend::~AndroidRendererFrontend() = default; + +void AndroidRendererFrontend::reset() { + assert (renderer); + if (renderer) { + renderer.reset(); + } +} + +void AndroidRendererFrontend::setObserver(RendererObserver& observer) { + assert (renderer); + renderer->setObserver(&observer); +} + +void AndroidRendererFrontend::update(std::shared_ptr<UpdateParameters> params) { + updateParameters = std::move(params); + asyncInvalidate.send(); +} + +void AndroidRendererFrontend::render(View& view) { + assert (renderer); + if (!updateParameters) return; + + renderer->render(view, *updateParameters); +} + +void AndroidRendererFrontend::onLowMemory() { + assert (renderer); + renderer->onLowMemory(); +} + +std::vector<Feature> AndroidRendererFrontend::querySourceFeatures(const std::string& sourceID, + const SourceQueryOptions& options) const { + return renderer->querySourceFeatures(sourceID, options); +} + +std::vector<Feature> AndroidRendererFrontend::queryRenderedFeatures(const ScreenBox& box, + const RenderedQueryOptions& options) const { + return renderer->queryRenderedFeatures(box, options); +} + +std::vector<Feature> AndroidRendererFrontend::queryRenderedFeatures(const ScreenCoordinate& point, + const RenderedQueryOptions& options) const { + return renderer->queryRenderedFeatures(point, options); +} + +AnnotationIDs AndroidRendererFrontend::queryPointAnnotations(const ScreenBox& box) const { + return renderer->queryPointAnnotations(box); +} + +} // namespace android +} // namespace mbgl + diff --git a/platform/android/src/android_renderer_frontend.hpp b/platform/android/src/android_renderer_frontend.hpp new file mode 100644 index 0000000000..95513a7682 --- /dev/null +++ b/platform/android/src/android_renderer_frontend.hpp @@ -0,0 +1,51 @@ + +#pragma once + +#include <mbgl/annotation/annotation.hpp> +#include <mbgl/renderer/renderer_frontend.hpp> +#include <mbgl/util/async_task.hpp> +#include <mbgl/util/geo.hpp> + +#include <functional> +#include <memory> +#include <vector> + +namespace mbgl { + +class View; +class Renderer; +class View; +class RenderedQueryOptions; +class SourceQueryOptions; + +namespace android { + +class AndroidRendererFrontend : public RendererFrontend { +public: + using InvalidateCallback = std::function<void ()>; + AndroidRendererFrontend(std::unique_ptr<Renderer>, InvalidateCallback); + ~AndroidRendererFrontend() override; + + void reset() override; + void setObserver(RendererObserver&) override; + + void update(std::shared_ptr<UpdateParameters>) override; + void render(View& view); + + // Feature querying + std::vector<Feature> queryRenderedFeatures(const ScreenCoordinate&, const RenderedQueryOptions&) const; + std::vector<Feature> queryRenderedFeatures(const ScreenBox&, const RenderedQueryOptions&) const; + std::vector<Feature> querySourceFeatures(const std::string& sourceID, const SourceQueryOptions&) const; + AnnotationIDs queryPointAnnotations(const ScreenBox& box) const; + + // Memory + void onLowMemory(); + +private: + std::unique_ptr<Renderer> renderer; + std::shared_ptr<UpdateParameters> updateParameters; + util::AsyncTask asyncInvalidate; +}; + +} // namespace android +} // namespace mbgl diff --git a/platform/android/src/native_map_view.cpp b/platform/android/src/native_map_view.cpp index 986cc73f0b..5faad75d5d 100755 --- a/platform/android/src/native_map_view.cpp +++ b/platform/android/src/native_map_view.cpp @@ -28,6 +28,7 @@ #include <mbgl/style/style.hpp> #include <mbgl/style/image.hpp> #include <mbgl/style/filter.hpp> +#include <mbgl/renderer/renderer.hpp> // Java -> C++ conversion #include "style/android_conversion.hpp" @@ -42,6 +43,7 @@ #include "jni.hpp" #include "attach_env.hpp" +#include "android_renderer_frontend.hpp" #include "bitmap.hpp" #include "run_loop_impl.hpp" #include "java/util.hpp" @@ -67,12 +69,23 @@ NativeMapView::NativeMapView(jni::JNIEnv& _env, return; } + auto& fileSource = mbgl::android::FileSource::getDefaultFileSource(_env, jFileSource); + + // Create a renderer + auto renderer = std::make_unique<Renderer>(*this, pixelRatio, fileSource, *threadPool, + GLContextMode::Unique, + jni::Make<std::string>(_env, _programCacheDir)); + + // Create a renderer frontend + rendererFrontend = std::make_unique<AndroidRendererFrontend>(std::move(renderer), + [this] { this->invalidate(); }); + // Create the core map - map = std::make_unique<mbgl::Map>( - *this, *this, mbgl::Size{ static_cast<uint32_t>(width), static_cast<uint32_t>(height) }, - pixelRatio, mbgl::android::FileSource::getDefaultFileSource(_env, jFileSource), *threadPool, - MapMode::Continuous, GLContextMode::Unique, ConstrainMode::HeightOnly, - ViewportMode::Default, jni::Make<std::string>(_env, _programCacheDir)); + map = std::make_unique<mbgl::Map>(*rendererFrontend, *this, + mbgl::Size{ static_cast<uint32_t>(width), + static_cast<uint32_t>(height) }, pixelRatio, + fileSource, *threadPool, MapMode::Continuous, + ConstrainMode::HeightOnly, ViewportMode::Default); } /** @@ -273,14 +286,14 @@ void NativeMapView::destroySurface(jni::JNIEnv&) { } void NativeMapView::render(jni::JNIEnv& env) { - BackendScope guard(*this); + BackendScope guard { *this }; if (framebufferSizeChanged) { setViewport(0, 0, getFramebufferSize()); framebufferSizeChanged = false; } - map->render(*this); + rendererFrontend->render(*this); if(snapshot){ snapshot = false; @@ -587,7 +600,7 @@ jni::Array<jni::jlong> NativeMapView::addMarkers(jni::JNIEnv& env, jni::Array<jn } void NativeMapView::onLowMemory(JNIEnv&) { - map->onLowMemory(); + rendererFrontend->onLowMemory(); } using DebugOptions = mbgl::MapDebugOptions; @@ -758,7 +771,7 @@ jni::Array<jlong> NativeMapView::queryPointAnnotations(JNIEnv& env, jni::Object< }; // Assume only points for now - mbgl::AnnotationIDs ids = map->queryPointAnnotations(box); + mbgl::AnnotationIDs ids = rendererFrontend->queryPointAnnotations(box); // Convert result std::vector<jlong> longIds(ids.begin(), ids.end()); @@ -780,7 +793,9 @@ jni::Array<jni::Object<geojson::Feature>> NativeMapView::queryRenderedFeaturesFo } mapbox::geometry::point<double> point = {x, y}; - return *convert<jni::Array<jni::Object<Feature>>, std::vector<mbgl::Feature>>(env, map->queryRenderedFeatures(point, { layers, toFilter(env, jfilter) })); + return *convert<jni::Array<jni::Object<Feature>>, std::vector<mbgl::Feature>>( + env, + rendererFrontend->queryRenderedFeatures(point, { layers, toFilter(env, jfilter) })); } jni::Array<jni::Object<geojson::Feature>> NativeMapView::queryRenderedFeaturesForBox(JNIEnv& env, jni::jfloat left, jni::jfloat top, @@ -798,7 +813,9 @@ jni::Array<jni::Object<geojson::Feature>> NativeMapView::queryRenderedFeaturesFo mapbox::geometry::point<double>{ right, bottom } }; - return *convert<jni::Array<jni::Object<Feature>>, std::vector<mbgl::Feature>>(env, map->queryRenderedFeatures(box, { layers, toFilter(env, jfilter) })); + return *convert<jni::Array<jni::Object<Feature>>, std::vector<mbgl::Feature>>( + env, + rendererFrontend->queryRenderedFeatures(box, { layers, toFilter(env, jfilter) })); } jni::Object<Light> NativeMapView::getLight(JNIEnv& env) { @@ -966,7 +983,7 @@ jni::Array<jni::Object<Source>> NativeMapView::getSources(JNIEnv& env) { jni::Array<jni::Object<Source>> jSources = jni::Array<jni::Object<Source>>::New(env, sources.size(), Source::javaClass); int index = 0; for (auto source : sources) { - auto jSource = jni::Object<Source>(createJavaSourcePeer(env, *map, *source)); + auto jSource = jni::Object<Source>(createJavaSourcePeer(env, *rendererFrontend, *source)); jSources.Set(env, index, jSource); jni::DeleteLocalRef(env, jSource); index++; @@ -984,7 +1001,7 @@ jni::Object<Source> NativeMapView::getSource(JNIEnv& env, jni::String sourceId) } // Create and return the source's native peer - return jni::Object<Source>(createJavaSourcePeer(env, *map, *coreSource)); + return jni::Object<Source>(createJavaSourcePeer(env, *rendererFrontend, *coreSource)); } void NativeMapView::addSource(JNIEnv& env, jni::jlong sourcePtr) { @@ -993,6 +1010,7 @@ void NativeMapView::addSource(JNIEnv& env, jni::jlong sourcePtr) { Source *source = reinterpret_cast<Source *>(sourcePtr); try { source->addToMap(*map); + source->setRendererFrontend(*rendererFrontend); } catch (const std::runtime_error& error) { jni::ThrowNew(env, jni::FindClass(env, "com/mapbox/mapboxsdk/style/sources/CannotAddSourceException"), error.what()); } @@ -1001,7 +1019,7 @@ void NativeMapView::addSource(JNIEnv& env, jni::jlong sourcePtr) { jni::Object<Source> NativeMapView::removeSourceById(JNIEnv& env, jni::String id) { std::unique_ptr<mbgl::style::Source> coreSource = map->getStyle().removeSource(jni::Make<std::string>(env, id)); if (coreSource) { - return jni::Object<Source>(createJavaSourcePeer(env, *map, *coreSource)); + return jni::Object<Source>(createJavaSourcePeer(env, *rendererFrontend, *coreSource)); } else { return jni::Object<Source>(); } diff --git a/platform/android/src/native_map_view.hpp b/platform/android/src/native_map_view.hpp index ed752f94ab..35d4c68a98 100755 --- a/platform/android/src/native_map_view.hpp +++ b/platform/android/src/native_map_view.hpp @@ -36,6 +36,8 @@ namespace mbgl { namespace android { +class AndroidRendererFrontend; + class NativeMapView : public View, public Backend, public MapObserver { public: @@ -60,7 +62,6 @@ public: // mbgl::Backend // void updateAssumedState() override; - void invalidate() override; // Deprecated // void notifyMapChange(mbgl::MapChange); @@ -79,6 +80,9 @@ public: void onDidFinishLoadingStyle() override; void onSourceChanged(mbgl::style::Source&) override; + // Signal the view system, we want to redraw + void invalidate(); + // JNI // void destroy(jni::JNIEnv&); @@ -288,6 +292,8 @@ private: void updateFps(); private: + std::unique_ptr<AndroidRendererFrontend> rendererFrontend; + JavaVM *vm = nullptr; jni::UniqueWeakObject<NativeMapView> javaPeer; diff --git a/platform/android/src/style/sources/geojson_source.cpp b/platform/android/src/style/sources/geojson_source.cpp index 780cc4b6f6..90ef851eba 100644 --- a/platform/android/src/style/sources/geojson_source.cpp +++ b/platform/android/src/style/sources/geojson_source.cpp @@ -1,5 +1,7 @@ #include "geojson_source.hpp" +#include <mbgl/renderer/query.hpp> + // Java -> C++ conversion #include "../android_conversion.hpp" #include "../conversion/filter.hpp" @@ -41,8 +43,8 @@ namespace android { ) { } - GeoJSONSource::GeoJSONSource(mbgl::Map& map, mbgl::style::GeoJSONSource& coreSource) - : Source(map, coreSource) { + GeoJSONSource::GeoJSONSource(mbgl::style::GeoJSONSource& coreSource) + : Source(coreSource) { } GeoJSONSource::~GeoJSONSource() = default; @@ -108,8 +110,8 @@ namespace android { using namespace mbgl::android::geojson; std::vector<mbgl::Feature> features; - if (map) { - features = map->querySourceFeatures(source.getID(), { {}, toFilter(env, jfilter) }); + if (rendererFrontend) { + features = rendererFrontend->querySourceFeatures(source.getID(), { {}, toFilter(env, jfilter) }); } return *convert<jni::Array<jni::Object<Feature>>, std::vector<mbgl::Feature>>(env, features); } diff --git a/platform/android/src/style/sources/geojson_source.hpp b/platform/android/src/style/sources/geojson_source.hpp index 938a20612c..52dd632bfa 100644 --- a/platform/android/src/style/sources/geojson_source.hpp +++ b/platform/android/src/style/sources/geojson_source.hpp @@ -21,7 +21,7 @@ public: GeoJSONSource(jni::JNIEnv&, jni::String, jni::Object<>); - GeoJSONSource(mbgl::Map&, mbgl::style::GeoJSONSource&); + GeoJSONSource(mbgl::style::GeoJSONSource&); ~GeoJSONSource(); diff --git a/platform/android/src/style/sources/image_source.cpp b/platform/android/src/style/sources/image_source.cpp index 9c37d63d4b..d46b367c53 100644 --- a/platform/android/src/style/sources/image_source.cpp +++ b/platform/android/src/style/sources/image_source.cpp @@ -23,8 +23,8 @@ namespace android { ) { } - ImageSource::ImageSource(mbgl::Map& map, mbgl::style::ImageSource& coreSource) - : Source(map, coreSource) { + ImageSource::ImageSource(mbgl::style::ImageSource& coreSource) + : Source(coreSource) { } ImageSource::~ImageSource() = default; diff --git a/platform/android/src/style/sources/image_source.hpp b/platform/android/src/style/sources/image_source.hpp index 309d17a299..9787a7294f 100644 --- a/platform/android/src/style/sources/image_source.hpp +++ b/platform/android/src/style/sources/image_source.hpp @@ -21,7 +21,7 @@ public: ImageSource(jni::JNIEnv&, jni::String, jni::Object<LatLngQuad>); - ImageSource(mbgl::Map&, mbgl::style::ImageSource&); + ImageSource(mbgl::style::ImageSource&); ~ImageSource(); diff --git a/platform/android/src/style/sources/raster_source.cpp b/platform/android/src/style/sources/raster_source.cpp index 32fdb163b0..d45342a1ad 100644 --- a/platform/android/src/style/sources/raster_source.cpp +++ b/platform/android/src/style/sources/raster_source.cpp @@ -22,8 +22,8 @@ namespace android { ) { } - RasterSource::RasterSource(mbgl::Map& map, mbgl::style::RasterSource& coreSource) - : Source(map, coreSource) { + RasterSource::RasterSource(mbgl::style::RasterSource& coreSource) + : Source(coreSource) { } RasterSource::~RasterSource() = default; diff --git a/platform/android/src/style/sources/raster_source.hpp b/platform/android/src/style/sources/raster_source.hpp index a79ccc10a4..84c49d7381 100644 --- a/platform/android/src/style/sources/raster_source.hpp +++ b/platform/android/src/style/sources/raster_source.hpp @@ -18,7 +18,7 @@ public: RasterSource(jni::JNIEnv&, jni::String, jni::Object<>, jni::jint); - RasterSource(mbgl::Map&, mbgl::style::RasterSource&); + RasterSource(mbgl::style::RasterSource&); ~RasterSource(); diff --git a/platform/android/src/style/sources/source.cpp b/platform/android/src/style/sources/source.cpp index 05f981953a..447b13019d 100644 --- a/platform/android/src/style/sources/source.cpp +++ b/platform/android/src/style/sources/source.cpp @@ -26,11 +26,11 @@ namespace android { , source(*ownedSource) { } - Source::Source(mbgl::Map& coreMap, mbgl::style::Source& coreSource) : source(coreSource) , map(&coreMap) { + Source::Source(mbgl::style::Source& coreSource) + : source(coreSource) { } - Source::~Source() { - } + Source::~Source() = default; style::Source& Source::get() { return source; @@ -57,9 +57,10 @@ namespace android { // Add source to map _map.getStyle().addSource(releaseCoreSource()); + } - // Save pointer to the map - this->map = &_map; + void Source::setRendererFrontend(AndroidRendererFrontend& frontend_) { + rendererFrontend = &frontend_; } std::unique_ptr<mbgl::style::Source> Source::releaseCoreSource() { diff --git a/platform/android/src/style/sources/source.hpp b/platform/android/src/style/sources/source.hpp index 49fc50d754..383017b66f 100644 --- a/platform/android/src/style/sources/source.hpp +++ b/platform/android/src/style/sources/source.hpp @@ -5,6 +5,7 @@ #include <mbgl/style/source.hpp> #include "../value.hpp" +#include "../../android_renderer_frontend.hpp" #include <jni/jni.hpp> @@ -23,7 +24,7 @@ public: /* * Called when a Java object is created on the c++ side */ - Source(mbgl::Map&, mbgl::style::Source&); + Source(mbgl::style::Source&); /* * Called when a Java object was created from the jvm side @@ -41,6 +42,8 @@ public: void addToMap(mbgl::Map&); + void setRendererFrontend(AndroidRendererFrontend&); + virtual jni::jobject* createJavaPeer(jni::JNIEnv&) = 0; jni::String getId(jni::JNIEnv&); @@ -57,8 +60,9 @@ protected: // Raw pointer that is valid until the source is removed from the map mbgl::style::Source& source; - // Map pointer is valid for newly created sources only after adding to the map - mbgl::Map* map; + // RendererFrontend pointer is valid only when + // added to the map + AndroidRendererFrontend* rendererFrontend; }; } // namespace android diff --git a/platform/android/src/style/sources/sources.cpp b/platform/android/src/style/sources/sources.cpp index 7ca6328e71..9ab3ca8e84 100644 --- a/platform/android/src/style/sources/sources.cpp +++ b/platform/android/src/style/sources/sources.cpp @@ -13,28 +13,35 @@ #include "unknown_source.hpp" #include "vector_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 { -Source* initializeSourcePeer(mbgl::Map& map, mbgl::style::Source& coreSource) { - Source* source; - if (coreSource.is<mbgl::style::VectorSource>()) { - source = new VectorSource(map, *coreSource.as<mbgl::style::VectorSource>()); - } else if (coreSource.is<mbgl::style::RasterSource>()) { - source = new RasterSource(map, *coreSource.as<mbgl::style::RasterSource>()); - } else if (coreSource.is<mbgl::style::GeoJSONSource>()) { - source = new GeoJSONSource(map, *coreSource.as<mbgl::style::GeoJSONSource>()); - } else if (coreSource.is<mbgl::style::ImageSource>()) { - source = new ImageSource(map, *coreSource.as<mbgl::style::ImageSource>()); - } else { - source = new UnknownSource(map, coreSource); - } - - return source; -} -jni::jobject* createJavaSourcePeer(jni::JNIEnv& env, mbgl::Map& map, mbgl::style::Source& coreSource) { - std::unique_ptr<Source> peerSource = std::unique_ptr<Source>(initializeSourcePeer(map, coreSource)); +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; diff --git a/platform/android/src/style/sources/sources.hpp b/platform/android/src/style/sources/sources.hpp index 09a8b35067..c7b36818b2 100644 --- a/platform/android/src/style/sources/sources.hpp +++ b/platform/android/src/style/sources/sources.hpp @@ -1,20 +1,18 @@ #pragma once -#include <mbgl/map/map.hpp> #include <mbgl/style/source.hpp> #include "source.hpp" +#include "../../android_renderer_frontend.hpp" #include <jni/jni.hpp> namespace mbgl { namespace android { - mbgl::android::Source* initializeSourcePeer(mbgl::Map&, mbgl::style::Source&); - - jni::jobject* createJavaSourcePeer(jni::JNIEnv&, mbgl::Map&, mbgl::style::Source&); + jni::jobject* createJavaSourcePeer(jni::JNIEnv&, AndroidRendererFrontend&, mbgl::style::Source&); void registerNativeSources(jni::JNIEnv&); -} -} +} // namespace android +} // namespace mbgl diff --git a/platform/android/src/style/sources/unknown_source.cpp b/platform/android/src/style/sources/unknown_source.cpp index 86736597c3..79f27bdfbf 100644 --- a/platform/android/src/style/sources/unknown_source.cpp +++ b/platform/android/src/style/sources/unknown_source.cpp @@ -12,8 +12,8 @@ namespace { namespace mbgl { namespace android { - UnknownSource::UnknownSource(mbgl::Map& map, mbgl::style::Source& coreSource) - : Source(map, coreSource) { + UnknownSource::UnknownSource(mbgl::style::Source& coreSource) + : Source(coreSource) { } jni::Class<UnknownSource> UnknownSource::javaClass; diff --git a/platform/android/src/style/sources/unknown_source.hpp b/platform/android/src/style/sources/unknown_source.hpp index 3c37239792..4a003c9a7f 100644 --- a/platform/android/src/style/sources/unknown_source.hpp +++ b/platform/android/src/style/sources/unknown_source.hpp @@ -16,7 +16,7 @@ public: static void registerNative(jni::JNIEnv&); - UnknownSource(mbgl::Map&, mbgl::style::Source&); + UnknownSource(mbgl::style::Source&); ~UnknownSource() = default; diff --git a/platform/android/src/style/sources/vector_source.cpp b/platform/android/src/style/sources/vector_source.cpp index e2d9f60dec..7fe45441bd 100644 --- a/platform/android/src/style/sources/vector_source.cpp +++ b/platform/android/src/style/sources/vector_source.cpp @@ -1,5 +1,7 @@ #include "vector_source.hpp" +#include <mbgl/renderer/query.hpp> + // Java -> C++ conversion #include "../android_conversion.hpp" #include "../conversion/filter.hpp" @@ -28,8 +30,8 @@ namespace android { ) { } - VectorSource::VectorSource(mbgl::Map& map, mbgl::style::VectorSource& coreSource) - : Source(map, coreSource) { + VectorSource::VectorSource(mbgl::style::VectorSource& coreSource) + : Source(coreSource) { } VectorSource::~VectorSource() = default; @@ -46,8 +48,8 @@ namespace android { using namespace mbgl::android::geojson; std::vector<mbgl::Feature> features; - if (map) { - features = map->querySourceFeatures(source.getID(), { toVector(env, jSourceLayerIds), toFilter(env, jfilter) }); + if (rendererFrontend) { + features = rendererFrontend->querySourceFeatures(source.getID(), { toVector(env, jSourceLayerIds), toFilter(env, jfilter) }); } return *convert<jni::Array<jni::Object<Feature>>, std::vector<mbgl::Feature>>(env, features); } diff --git a/platform/android/src/style/sources/vector_source.hpp b/platform/android/src/style/sources/vector_source.hpp index 643b468338..509fe068d1 100644 --- a/platform/android/src/style/sources/vector_source.hpp +++ b/platform/android/src/style/sources/vector_source.hpp @@ -19,7 +19,7 @@ public: VectorSource(jni::JNIEnv&, jni::String, jni::Object<>); - VectorSource(mbgl::Map&, mbgl::style::VectorSource&); + VectorSource(mbgl::style::VectorSource&); ~VectorSource(); |