diff options
author | Julian Rex <julian.rex@mapbox.com> | 2018-03-05 13:15:20 -0500 |
---|---|---|
committer | Julian Rex <julian.rex@mapbox.com> | 2018-03-05 13:16:02 -0500 |
commit | 6fb2a94c5e1be320cc88bf9ed822fbd297223c4b (patch) | |
tree | 2c87aa4638883272223bffcc9859251c1b9ffbb4 /src | |
parent | ad323ded0cd2ae4e0987ee8a783f1bb65435f4b8 (diff) | |
download | qtlocation-mapboxgl-6fb2a94c5e1be320cc88bf9ed822fbd297223c4b.tar.gz |
[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.
Diffstat (limited to 'src')
-rw-r--r-- | src/mbgl/style/layers/custom_layer.cpp | 14 |
1 files changed, 11 insertions, 3 deletions
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<Impl>(layerID, init, render, contextLost, deinit, context)) { + : Layer(makeMutable<Impl>(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<Impl>(layerID, init, render, nullptr, deinit, context)) { + : Layer(makeMutable<Impl>(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<const Impl&>(*baseImpl); |