From 6fb2a94c5e1be320cc88bf9ed822fbd297223c4b Mon Sep 17 00:00:00 2001 From: Julian Rex Date: Mon, 5 Mar 2018 13:15:20 -0500 Subject: [ios, macos, core] Added retain/release manager that holds on to the MGLOpenGLStyleLayers for the 2 trips through the render loop that are needed before they can be deallocated. Added additional tests. --- src/mbgl/style/layers/custom_layer.cpp | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/mbgl/style/layers/custom_layer.cpp b/src/mbgl/style/layers/custom_layer.cpp index 854c771847..40013f3422 100644 --- a/src/mbgl/style/layers/custom_layer.cpp +++ b/src/mbgl/style/layers/custom_layer.cpp @@ -10,19 +10,27 @@ CustomLayer::CustomLayer(const std::string& layerID, CustomLayerRenderFunction render, CustomLayerContextLostFunction contextLost, CustomLayerDeinitializeFunction deinit, + CustomLayerDeallocationFunction deallocation, void* context) - : Layer(makeMutable(layerID, init, render, contextLost, deinit, context)) { + : Layer(makeMutable(layerID, init, render, contextLost, deinit, context)), + deallocationFn(deallocation) { } CustomLayer::CustomLayer(const std::string& layerID, CustomLayerInitializeFunction init, CustomLayerRenderFunction render, CustomLayerDeinitializeFunction deinit, + CustomLayerDeallocationFunction deallocation, void* context) - : Layer(makeMutable(layerID, init, render, nullptr, deinit, context)) { + : Layer(makeMutable(layerID, init, render, nullptr, deinit, context)), + deallocationFn(deallocation) { } -CustomLayer::~CustomLayer() = default; +CustomLayer::~CustomLayer() { + if (deallocationFn) { + deallocationFn(&peer); + } +}; const CustomLayer::Impl& CustomLayer::impl() const { return static_cast(*baseImpl); -- cgit v1.2.1