summaryrefslogtreecommitdiff
path: root/include/mbgl/renderer
diff options
context:
space:
mode:
Diffstat (limited to 'include/mbgl/renderer')
-rw-r--r--include/mbgl/renderer/query.hpp43
-rw-r--r--include/mbgl/renderer/renderer.hpp54
-rw-r--r--include/mbgl/renderer/renderer_frontend.hpp31
3 files changed, 128 insertions, 0 deletions
diff --git a/include/mbgl/renderer/query.hpp b/include/mbgl/renderer/query.hpp
new file mode 100644
index 0000000000..b9d5f21a44
--- /dev/null
+++ b/include/mbgl/renderer/query.hpp
@@ -0,0 +1,43 @@
+#pragma once
+
+#include <mbgl/util/optional.hpp>
+#include <mbgl/style/filter.hpp>
+
+#include <string>
+#include <vector>
+
+namespace mbgl {
+
+/**
+ * Options for query rendered features.
+ */
+class RenderedQueryOptions {
+public:
+ RenderedQueryOptions(optional<std::vector<std::string>> layerIDs_ = optional<std::vector<std::string>>(),
+ optional<style::Filter> filter_ = optional<style::Filter>())
+ : layerIDs(std::move(layerIDs_)),
+ filter(std::move(filter_)) {}
+
+ /** layerIDs to include in the query */
+ optional<std::vector<std::string>> layerIDs;
+
+ optional<style::Filter> filter;
+};
+
+/**
+ * Options for query source features
+ */
+class SourceQueryOptions {
+public:
+ SourceQueryOptions(optional<std::vector<std::string>> sourceLayers_ = optional<std::vector<std::string>> (),
+ optional<style::Filter> filter_ = optional<style::Filter>())
+ : sourceLayers(std::move(sourceLayers_)),
+ filter(std::move(filter_)) {}
+
+ // Required for VectorSource, ignored for GeoJSONSource
+ optional<std::vector<std::string>> sourceLayers;
+
+ optional<style::Filter> filter;
+};
+
+} // namespace mbgl
diff --git a/include/mbgl/renderer/renderer.hpp b/include/mbgl/renderer/renderer.hpp
new file mode 100644
index 0000000000..6626f74d3d
--- /dev/null
+++ b/include/mbgl/renderer/renderer.hpp
@@ -0,0 +1,54 @@
+#pragma once
+
+#include <mbgl/map/mode.hpp>
+#include <mbgl/renderer/query.hpp>
+#include <mbgl/annotation/annotation.hpp>
+#include <mbgl/util/geo.hpp>
+#include <mbgl/util/geo.hpp>
+
+#include <functional>
+#include <memory>
+#include <string>
+#include <vector>
+
+namespace mbgl {
+
+class Backend;
+class FileSource;
+class RendererObserver;
+class RenderedQueryOptions;
+class Scheduler;
+class SourceQueryOptions;
+class UpdateParameters;
+class View;
+
+class Renderer {
+public:
+ Renderer(Backend&, float pixelRatio_, FileSource&, Scheduler&,
+ GLContextMode = GLContextMode::Unique,
+ const optional<std::string> programCacheDir = optional<std::string>());
+ ~Renderer();
+
+ void setObserver(RendererObserver*);
+
+ void render(View& view, const UpdateParameters&);
+
+ // Feature queries
+ std::vector<Feature> queryRenderedFeatures(const ScreenLineString&, const RenderedQueryOptions& options = {}) const;
+ std::vector<Feature> queryRenderedFeatures(const ScreenCoordinate& point, const RenderedQueryOptions& options = {}) const;
+ std::vector<Feature> queryRenderedFeatures(const ScreenBox& box, const RenderedQueryOptions& options = {}) const;
+ std::vector<Feature> querySourceFeatures(const std::string& sourceID, const SourceQueryOptions& options = {}) const;
+ AnnotationIDs queryPointAnnotations(const ScreenBox& box) const;
+
+ // Debug
+ void dumpDebugLogs();
+
+ // Memory
+ void onLowMemory();
+
+private:
+ class Impl;
+ std::unique_ptr<Impl> impl;
+};
+
+} // namespace mbgl
diff --git a/include/mbgl/renderer/renderer_frontend.hpp b/include/mbgl/renderer/renderer_frontend.hpp
new file mode 100644
index 0000000000..f72b0ccdde
--- /dev/null
+++ b/include/mbgl/renderer/renderer_frontend.hpp
@@ -0,0 +1,31 @@
+#pragma once
+
+#include <memory>
+
+namespace mbgl {
+
+class RendererObserver;
+class UpdateParameters;
+
+// The RenderFrontend is the bridge between the Map and
+// platform used to update and observer the Renderer
+//
+// It hides any threading specifics and always replies on
+// the original thread.
+class RendererFrontend {
+public:
+
+ virtual ~RendererFrontend() = default;
+
+ // Must synchronously clean up the Renderer if set
+ virtual void reset() = 0;
+
+ // Implementer must bind the renderer observer to the renderer in a
+ // appropriate manner so that the callbacks occur on the main thread
+ virtual void setObserver(RendererObserver&) = 0;
+
+ // Coalescing updates is up to the implementer
+ virtual void update(std::shared_ptr<UpdateParameters>) = 0;
+};
+
+} // namespace mbgl