diff --git a/yg/geometry_batcher.cpp b/yg/geometry_batcher.cpp index 8378db60e2..05e5e877f5 100644 --- a/yg/geometry_batcher.cpp +++ b/yg/geometry_batcher.cpp @@ -312,7 +312,25 @@ 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) + void GeometryBatcher::addTexturedStrip( + m2::PointF const * coords, + m2::PointF const * texCoords, + unsigned size, + double depth, + int pageID + ) + { + addTexturedStripStrided(coords, sizeof(m2::PointF), texCoords, sizeof(m2::PointF), size, depth, pageID); + } + + void GeometryBatcher::addTexturedStripStrided( + m2::PointF const * coords, + size_t coordsStride, + m2::PointF const * texCoords, + size_t texCoordsStride, + unsigned size, + double depth, + int pageID) { if (!hasRoom(size, (size - 2) * 3, pageID)) flush(pageID); @@ -324,9 +342,11 @@ namespace yg 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].pt = *coords; + m_pipelines[pageID].m_vertices[vOffset + i].tex = *texCoords; m_pipelines[pageID].m_vertices[vOffset + i].depth = depth; + coords = reinterpret_cast(reinterpret_cast(coords) + coordsStride); + texCoords = reinterpret_cast(reinterpret_cast(texCoords) + texCoordsStride); } m_pipelines[pageID].m_currentVertex += size; diff --git a/yg/geometry_batcher.hpp b/yg/geometry_batcher.hpp index 824ca4c143..4f1f9cc7d6 100644 --- a/yg/geometry_batcher.hpp +++ b/yg/geometry_batcher.hpp @@ -125,6 +125,14 @@ namespace yg double depth, int pageID); + void addTexturedStripStrided(m2::PointF const * coords, + size_t coordsStride, + m2::PointF const * texCoords, + size_t texCoordsStride, + unsigned size, + double depth, + int pageID); + void addTexturedStrip(m2::PointF const * coords, m2::PointF const * texCoords, unsigned size, diff --git a/yg/shape_renderer.cpp b/yg/shape_renderer.cpp index 2c10a4037e..f50ec2efb1 100644 --- a/yg/shape_renderer.cpp +++ b/yg/shape_renderer.cpp @@ -2,6 +2,8 @@ #include "shape_renderer.hpp" #include "skin.hpp" +#include "../base/logging.hpp" + namespace yg { namespace gl @@ -65,5 +67,34 @@ namespace yg drawTrianglesList(§orPts[0], sectorPts.size(), skin()->mapColor(c), depth); } + void ShapeRenderer::drawRectangle(m2::RectD const & r, yg::Color const & c, double depth) + { + ResourceStyle const * style = skin()->fromID(skin()->mapColor(c)); + + if (style == 0) + { + LOG(LINFO, ("cannot map color")); + return; + } + + m2::PointF rectPts[4] = { + m2::PointF(r.minX(), r.minY()), + m2::PointF(r.maxX(), r.minY()), + m2::PointF(r.minX(), r.maxY()), + m2::PointD(r.maxX(), r.maxY()) + }; + + m2::PointF texPt = style->m_texRect.Center(); + + addTexturedStripStrided( + rectPts, + sizeof(m2::PointF), + &texPt, + 0, + 4, + depth, + style->m_pageID + ); + } } } diff --git a/yg/shape_renderer.hpp b/yg/shape_renderer.hpp index 0e0f8dd6cb..9770e20fbc 100644 --- a/yg/shape_renderer.hpp +++ b/yg/shape_renderer.hpp @@ -18,6 +18,8 @@ namespace yg void drawArc(m2::PointD const & center, double startA, double endA, double r, yg::Color const & c, double depth); void drawSector(m2::PointD const & center, double startA, double endA, double r, yg::Color const & c, double depth); void fillSector(m2::PointD const & center, double startA, double endA, double r, yg::Color const & c, double depth); + + void drawRectangle(m2::RectD const & r, yg::Color const & c, double depth); }; } } diff --git a/yg/text_renderer.cpp b/yg/text_renderer.cpp index 6470a6da7f..b77b9cf34f 100644 --- a/yg/text_renderer.cpp +++ b/yg/text_renderer.cpp @@ -238,9 +238,12 @@ namespace yg { uint32_t glyphID = skin()->mapGlyph(GlyphKey(text[i], fontSize, false, yg::Color(0, 0, 0, 0)), fixedFont); CharStyle const * p = static_cast(skin()->fromID(glyphID)); - rect.Add(pt); - rect.Add(pt + m2::PointD(p->m_xOffset + p->m_texRect.SizeX() - 4, -p->m_yOffset - (int)p->m_texRect.SizeY() + 4)); - pt += m2::PointD(p->m_xAdvance, 0); + if (p != 0) + { + rect.Add(pt); + rect.Add(pt + m2::PointD(p->m_xOffset + p->m_texRect.SizeX() - 4, -p->m_yOffset - (int)p->m_texRect.SizeY() + 4)); + pt += m2::PointD(p->m_xAdvance, 0); + } } else { diff --git a/yg/texture.hpp b/yg/texture.hpp index eeb5d8c417..adcd442c43 100644 --- a/yg/texture.hpp +++ b/yg/texture.hpp @@ -96,7 +96,7 @@ namespace yg Traits::gl_pixel_format_type, Traits::gl_pixel_data_type, &gil::view(image)(0, 0))); -// boost::gil::lodepng_write_view(fullPath.c_str(), gil::view(image)); + boost::gil::lodepng_write_view(fullPath.c_str(), gil::view(image)); #endif @@ -274,7 +274,7 @@ namespace yg readback(); std::string const fullPath = GetPlatform().WritablePathForFile(fileName); #ifndef OMIM_GL_ES -// boost::gil::lodepng_write_view(fullPath.c_str(), view(width(), height())); + boost::gil::lodepng_write_view(fullPath.c_str(), view(width(), height())); #endif unlock(); }