| 169 | } |
| 170 | |
| 171 | void GlyphIndex::UploadResources(ref_ptr<GraphicsContext> context, ref_ptr<Texture> texture) |
| 172 | { |
| 173 | PendingNodes pendingNodes; |
| 174 | { |
| 175 | std::lock_guard lock(m_mutex); |
| 176 | if (m_pendingNodes.empty()) |
| 177 | return; |
| 178 | m_pendingNodes.swap(pendingNodes); |
| 179 | } |
| 180 | |
| 181 | for (auto it = pendingNodes.begin(); it != pendingNodes.end();) |
| 182 | { |
| 183 | // TODO(AB): Is it possible to mark and check if there is no image before uploading? |
| 184 | m_mng->MarkGlyphReady(it->second.m_key); |
| 185 | |
| 186 | if (it->second.m_image.m_data) |
| 187 | ++it; |
| 188 | else |
| 189 | it = pendingNodes.erase(it); |
| 190 | } |
| 191 | |
| 192 | if (pendingNodes.empty()) |
| 193 | return; |
| 194 | |
| 195 | for (auto & [rect, glyph] : pendingNodes) |
| 196 | { |
| 197 | ASSERT(glyph.m_image.m_width != 0 && glyph.m_image.m_height != 0 && rect.SizeX() != 0 && rect.SizeY() != 0, ()); |
| 198 | ASSERT_EQUAL(glyph.m_image.m_width, rect.SizeX(), ()); |
| 199 | ASSERT_EQUAL(glyph.m_image.m_height, rect.SizeY(), ()); |
| 200 | |
| 201 | m2::PointU const zeroPoint = rect.LeftBottom(); |
| 202 | uint8_t * srcMemory = SharedBufferManager::GetRawPointer(glyph.m_image.m_data); |
| 203 | texture->UploadData(context, zeroPoint.x, zeroPoint.y, rect.SizeX(), rect.SizeY(), make_ref(srcMemory)); |
| 204 | |
| 205 | glyph.m_image.Destroy(); |
| 206 | } |
| 207 | } |
| 208 | } // namespace dp |