summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorJohn Firebaugh <john.firebaugh@gmail.com>2016-04-25 13:14:34 -0700
committerJohn Firebaugh <john.firebaugh@gmail.com>2016-06-02 14:51:39 -0700
commitd7e1ecd19e321afaba631f9365b31e0a728a61c3 (patch)
treef3a91c82c42151d43a88330da0d00f02857456b4 /include
parenta43940afb2208c61b487bfd8729bbde1bd674794 (diff)
downloadqtlocation-mapboxgl-d7e1ecd19e321afaba631f9365b31e0a728a61c3.tar.gz
[core] Generalize Map::{add,remove}CustomLayer
Diffstat (limited to 'include')
-rw-r--r--include/mbgl/layer/custom_layer.hpp39
-rw-r--r--include/mbgl/map/map.hpp11
-rw-r--r--include/mbgl/map/view.hpp4
-rw-r--r--include/mbgl/style/types.hpp39
4 files changed, 44 insertions, 49 deletions
diff --git a/include/mbgl/layer/custom_layer.hpp b/include/mbgl/layer/custom_layer.hpp
index 81e91ddf50..9782d9593f 100644
--- a/include/mbgl/layer/custom_layer.hpp
+++ b/include/mbgl/layer/custom_layer.hpp
@@ -4,6 +4,45 @@
namespace mbgl {
+/**
+ * Initialize any GL state needed by the custom layer. This method is called once, from the
+ * rendering thread, at a point when the GL context is active but before rendering for the
+ * first time.
+ *
+ * Resources that are acquired in this method must be released in the UninitializeFunction.
+ */
+using CustomLayerInitializeFunction = void (*)(void* context);
+
+/**
+ * Parameters that define the current camera position for a CustomLayerRenderFunction.
+ */
+struct CustomLayerRenderParameters {
+ double width;
+ double height;
+ double latitude;
+ double longitude;
+ double zoom;
+ double bearing;
+ double pitch;
+ double altitude;
+};
+
+/**
+ * Render the layer. This method is called once per frame. The implementation should not make
+ * any assumptions about the GL state (other than that the correct context is active). It may
+ * make changes to the state, and is not required to reset values such as the depth mask, stencil
+ * mask, and corresponding test flags to their original values.
+ */
+using CustomLayerRenderFunction = void (*)(void* context, const CustomLayerRenderParameters&);
+
+/**
+ * Destroy any GL state needed by the custom layer, and deallocate context, if necessary. This
+ * method is called once, from the rendering thread, at a point when the GL context is active.
+ *
+ * Note that it may be called even when the InitializeFunction has not been called.
+ */
+using CustomLayerDeinitializeFunction = void (*)(void* context);
+
class CustomLayer : public Layer {
public:
CustomLayer(const std::string& id,
diff --git a/include/mbgl/map/map.hpp b/include/mbgl/map/map.hpp
index a728e2dd62..aadfdf9ada 100644
--- a/include/mbgl/map/map.hpp
+++ b/include/mbgl/map/map.hpp
@@ -9,7 +9,6 @@
#include <mbgl/util/feature.hpp>
#include <mbgl/util/noncopyable.hpp>
#include <mbgl/annotation/annotation.hpp>
-#include <mbgl/style/types.hpp>
#include <mbgl/style/property_transition.hpp>
#include <cstdint>
@@ -23,6 +22,7 @@ namespace mbgl {
class FileSource;
class View;
class SpriteImage;
+class Layer;
struct CameraOptions;
struct AnimationOptions;
@@ -146,13 +146,8 @@ public:
AnnotationIDs getPointAnnotationsInBounds(const LatLngBounds&);
- void addCustomLayer(const std::string& id,
- CustomLayerInitializeFunction,
- CustomLayerRenderFunction,
- CustomLayerDeinitializeFunction,
- void* context,
- const char* before = nullptr);
- void removeCustomLayer(const std::string& id);
+ void addLayer(std::unique_ptr<Layer>, const optional<std::string>& beforeLayerID = {});
+ void removeLayer(const std::string& layerID);
// Feature queries
std::vector<Feature> queryRenderedFeatures(const ScreenCoordinate&, const optional<std::vector<std::string>>& layerIDs = {});
diff --git a/include/mbgl/map/view.hpp b/include/mbgl/map/view.hpp
index 4431e2b33c..9f12ee5fb6 100644
--- a/include/mbgl/map/view.hpp
+++ b/include/mbgl/map/view.hpp
@@ -36,8 +36,8 @@ public:
// as a matched pair, in four situations:
//
// 1. When releasing GL resources during Map destruction
- // 2. When calling a CustomLayerInitializeFunction, during Map::addCustomLayer
- // 3. When calling a CustomLayerDeinitializeFunction, during Map::removeCustomLayer
+ // 2. When calling a CustomLayerInitializeFunction, during Map::addLayer
+ // 3. When calling a CustomLayerDeinitializeFunction, during Map::removeLayer
// 4. When rendering for Map::renderStill
//
// They are *not* called for Map::render; it is assumed that the correct context is already
diff --git a/include/mbgl/style/types.hpp b/include/mbgl/style/types.hpp
index a852a09a14..ea09ccfb0c 100644
--- a/include/mbgl/style/types.hpp
+++ b/include/mbgl/style/types.hpp
@@ -125,44 +125,5 @@ enum class TextTransformType : uint8_t {
Lowercase,
};
-/**
- * Initialize any GL state needed by the custom layer. This method is called once, from the
- * rendering thread, at a point when the GL context is active but before rendering for the
- * first time.
- *
- * Resources that are acquired in this method must be released in the UninitializeFunction.
- */
-using CustomLayerInitializeFunction = void (*)(void* context);
-
-/**
- * Parameters that define the current camera position for a CustomLayerRenderFunction.
- */
-struct CustomLayerRenderParameters {
- double width;
- double height;
- double latitude;
- double longitude;
- double zoom;
- double bearing;
- double pitch;
- double altitude;
-};
-
-/**
- * Render the layer. This method is called once per frame. The implementation should not make
- * any assumptions about the GL state (other than that the correct context is active). It may
- * make changes to the state, and is not required to reset values such as the depth mask, stencil
- * mask, and corresponding test flags to their original values.
- */
-using CustomLayerRenderFunction = void (*)(void* context, const CustomLayerRenderParameters&);
-
-/**
- * Destroy any GL state needed by the custom layer, and deallocate context, if necessary. This
- * method is called once, from the rendering thread, at a point when the GL context is active.
- *
- * Note that it may be called even when the InitializeFunction has not been called.
- */
-using CustomLayerDeinitializeFunction = void (*)(void* context);
-
} // namespace mbgl