[core] Reduce custom layer API to lowest common denominator
This commit is contained in:
@@ -9,6 +9,7 @@
|
||||
#include <mbgl/util/noncopyable.hpp>
|
||||
#include <mbgl/util/vec.hpp>
|
||||
#include <mbgl/annotation/annotation.hpp>
|
||||
#include <mbgl/style/types.hpp>
|
||||
|
||||
#include <cstdint>
|
||||
#include <string>
|
||||
@@ -27,7 +28,6 @@ class Transform;
|
||||
class PointAnnotation;
|
||||
class ShapeAnnotation;
|
||||
struct CameraOptions;
|
||||
class StyleLayer;
|
||||
|
||||
namespace util {
|
||||
template <class T> class Thread;
|
||||
@@ -164,9 +164,12 @@ public:
|
||||
AnnotationIDs getPointAnnotationsInBounds(const LatLngBounds&);
|
||||
LatLngBounds getBoundsForAnnotations(const AnnotationIDs&);
|
||||
|
||||
// Style API
|
||||
void addLayer(std::unique_ptr<StyleLayer>);
|
||||
void addLayer(std::unique_ptr<StyleLayer>, const std::string& before);
|
||||
void addCustomLayer(const std::string& id,
|
||||
CustomLayerInitializeFunction,
|
||||
CustomLayerRenderFunction,
|
||||
CustomLayerDeinitializeFunction,
|
||||
void* context,
|
||||
const char* before = nullptr);
|
||||
|
||||
// Memory
|
||||
void setSourceTileCacheSize(size_t);
|
||||
|
||||
@@ -189,6 +189,45 @@ MBGL_DEFINE_ENUM_CLASS(TextTransformTypeClass, TextTransformType, {
|
||||
{ TextTransformType::Lowercase, "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
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user