diff options
author | Roman Sorokin <sorok-roma@yandex.ru> | 2014-09-15 14:00:53 +0400 |
---|---|---|
committer | Alex Zolotarev <alex@maps.me> | 2015-09-23 02:27:21 +0300 |
commit | 159c7b4b203ed0edc73aa7ce90adc97c016d8da2 (patch) | |
tree | 781af9145555ac87fdbbf38fa2b2bb337424792f /drape_frontend/text_layout.cpp | |
parent | 72391142132d2316edbe34fef8f0065134ca0530 (diff) |
Correct attribute loading for new shaders
Diffstat (limited to 'drape_frontend/text_layout.cpp')
-rw-r--r-- | drape_frontend/text_layout.cpp | 41 |
1 files changed, 31 insertions, 10 deletions
diff --git a/drape_frontend/text_layout.cpp b/drape_frontend/text_layout.cpp index b7fe836c21..3d283d9e44 100644 --- a/drape_frontend/text_layout.cpp +++ b/drape_frontend/text_layout.cpp @@ -7,15 +7,29 @@ #include "../std/limits.hpp" using glsl_types::vec4; +using glsl_types::Quad1; using glsl_types::Quad4; namespace { - void FillColor(vector<Quad4> & data, dp::Color const & color) +void FillColor(vector<Quad4> & colors, + dp::TextureSetHolder::ColorRegion & region, + dp::Color const & base, dp::Color const & outline, + dp::RefPointer<dp::TextureSetHolder> textures) { - Quad4 c; - c.v[0] = c.v[1] = c.v[2] = c.v[3] = vec4(dp::ColorF(color)); - fill(data.begin(), data.end(), c); + dp::ColorKey key; + key.m_color = (base.m_alfa << 24) | (base.m_blue << 16) | (base.m_green << 8) | base.m_red; + textures->GetColorRegion(key, region); + m2::RectF const & rect1 = region.GetTexRect(); + m2::PointF coord1 = (rect1.RightTop() + rect1.LeftBottom()) * 0.5f; + key.m_color = (outline.m_alfa << 24) | (outline.m_blue << 16) | (outline.m_green << 8) | outline.m_red; + textures->GetColorRegion(key, region); + m2::RectF const & rect2 = region.GetTexRect(); + m2::PointF coord2 = (rect2.RightTop() + rect2.LeftBottom()) * 0.5f; + + vec4 clrs(coord1, coord2); + Quad4 f(clrs, clrs, clrs, clrs); + fill(colors.begin(), colors.end(), f); } } @@ -96,15 +110,18 @@ dp::OverlayHandle * LayoutText(const FeatureID & featureID, vector<glsl_types::Quad4> & positions, vector<glsl_types::Quad4> & texCoord, vector<glsl_types::Quad4> & color, - vector<glsl_types::Quad4> & index, + vector<glsl_types::Quad1> & index, dp::RefPointer<dp::TextureSetHolder> textures, int count) { STATIC_ASSERT(sizeof(vec4) == 4 * sizeof(float)); STATIC_ASSERT(sizeof(Quad4) == 4 * sizeof(vec4)); - FillColor(color, layoutIter->m_font.m_color); - FillColor(index,layoutIter->m_font.m_outlineColor); + dp::TextureSetHolder::ColorRegion region; + FillColor(color, region, layoutIter->m_font.m_color, layoutIter->m_font.m_outlineColor, textures); + float texIndex = static_cast<float>(region.GetTextureNode().m_textureOffset); + Quad1 f(texIndex, texIndex, texIndex, texIndex); + fill(index.begin(), index.end(), f); int counter = 0; m2::PointD size(0.0, 0.0); @@ -161,7 +178,8 @@ dp::OverlayHandle * LayoutText(const FeatureID & featureID, void TextLayout::InitPathText(float depth, vector<glsl_types::Quad4> & texCoord, vector<glsl_types::Quad4> & fontColor, - vector<glsl_types::Quad4> & index) const + vector<glsl_types::Quad1> & index, + dp::RefPointer<dp::TextureSetHolder> textures) const { STATIC_ASSERT(sizeof(vec4) == 4 * sizeof(float)); STATIC_ASSERT(sizeof(Quad4) == 4 * sizeof(vec4)); @@ -171,8 +189,11 @@ void TextLayout::InitPathText(float depth, ASSERT(glyphCount <= fontColor.size(), ()); ASSERT(glyphCount <= index.size(), ()); - FillColor(fontColor, m_font.m_color); - FillColor(index, m_font.m_outlineColor); + dp::TextureSetHolder::ColorRegion region; + FillColor(fontColor, region, m_font.m_color, m_font.m_outlineColor, textures); + float texIndex = static_cast<float>(region.GetTextureNode().m_textureOffset); + Quad1 f(texIndex, texIndex, texIndex, texIndex); + fill(index.begin(), index.end(), f); for (size_t i = 0; i < glyphCount; ++i) GetTextureQuad(m_metrics[i], depth, texCoord[i]); |