diff --git a/drape/font_texture.cpp b/drape/font_texture.cpp index c42f61b8c4..41aaab9707 100644 --- a/drape/font_texture.cpp +++ b/drape/font_texture.cpp @@ -82,6 +82,18 @@ GlyphIndex::GlyphIndex(m2::PointU size, RefPointer mng) { } +GlyphIndex::~GlyphIndex() +{ + { + threads::MutexGuard g(m_lock); + for_each(m_pendingNodes.begin(), m_pendingNodes.end(), [](TPendingNode & node) + { + node.second.m_image.Destroy(); + }); + m_pendingNodes.clear(); + } +} + RefPointer GlyphIndex::MapResource(GlyphKey const & key, bool & newResource) { newResource = false; @@ -128,7 +140,6 @@ void GlyphIndex::UploadResources(RefPointer texture) for (size_t i = 1; i < pendingNodes.size(); ++i) { TPendingNode const & prevNode = pendingNodes[i - 1]; - maxHeight = max(maxHeight, prevNode.first.SizeY()); TPendingNode const & currentNode = pendingNodes[i]; if (ranges.size() < 2 && prevNode.first.minY() < currentNode.first.minY()) { @@ -136,6 +147,8 @@ void GlyphIndex::UploadResources(RefPointer texture) maxHeights.push_back(maxHeight); maxHeight = currentNode.first.SizeY(); } + + maxHeight = max(maxHeight, currentNode.first.SizeY()); } maxHeights.push_back(maxHeight); ranges.push_back(pendingNodes.size()); @@ -150,6 +163,10 @@ void GlyphIndex::UploadResources(RefPointer texture) uint32_t height = maxHeights[i - 1]; uint32_t width = pendingNodes[endIndex - 1].first.maxX() - pendingNodes[startIndex].first.minX(); uint32_t byteCount = my::NextPowOf2(height * width); + + if (byteCount == 0) + continue; + m2::PointU zeroPoint = pendingNodes[startIndex].first.LeftBottom(); SharedBufferManager::shared_buffer_ptr_t buffer = SharedBufferManager::instance().reserveSharedBuffer(byteCount); @@ -169,6 +186,7 @@ void GlyphIndex::UploadResources(RefPointer texture) ASSERT_EQUAL(glyph.m_image.m_width, w, ()); ASSERT_EQUAL(glyph.m_image.m_height, h, ()); + ASSERT_GREATER_OR_EQUAL(height, h, ()); view_t dstSubView = subimage_view(dstView, rect.minX(), rect.minY(), w, h); uint8_t * srcMemory = SharedBufferManager::GetRawPointer(glyph.m_image.m_data); diff --git a/drape/font_texture.hpp b/drape/font_texture.hpp index e67eedb9b1..178e8fa33b 100644 --- a/drape/font_texture.hpp +++ b/drape/font_texture.hpp @@ -61,6 +61,7 @@ class GlyphIndex { public: GlyphIndex(m2::PointU size, RefPointer mng); + ~GlyphIndex(); /// can return nullptr RefPointer MapResource(GlyphKey const & key, bool & newResource); diff --git a/drape/glyph_manager.hpp b/drape/glyph_manager.hpp index 9102c6c13e..f1fdfaf8ee 100644 --- a/drape/glyph_manager.hpp +++ b/drape/glyph_manager.hpp @@ -39,7 +39,7 @@ public: { ~GlyphImage() { - ASSERT(!m_data.unique(), ()); + ASSERT(!m_data.unique(), ("Probably you forgot to call Destroy()")); } void Destroy() diff --git a/drape_frontend/batchers_pool.cpp b/drape_frontend/batchers_pool.cpp index 14690cfacb..0c54cc60fe 100644 --- a/drape_frontend/batchers_pool.cpp +++ b/drape_frontend/batchers_pool.cpp @@ -32,7 +32,12 @@ BatchersPool::BatchersPool(int initBatcherCount, TSendMessageFn const & sendMess BatchersPool::~BatchersPool() { - ASSERT(m_batchs.empty(), ()); + for_each(m_batchs.begin(), m_batchs.end(), [this](pair const & p) + { + m_pool.Return(p.second.first); + }); + + m_batchs.clear(); } void BatchersPool::ReserveBatcher(TileKey const & key)