diff --git a/yg/geometry_batcher.cpp b/yg/geometry_batcher.cpp index 994946276d..f3cdcd86e4 100644 --- a/yg/geometry_batcher.cpp +++ b/yg/geometry_batcher.cpp @@ -326,7 +326,7 @@ namespace yg texture->mapPixel(m2::PointF(texMaxX, texMinY)) }; - addTexturedVertices(coords, texCoords, 4, depth, lineStyle->m_pageID); + addTexturedFan(coords, texCoords, 4, depth, lineStyle->m_pageID); segLenRemain -= rawTileLen; @@ -385,7 +385,7 @@ namespace yg m2::PointF(points[i + 1] + prevStartVec * geomHalfWidth) }; - addTexturedVertices(joinSeg, joinSegTex, 3, depth, lineStyle->m_pageID); + addTexturedFan(joinSeg, joinSegTex, 3, depth, lineStyle->m_pageID); prevStartVec = startVec; } @@ -506,10 +506,10 @@ namespace yg m2::PointF(texMaxX, texMinY) }; - addTexturedVertices(coords, texCoords, 4, depth, pageID); + addTexturedFan(coords, texCoords, 4, depth, pageID); } - void GeometryBatcher::addTexturedVertices(m2::PointF const * coords, m2::PointF const * texCoords, unsigned size, double depth, int pageID) + void GeometryBatcher::addTexturedFan(m2::PointF const * coords, m2::PointF const * texCoords, unsigned size, double depth, int pageID) { if (!hasRoom(size, (size - 2) * 3, pageID)) flush(pageID); @@ -539,6 +539,42 @@ namespace yg m_pipelines[pageID].m_currentIndex += (size - 2) * 3; } + void GeometryBatcher::addTexturedStrip(m2::PointF const * coords, m2::PointF const * texCoords, unsigned size, double depth, int pageID) + { + if (!hasRoom(size, (size - 2) * 3, pageID)) + flush(pageID); + + ASSERT(size > 2, ()); + + size_t vOffset = m_pipelines[pageID].m_currentVertex; + size_t iOffset = m_pipelines[pageID].m_currentIndex; + + for (unsigned i = 0; i < size; ++i) + { + m_pipelines[pageID].m_vertices[vOffset + i].pt = coords[i]; + m_pipelines[pageID].m_vertices[vOffset + i].tex = texCoords[i]; + m_pipelines[pageID].m_vertices[vOffset + i].depth = depth; + } + + m_pipelines[pageID].m_currentVertex += size; + + size_t oldIdx1 = vOffset; + size_t oldIdx2 = vOffset + 1; + + for (size_t j = 0; j < size - 2; ++j) + { + m_pipelines[pageID].m_indices[iOffset + j * 3] = oldIdx1; + m_pipelines[pageID].m_indices[iOffset + j * 3 + 1] = oldIdx2; + m_pipelines[pageID].m_indices[iOffset + j * 3 + 2] = vOffset + j + 2; + + oldIdx1 = oldIdx2; + oldIdx2 = vOffset + j + 2; + } + + m_pipelines[pageID].m_currentIndex += (size - 2) * 3; + } + + void GeometryBatcher::drawGlyph(m2::PointD const & ptOrg, m2::PointD const & ptGlyph, float angle, float blOffset, CharStyle const * p, double depth) { float x0 = ptGlyph.x + (p->m_xOffset - 1); diff --git a/yg/geometry_batcher.hpp b/yg/geometry_batcher.hpp index e1af72c936..006e48130a 100644 --- a/yg/geometry_batcher.hpp +++ b/yg/geometry_batcher.hpp @@ -162,11 +162,17 @@ namespace yg void setRenderTarget(shared_ptr const & rt); - void addTexturedVertices(m2::PointF const * coords, - m2::PointF const * texCoords, - unsigned size, - double depth, - int pageID); + void addTexturedFan(m2::PointF const * coords, + m2::PointF const * texCoords, + unsigned size, + double depth, + int pageID); + + void addTexturedStrip(m2::PointF const * coords, + m2::PointF const * texCoords, + unsigned size, + double depth, + int pageID); int aaShift() const; diff --git a/yg/path_renderer.cpp b/yg/path_renderer.cpp index bd35d1561a..27aa7a36d9 100644 --- a/yg/path_renderer.cpp +++ b/yg/path_renderer.cpp @@ -42,49 +42,36 @@ namespace yg m2::PointF const fNorm = norm * geomHalfWidth; // enough to calc it once m2::PointF const fDir(fNorm.y, -fNorm.x); - m2::PointF coords[12] = + m2::PointF coords[8] = { /// left round cap - m2::PointF(points[i].x - fDir.x + fNorm.x, points[i].y - fDir.y + fNorm.y), - m2::PointF(points[i].x - fDir.x - fNorm.x, points[i].y - fDir.y - fNorm.y), - m2::PointF(points[i].x - fNorm.x, points[i].y - fNorm.y), - m2::PointF(points[i].x + fNorm.x, points[i].y + fNorm.y), + points[i] - fDir + fNorm, + points[i] - fDir - fNorm, + points[i] + fNorm, /// inner part - m2::PointF(points[i].x + fNorm.x, points[i].y + fNorm.y), - m2::PointF(points[i].x - fNorm.x, points[i].y - fNorm.y), - m2::PointF(points[i + 1].x - fNorm.x, points[i + 1].y - fNorm.y), - m2::PointF(points[i + 1].x + fNorm.x, points[i + 1].y + fNorm.y), + points[i] - fNorm, + points[i + 1] + fNorm, + points[i + 1] - fNorm, /// right round cap - m2::PointF(points[i + 1].x + fNorm.x, points[i + 1].y + fNorm.y), - m2::PointF(points[i + 1].x - fNorm.x, points[i + 1].y - fNorm.y), - m2::PointF(points[i + 1].x + fDir.x - fNorm.x, points[i + 1].y + fDir.y - fNorm.y), - m2::PointF(points[i + 1].x + fDir.x + fNorm.x, points[i + 1].y + fDir.y + fNorm.y) + points[i + 1] + fDir + fNorm, + points[i + 1] + fDir - fNorm }; shared_ptr texture = skin()->pages()[lineStyle->m_pageID]->texture(); - m2::PointF texCoords[12] = + m2::PointF texCoords[8] = { - /// left round cap texture->mapPixel(m2::PointF(texMinX, texMinY)), texture->mapPixel(m2::PointF(texMinX, texMaxY)), - texture->mapPixel(m2::PointF(texCenterX, texMaxY)), - texture->mapPixel(m2::PointF(texCenterX, texMinY)), - /// inner part texture->mapPixel(m2::PointF(texCenterX, texMinY)), texture->mapPixel(m2::PointF(texCenterX, texMaxY)), - texture->mapPixel(m2::PointF(texCenterX, texMaxY)), - texture->mapPixel(m2::PointF(texCenterX, texMinY)), - /// right round cap texture->mapPixel(m2::PointF(texCenterX, texMinY)), texture->mapPixel(m2::PointF(texCenterX, texMaxY)), - texture->mapPixel(m2::PointF(texMaxX, texMaxY)), - texture->mapPixel(m2::PointF(texMaxX, texMinY)) + texture->mapPixel(m2::PointF(texMaxX, texMinY)), + texture->mapPixel(m2::PointF(texMaxX, texMaxY)) }; - addTexturedVertices(coords, texCoords, 4, depth, lineStyle->m_pageID); - addTexturedVertices(coords + 4, texCoords + 4, 4, depth, lineStyle->m_pageID); - addTexturedVertices(coords + 8, texCoords + 8, 4, depth, lineStyle->m_pageID); + addTexturedStrip(coords, texCoords, 8, depth, lineStyle->m_pageID); } } else diff --git a/yg/yg_tests/screengl_test.cpp b/yg/yg_tests/screengl_test.cpp index e5d0494b05..3b27197930 100644 --- a/yg/yg_tests/screengl_test.cpp +++ b/yg/yg_tests/screengl_test.cpp @@ -879,10 +879,10 @@ namespace // UNIT_TEST_GL(TestDrawPathWithSkinPageMiss); // UNIT_TEST_GL(TestDrawPathWithOffset); // UNIT_TEST_GL(TestDrawPathJoin); - UNIT_TEST_GL(TestDrawPathSolid1PX); - UNIT_TEST_GL(TestDrawPathSolid2PX); -// UNIT_TEST_GL(TestDrawPathSolid); - UNIT_TEST_GL(TestDrawPathSolidDiffWidth); +// UNIT_TEST_GL(TestDrawPathSolid1PX); +// UNIT_TEST_GL(TestDrawPathSolid2PX); + UNIT_TEST_GL(TestDrawPathSolid); +// UNIT_TEST_GL(TestDrawPathSolidDiffWidth); // UNIT_TEST_GL(TestDrawPathSolidWithZ); // UNIT_TEST_GL(TestDrawPathSolidWithClipRect); // UNIT_TEST_GL(TestDrawUtilsRect);