Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mapsme/omim.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorrachytski <siarhei.rachytski@gmail.com>2012-12-13 02:06:41 +0400
committerAlex Zolotarev <alex@maps.me>2015-09-23 01:47:54 +0300
commitc9c73043821a35f6dccef5edb3925edc70e81f1d (patch)
treeef18ae6215bda794aeee078fad0809c53b27e616 /graphics/text_element.cpp
parent34e4f3d51e1d5719766c6b35f49a7657a727f700 (diff)
caching rendered string as a whole on the texture.
Diffstat (limited to 'graphics/text_element.cpp')
-rw-r--r--graphics/text_element.cpp34
1 files changed, 28 insertions, 6 deletions
diff --git a/graphics/text_element.cpp b/graphics/text_element.cpp
index 2c8fdab4e1..a68e5222ec 100644
--- a/graphics/text_element.cpp
+++ b/graphics/text_element.cpp
@@ -99,16 +99,38 @@ namespace graphics
deltaA = (ang::AngleD(0) * m).val();
}
- for (unsigned i = layout.firstVisible(); i < layout.lastVisible(); ++i)
+ size_t cnt = layout.entries().size();
+
+ buffer_vector<Glyph::Info, 32> glyphInfos(cnt);
+ buffer_vector<Resource::Info const *, 32> resInfos(cnt);
+ buffer_vector<uint32_t, 32> glyphIDs(cnt);
+
+ unsigned firstVis = layout.firstVisible();
+ unsigned lastVis = layout.lastVisible();
+
+ /// collecting all glyph infos in one array and packing them as a whole.
+ for (unsigned i = firstVis; i < lastVis; ++i)
{
- Skin * skin = screen->skin().get();
- GlyphLayoutElem const & elem = layout.entries()[i];
- GlyphKey glyphKey(elem.m_sym,
+ GlyphKey glyphKey(layout.entries()[i].m_sym,
fontDesc.m_size,
fontDesc.m_isMasked,
fontDesc.m_isMasked ? fontDesc.m_maskColor : fontDesc.m_color);
- uint32_t const glyphID = skin->map(Glyph::Info(glyphKey, screen->glyphCache()));
- Glyph const * glyph = static_cast<Glyph const *>(skin->fromID(glyphID));
+
+ glyphInfos[i] = Glyph::Info(glyphKey, screen->glyphCache());
+ resInfos[i] = &glyphInfos[i];
+ }
+
+ Skin * skin = screen->skin().get();
+
+ if (firstVis != lastVis)
+ skin->map(&resInfos[firstVis],
+ &glyphIDs[firstVis],
+ lastVis - firstVis);
+
+ for (unsigned i = firstVis; i < lastVis; ++i)
+ {
+ GlyphLayoutElem const & elem = layout.entries()[i];
+ Glyph const * glyph = static_cast<Glyph const *>(skin->fromID(glyphIDs[i]));
m2::PointD glyphPt;
ang::AngleD glyphAngle;