From 93fbaa0b3552fdc7835f7de1958007609a642838 Mon Sep 17 00:00:00 2001 From: "r.kuznetsov" Date: Tue, 15 Dec 2015 18:12:23 +0300 Subject: [PATCH] Fixed guy text blurring --- drape_frontend/backend_renderer.cpp | 1 + drape_frontend/gui/gui_text.cpp | 8 ++++---- drape_frontend/gui/shape.cpp | 2 +- drape_frontend/text_layout.cpp | 11 ++++++----- drape_frontend/visual_params.cpp | 9 +++++++-- drape_frontend/visual_params.hpp | 3 +++ 6 files changed, 22 insertions(+), 12 deletions(-) diff --git a/drape_frontend/backend_renderer.cpp b/drape_frontend/backend_renderer.cpp index e61abccaee..dcd238144b 100644 --- a/drape_frontend/backend_renderer.cpp +++ b/drape_frontend/backend_renderer.cpp @@ -274,6 +274,7 @@ void BackendRenderer::InitGLDependentResource() params.m_glyphMngParams.m_whitelist = "fonts_whitelist.txt"; params.m_glyphMngParams.m_blacklist = "fonts_blacklist.txt"; params.m_glyphMngParams.m_sdfScale = VisualParams::Instance().GetGlyphSdfScale(); + params.m_glyphMngParams.m_baseGlyphHeight = VisualParams::Instance().GetGlyphBaseSize(); GetPlatform().GetFontNames(params.m_glyphMngParams.m_fonts); m_texMng->Init(params); diff --git a/drape_frontend/gui/gui_text.cpp b/drape_frontend/gui/gui_text.cpp index 53cffb1609..ce902bd3d6 100644 --- a/drape_frontend/gui/gui_text.cpp +++ b/drape_frontend/gui/gui_text.cpp @@ -19,8 +19,6 @@ namespace gui namespace { -static float const BASE_GLYPH_HEIGHT = 20.0f; - glsl::vec2 GetNormalsAndMask(dp::TextureManager::GlyphRegion const & glyph, float textRatio, array & normals, array & maskTexCoord) { @@ -156,7 +154,8 @@ void StaticLabel::CacheStaticText(string const & text, char const * delim, glsl::vec2 colorTex = glsl::ToVec2(color.GetTexRect().Center()); glsl::vec2 outlineTex = glsl::ToVec2(outline.GetTexRect().Center()); - float textRatio = font.m_size * df::VisualParams::Instance().GetVisualScale() / BASE_GLYPH_HEIGHT; + df::VisualParams const & vparams = df::VisualParams::Instance(); + float const textRatio = font.m_size * vparams.GetVisualScale() / vparams.GetGlyphBaseSize(); buffer_vector lineLengths; lineLengths.reserve(buffers.size()); @@ -325,7 +324,8 @@ void MutableLabel::Precache(PrecacheParams const & params, PrecacheResult & resu { SetMaxLength(params.m_maxLength); result.m_state.SetMaskTexture(SetAlphabet(params.m_alphabet, mng)); - m_textRatio = params.m_font.m_size * df::VisualParams::Instance().GetVisualScale() / BASE_GLYPH_HEIGHT; + df::VisualParams const & vparams = df::VisualParams::Instance(); + m_textRatio = params.m_font.m_size * vparams.GetVisualScale() / vparams.GetGlyphBaseSize(); dp::TextureManager::ColorRegion color; dp::TextureManager::ColorRegion outlineColor; diff --git a/drape_frontend/gui/shape.cpp b/drape_frontend/gui/shape.cpp index 32dbb86665..f1e4919623 100644 --- a/drape_frontend/gui/shape.cpp +++ b/drape_frontend/gui/shape.cpp @@ -26,7 +26,7 @@ bool Handle::Update(ScreenBase const & screen) m_uniforms.SetFloatValue("u_opacity", 1.0); auto const & params = df::VisualParams::Instance().GetGlyphVisualParams(); - m_uniforms.SetFloatValue("u_contrastGamma", params.m_contrast, params.m_gamma); + m_uniforms.SetFloatValue("u_contrastGamma", params.m_guiContrast, params.m_guiGamma); m_uniforms.SetFloatValue("u_isOutlinePass", 0.0f); } diff --git a/drape_frontend/text_layout.cpp b/drape_frontend/text_layout.cpp index 559717f3ef..7743a6e750 100644 --- a/drape_frontend/text_layout.cpp +++ b/drape_frontend/text_layout.cpp @@ -1,5 +1,7 @@ #include "drape_frontend/text_layout.hpp" +#include "drape_frontend/visual_params.hpp" + #include "drape/fribidi.hpp" #include "drape/glsl_func.hpp" #include "drape/overlay_handle.hpp" @@ -14,8 +16,7 @@ namespace df namespace { -float const BASE_HEIGHT = 22.0f; -float const VALID_SPLINE_TURN = 0.96f; +float const kValidSplineTurn = 0.96f; class TextGeometryGenerator { @@ -343,7 +344,7 @@ void TextLayout::Init(strings::UniString const & text, float fontSize, ref_ptr textures) { m_text = text; - m_textSizeRatio = fontSize / BASE_HEIGHT; + m_textSizeRatio = fontSize / VisualParams::Instance().GetGlyphBaseSize(); textures->GetGlyphRegions(text, m_metrics); } @@ -376,7 +377,7 @@ float TextLayout::GetPixelLength() const float TextLayout::GetPixelHeight() const { - return m_textSizeRatio * BASE_HEIGHT; + return m_textSizeRatio * VisualParams::Instance().GetGlyphBaseSize(); } strings::UniString const & TextLayout::GetText() const @@ -511,7 +512,7 @@ bool PathTextLayout::CacheDynamicGeometry(m2::Spline::iterator const & iter, Scr glsl::vec2 currentTangent = glsl::ToVec2(penIter.m_dir); penIter.Advance(advanceSign * xAdvance * scalePtoG); float const dotProduct = glsl::dot(currentTangent, glsl::ToVec2(penIter.m_dir)); - if (dotProduct < VALID_SPLINE_TURN) + if (dotProduct < kValidSplineTurn) return false; } diff --git a/drape_frontend/visual_params.cpp b/drape_frontend/visual_params.cpp index 3cdde498f0..7d31b28134 100644 --- a/drape_frontend/visual_params.cpp +++ b/drape_frontend/visual_params.cpp @@ -42,9 +42,9 @@ void VisualParams::Init(double vs, uint32_t tileSize, vector const & a // Here we set up glyphs rendering parameters separately for high-res and low-res screens. if (vs <= 1.0) - g_VizParams.m_glyphVisualParams = { 0.48f, 0.08f, 0.2f, 0.01f }; + g_VizParams.m_glyphVisualParams = { 0.48f, 0.08f, 0.2f, 0.01f, 0.49f, 0.04f }; else - g_VizParams.m_glyphVisualParams = { 0.5f, 0.05f, 0.2f, 0.01f }; + g_VizParams.m_glyphVisualParams = { 0.5f, 0.05f, 0.2f, 0.01f, 0.49f, 0.04f }; RISE_INITED; } @@ -54,6 +54,11 @@ uint32_t VisualParams::GetGlyphSdfScale() const return (m_visualScale <= 1.0) ? 3 : 4; } +uint32_t VisualParams::GetGlyphBaseSize() const +{ + return 22; +} + VisualParams & VisualParams::Instance() { ASSERT_INITED; diff --git a/drape_frontend/visual_params.hpp b/drape_frontend/visual_params.hpp index 4a1366775d..5204edc6fc 100644 --- a/drape_frontend/visual_params.hpp +++ b/drape_frontend/visual_params.hpp @@ -38,10 +38,13 @@ public: float m_gamma; float m_outlineContrast; float m_outlineGamma; + float m_guiContrast; + float m_guiGamma; }; GlyphVisualParams const & GetGlyphVisualParams() const; uint32_t GetGlyphSdfScale() const; + uint32_t GetGlyphBaseSize() const; private: int m_tileSize;