From e7130dc4ac81f64a2cfc2110abefcaa77a10e2ce Mon Sep 17 00:00:00 2001 From: rachytski Date: Fri, 7 Oct 2011 15:58:26 +0300 Subject: [PATCH] fixing #339. --- map/draw_processor.cpp | 4 +++- yg/path_renderer.cpp | 20 ++++++++++++++------ yg/yg_tests/screengl_test.cpp | 21 +++++++++++++++++---- 3 files changed, 34 insertions(+), 11 deletions(-) diff --git a/map/draw_processor.cpp b/map/draw_processor.cpp index 44b485d611..6d1330fe77 100644 --- a/map/draw_processor.cpp +++ b/map/draw_processor.cpp @@ -394,9 +394,11 @@ namespace fwork functor_t fun(p1); f.ForEachPointRef(fun, m_zoom); + + textLength += 50; + if ((fun.IsExist()) && (fun.m_length > textLength)) { - textLength += 50; p.m_startLength = (fun.m_length - textLength) / 2; p.m_endLength = p.m_startLength + textLength; } diff --git a/yg/path_renderer.cpp b/yg/path_renderer.cpp index 711c1cdde6..143899782a 100644 --- a/yg/path_renderer.cpp +++ b/yg/path_renderer.cpp @@ -46,6 +46,11 @@ namespace yg float rawTileStartLen = 0; + float rawTileLen = (float)lineStyle->rawTileLen(); + + if ((offset < 0) && (!lineStyle->m_isWrapped)) + offset = offset - rawTileLen * ceil(offset / rawTileLen); + bool skipToOffset = true; for (size_t i = 0; i < pointsCount - 1; ++i) @@ -84,15 +89,21 @@ namespace yg /// The rightmost tile goes non-antialised at left and antialiased at right side. /// Length of the actual pattern data being tiling(without antialiasing zones). - float rawTileLen = 0; + rawTileLen = 0; + + shared_ptr texture = skin()->getPage(lineStyle->m_pipelineID)->texture(); + + float texMaxY = lineStyle->m_texRect.maxY() - aaShift(); + float texMinY = lineStyle->m_texRect.minY() + aaShift(); + + m2::PointF const fNorm = norm * geomHalfWidth; // enough to calc it once + while (segLenRemain > 0) { rawTileLen = lineStyle->m_isWrapped ? segLen : std::min(((float)lineStyle->rawTileLen() - rawTileStartLen), segLenRemain); - float texMaxY = lineStyle->m_texRect.maxY() - aaShift(); - float texMinY = lineStyle->m_texRect.minY() + aaShift(); float texMinX = lineStyle->m_isWrapped ? 0 : lineStyle->m_texRect.minX() + 2 + rawTileStartLen; float texMaxX = texMinX + rawTileLen; @@ -104,7 +115,6 @@ namespace yg m2::PointF rawTileEndPt(rawTileStartPt.x + dir.x * rawTileLen, rawTileStartPt.y + dir.y * rawTileLen); - m2::PointF const fNorm = norm * geomHalfWidth; // enough to calc it once m2::PointF coords[4] = { // vng: i think this "rawTileStartPt + fNorm" reading better, isn't it? @@ -114,8 +124,6 @@ namespace yg m2::PointF(rawTileEndPt.x + fNorm.x, rawTileEndPt.y + fNorm.y) }; - shared_ptr texture = skin()->getPage(lineStyle->m_pipelineID)->texture(); - m2::PointF texCoords[4] = { texture->mapPixel(m2::PointF(texMinX, texMinY)), diff --git a/yg/yg_tests/screengl_test.cpp b/yg/yg_tests/screengl_test.cpp index 6edcbf623d..671e19480f 100644 --- a/yg/yg_tests/screengl_test.cpp +++ b/yg/yg_tests/screengl_test.cpp @@ -161,11 +161,24 @@ namespace vector pts; vector pattern; + pattern.push_back(20); + pattern.push_back(30); + + pts.push_back(m2::PointD(200, 80)); + pts.push_back(m2::PointD(300, 80)); + + AddTest(pts, pattern, yg::Color(0, 0, 0, 255), 4, 0, 150); + + pts.clear(); + pts.push_back(m2::PointD(200, 90)); + pts.push_back(m2::PointD(300, 90)); + + AddTest(pts, pattern, yg::Color(0, 0, 0, 255), 4, 0, -150); + + pts.clear(); pts.push_back(m2::PointD(200, 100)); pts.push_back(m2::PointD(400, 100)); - pattern.push_back(20); - pattern.push_back(30); /// The path should start from -10px path offset. AddTest(pts, pattern, yg::Color(0, 0, 0, 255), 4, 0, -10); @@ -1322,7 +1335,7 @@ namespace // UNIT_TEST_GL(TestDrawSingleSymbol); // UNIT_TEST_GL(TestDrawEmptySymbol); // UNIT_TEST_GL(TestDrawSingleSymbolAndSolidPath); - UNIT_TEST_GL(TestDrawMultiLineStringWithPosition); +// UNIT_TEST_GL(TestDrawMultiLineStringWithPosition); // UNIT_TEST_GL(TestDrawString); // UNIT_TEST_GL(TestDrawStringWithFixedFont); // UNIT_TEST_GL(TestDrawStringWithColor); @@ -1344,7 +1357,7 @@ namespace // UNIT_TEST_GL(TestDrawPoly); // UNIT_TEST_GL(TestDrawSolidRect); // UNIT_TEST_GL(TestDrawPathWithSkinPageMiss); -// UNIT_TEST_GL(TestDrawPathWithOffset); + UNIT_TEST_GL(TestDrawPathWithOffset); // UNIT_TEST_GL(TestDrawPathJoin); // UNIT_TEST_GL(TestDrawPathSolid1PX); // UNIT_TEST_GL(TestDrawPathSolid2PX);