forked from organicmaps/organicmaps
Fixed text rendering under POI
This commit is contained in:
parent
9ac9f025fd
commit
24556fcdb0
6 changed files with 25 additions and 4 deletions
|
@ -1,7 +1,7 @@
|
|||
LINE_PROGRAM line_vertex_shader.vsh line_fragment_shader.fsh
|
||||
TEXT_PROGRAM text_vertex_shader.vsh text_fragment_shader.fsh
|
||||
TEXTURING_PROGRAM texturing_vertex_shader.vsh texturing_fragment_shader.fsh
|
||||
DASHED_LINE_PROGRAM dashed_vertex_shader.vsh dashed_fragment_shader.fsh
|
||||
TEXT_PROGRAM text_vertex_shader.vsh text_fragment_shader.fsh
|
||||
COMPASS_PROGRAM compass_vertex_shader.vsh texturing_fragment_shader.fsh
|
||||
RULER_PROGRAM ruler_vertex_shader.vsh texturing_fragment_shader.fsh
|
||||
ACCURACY_PROGRAM position_accuracy_shader.vsh texturing_fragment_shader.fsh
|
||||
|
|
|
@ -172,6 +172,17 @@ dp::Anchor GetAnchor(CaptionDefProto const * capRule)
|
|||
return dp::Center;
|
||||
}
|
||||
|
||||
m2::PointF GetOffset(CaptionDefProto const * capRule)
|
||||
{
|
||||
m2::PointF result(0, 0);
|
||||
if (capRule != nullptr && capRule->has_offset_x())
|
||||
result.x = capRule->offset_x();
|
||||
if (capRule != nullptr && capRule->has_offset_y())
|
||||
result.y = capRule->offset_y();
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
BaseApplyFeature::BaseApplyFeature(ref_ptr<EngineContext> context, FeatureID const & id,
|
||||
|
@ -195,6 +206,8 @@ void BaseApplyFeature::ExtractCaptionParams(CaptionDefProto const * primaryProto
|
|||
params.m_featureID = m_id;
|
||||
params.m_primaryText = m_captions.GetMainText();
|
||||
params.m_primaryTextFont = decl;
|
||||
params.m_primaryOffset = GetOffset(primaryProto);
|
||||
params.m_secondaryOffset = GetOffset(secondaryProto);
|
||||
|
||||
if (secondaryProto)
|
||||
{
|
||||
|
@ -450,6 +463,8 @@ void ApplyLineFeature::Finish()
|
|||
viewParams.m_featureID = FeatureID();
|
||||
viewParams.m_primaryText = roadNumber;
|
||||
viewParams.m_primaryTextFont = dp::FontDecl(dp::Color::RoadNumberOutline(), textHeight, dp::Color::White());
|
||||
viewParams.m_primaryOffset = m2::PointF(0, 0);
|
||||
viewParams.m_secondaryOffset = m2::PointF(0, 0);
|
||||
|
||||
m2::Spline::iterator it = m_spline.CreateIterator();
|
||||
while (!it.BeginAgain())
|
||||
|
|
|
@ -51,7 +51,7 @@ void PoiSymbolShape::Draw(ref_ptr<dp::Batcher> batcher, ref_ptr<dp::TextureManag
|
|||
provider.InitStream(0, gpu::SolidTexturingVertex::GetBindingInfo(), make_ref(vertexes));
|
||||
|
||||
drape_ptr<dp::OverlayHandle> handle = make_unique_dp<dp::SquareHandle>(m_params.m_id,
|
||||
dp::Center,
|
||||
dp::Bottom,
|
||||
m_pt,
|
||||
pixelSize,
|
||||
m_params.m_depth);
|
||||
|
|
|
@ -57,6 +57,8 @@ struct TextViewParams : CommonViewParams
|
|||
dp::FontDecl m_secondaryTextFont;
|
||||
string m_secondaryText;
|
||||
dp::Anchor m_anchor;
|
||||
m2::PointF m_primaryOffset;
|
||||
m2::PointF m_secondaryOffset;
|
||||
};
|
||||
|
||||
struct PathTextViewParams : CommonViewParams
|
||||
|
|
|
@ -86,14 +86,14 @@ void TextShape::Draw(ref_ptr<dp::Batcher> batcher, ref_ptr<dp::TextureManager> t
|
|||
ASSERT(!m_params.m_primaryText.empty(), ());
|
||||
StraightTextLayout primaryLayout(strings::MakeUniString(m_params.m_primaryText),
|
||||
m_params.m_primaryTextFont.m_size, textures, m_params.m_anchor);
|
||||
glsl::vec2 primaryOffset(0.0, 0.0);
|
||||
glsl::vec2 primaryOffset = glsl::ToVec2(m_params.m_primaryOffset);
|
||||
|
||||
if (!m_params.m_secondaryText.empty())
|
||||
{
|
||||
StraightTextLayout secondaryLayout(strings::MakeUniString(m_params.m_secondaryText),
|
||||
m_params.m_secondaryTextFont.m_size, textures, m_params.m_anchor);
|
||||
|
||||
glsl::vec2 secondaryOffset = primaryOffset;
|
||||
glsl::vec2 secondaryOffset = primaryOffset + glsl::ToVec2(m_params.m_secondaryOffset);
|
||||
|
||||
if (m_params.m_anchor & dp::Top)
|
||||
secondaryOffset += glsl::vec2(0.0, primaryLayout.GetPixelSize().y);
|
||||
|
|
|
@ -394,6 +394,8 @@ void TestingEngine::Draw()
|
|||
TScene::iterator it = m_scene.begin();
|
||||
for(; it != m_scene.end(); ++it)
|
||||
{
|
||||
m_textures->UpdateDynamicTextures();
|
||||
|
||||
dp::GLState const & state = it->first;
|
||||
ref_ptr<dp::GpuProgram> prg = m_programManager->GetProgram(state.GetProgramIndex());
|
||||
prg->Bind();
|
||||
|
@ -456,6 +458,8 @@ void TestingEngine::DrawImpl()
|
|||
params.m_primaryTextFont = fd;
|
||||
params.m_secondaryTextFont = auxFd;
|
||||
params.m_secondaryText = "Народная Китайская республика";
|
||||
params.m_primaryOffset = m2::PointF(0, 0);
|
||||
params.m_secondaryOffset = m2::PointF(0, 0);
|
||||
TextShape sh1(m2::PointF(82.277071f, 46.9271164f), params);
|
||||
sh1.Draw(make_ref(m_batcher), make_ref(m_textures));
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue