From 97a010cc9bde2eaa2cc94ca844fe9546347d37c2 Mon Sep 17 00:00:00 2001 From: Ivo van Dongen Date: Tue, 19 Sep 2017 10:29:51 +0300 Subject: [core] custom layer - add contextLost callback - optional callback method that can be used to do cleanup when the context has been lost before re-initialisation --- include/mbgl/style/layers/custom_layer.hpp | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'include/mbgl') diff --git a/include/mbgl/style/layers/custom_layer.hpp b/include/mbgl/style/layers/custom_layer.hpp index 79a353b047..bf3387f95b 100644 --- a/include/mbgl/style/layers/custom_layer.hpp +++ b/include/mbgl/style/layers/custom_layer.hpp @@ -38,6 +38,14 @@ struct CustomLayerRenderParameters { */ using CustomLayerRenderFunction = void (*)(void* context, const CustomLayerRenderParameters&); +/** + * Called when the system has destroyed the underlying GL context. The + * `CustomLayerDeinitializeFunction` will not be called in this case, however + * `CustomLayerInitializeFunction` will be called instead to prepare for a new render. + * + */ +using CustomLayerContextLostFunction = void (*)(void* context); + /** * Destroy any GL state needed by the custom layer, and deallocate context, if necessary. This * method is called once, from the main thread, at a point when the GL context is active. @@ -51,8 +59,16 @@ public: CustomLayer(const std::string& id, CustomLayerInitializeFunction, CustomLayerRenderFunction, + CustomLayerContextLostFunction, CustomLayerDeinitializeFunction, void* context); + + CustomLayer(const std::string& id, + CustomLayerInitializeFunction, + CustomLayerRenderFunction, + CustomLayerDeinitializeFunction, + void* context); + ~CustomLayer() final; // Visibility -- cgit v1.2.1