MCPcopy Create free account
hub / github.com/comaps/comaps / MapResource

Method MapResource

libs/drape/font_texture.cpp:110–150  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

108}
109
110ref_ptr<Texture::ResourceInfo> GlyphIndex::MapResource(GlyphFontAndId const & key, bool & newResource)
111{
112 newResource = false;
113 if (auto const found = m_index.find(key); found != m_index.end())
114 return make_ref(&found->second);
115
116 newResource = true;
117
118 constexpr bool kUseSdf = true;
119 GlyphImage glyphImage = m_mng->GetGlyphImage(key, dp::kBaseFontSizePixels, kUseSdf);
120 m2::RectU r;
121 if (!m_packer.PackGlyph(glyphImage.m_width, glyphImage.m_height, r))
122 {
123 glyphImage.Destroy();
124
125 LOG(LWARNING, ("Glyphs packer could not pack a glyph with fontIndex =", key.m_fontIndex, "glyphId =", key.m_glyphId,
126 "w =", glyphImage.m_width, "h =", glyphImage.m_height, "packerSize =", m_packer.GetSize()));
127
128 // TODO(AB): Is it a valid invalid glyph?
129 GlyphFontAndId constexpr kInvalidGlyphKey{0, 0};
130 if (auto const found = m_index.find(kInvalidGlyphKey); found != m_index.end())
131 {
132 newResource = false;
133 return make_ref(&found->second);
134 }
135
136 LOG(LERROR, ("Invalid glyph was not found in the index"));
137
138 return nullptr;
139 }
140
141 auto res = m_index.emplace(key, GlyphInfo{m_packer.MapTextureCoords(r)});
142 ASSERT(res.second, ());
143
144 {
145 std::lock_guard lock(m_mutex);
146 m_pendingNodes.emplace_back(r, Glyph{std::move(glyphImage), key});
147 }
148
149 return make_ref(&res.first->second);
150}
151
152bool GlyphIndex::CanBeGlyphPacked(uint32_t glyphsCount) const
153{

Callers 2

ShapeSingleTextLineMethod · 0.45
FindResourceMethod · 0.45

Calls 11

make_refFunction · 0.85
ASSERTFunction · 0.85
PackGlyphMethod · 0.80
findMethod · 0.45
endMethod · 0.45
GetGlyphImageMethod · 0.45
DestroyMethod · 0.45
GetSizeMethod · 0.45
emplaceMethod · 0.45
MapTextureCoordsMethod · 0.45
emplace_backMethod · 0.45

Tested by

no test coverage detected