From f69571c354384c81f9b9aa8f239ccb0e4fe5c272 Mon Sep 17 00:00:00 2001 From: rachytski Date: Sun, 16 Jan 2011 14:51:45 +0200 Subject: [PATCH] symbol position as a parameter in drawPoint function. plenty of warnings cleanups. --- 3party/agg/agg_bezier_arc.h | 2 +- 3party/agg/agg_color_gray.h | 2 +- 3party/agg/agg_pixfmt_rgba.h | 1 + 3party/agg/agg_rasterizer_sl_clip.h | 2 +- 3party/fribidi/lib/fribidi-mem.c | 2 +- indexer/classificator.cpp | 1 + indexer/feature.cpp | 2 +- map/drawer_yg.cpp | 12 ++++++------ map/drawer_yg.hpp | 4 ++-- map/information_display.cpp | 2 +- map/navigator.cpp | 2 +- yg/geometry_batcher.cpp | 23 ++++++++++++++++++----- yg/geometry_batcher.hpp | 15 +++++++++++++++ yg/glyph_cache.cpp | 12 +----------- yg/glyph_cache_impl.cpp | 2 +- yg/path_renderer.cpp | 13 +++++++------ yg/skin_loader.cpp | 4 ++-- yg/yg_tests/screengl_test.cpp | 6 +++--- 18 files changed, 64 insertions(+), 43 deletions(-) diff --git a/3party/agg/agg_bezier_arc.h b/3party/agg/agg_bezier_arc.h index 6d98d1a9f0..b3d65492ff 100644 --- a/3party/agg/agg_bezier_arc.h +++ b/3party/agg/agg_bezier_arc.h @@ -68,7 +68,7 @@ namespace agg *x = m_vertices[m_vertex]; *y = m_vertices[m_vertex + 1]; m_vertex += 2; - return (m_vertex == 2) ? path_cmd_move_to : m_cmd; + return (m_vertex == 2) ? (unsigned)path_cmd_move_to : m_cmd; } // Supplemantary functions. num_vertices() actually returns doubled diff --git a/3party/agg/agg_color_gray.h b/3party/agg/agg_color_gray.h index 8e782ef2c9..c27db2dd5a 100644 --- a/3party/agg/agg_color_gray.h +++ b/3party/agg/agg_color_gray.h @@ -335,7 +335,7 @@ namespace agg return *this; } calc_type v_ = (calc_type(v) * base_mask) / a; - v = value_type((v_ > base_mask) ? base_mask : v_); + v = value_type((v_ > (calc_type)base_mask) ? (calc_type)base_mask : v_); return *this; } diff --git a/3party/agg/agg_pixfmt_rgba.h b/3party/agg/agg_pixfmt_rgba.h index 7d89b4905b..0afea77c46 100644 --- a/3party/agg/agg_pixfmt_rgba.h +++ b/3party/agg/agg_pixfmt_rgba.h @@ -144,6 +144,7 @@ namespace agg unsigned alpha, unsigned cover=0) { + static_cast(cover); calc_type r = p[Order::R]; calc_type g = p[Order::G]; calc_type b = p[Order::B]; diff --git a/3party/agg/agg_rasterizer_sl_clip.h b/3party/agg/agg_rasterizer_sl_clip.h index e7ba065acc..a3c5867fbe 100644 --- a/3party/agg/agg_rasterizer_sl_clip.h +++ b/3party/agg/agg_rasterizer_sl_clip.h @@ -317,7 +317,7 @@ namespace agg rasterizer_sl_no_clip() : m_x1(0), m_y1(0) {} void reset_clipping() {} - void clip_box(coord_type x1, coord_type y1, coord_type x2, coord_type y2) {} + void clip_box(coord_type /*x1*/, coord_type /*y1*/, coord_type /*x2*/, coord_type /*y2*/) {} void move_to(coord_type x1, coord_type y1) { m_x1 = x1; m_y1 = y1; } template diff --git a/3party/fribidi/lib/fribidi-mem.c b/3party/fribidi/lib/fribidi-mem.c index da4bb96487..99b54f81bb 100644 --- a/3party/fribidi/lib/fribidi-mem.c +++ b/3party/fribidi/lib/fribidi-mem.c @@ -59,7 +59,7 @@ fribidi_mem_chunk_new ( { register FriBidiMemChunk *m; - fribidi_assert (area_size >= atom_size * 8); + fribidi_assert (area_size >= (unsigned long)atom_size * 8); m = (FriBidiMemChunk *) fribidi_malloc (sizeof (FriBidiMemChunk)); if LIKELY diff --git a/indexer/classificator.cpp b/indexer/classificator.cpp index be4092e35f..3db7b266a5 100644 --- a/indexer/classificator.cpp +++ b/indexer/classificator.cpp @@ -119,6 +119,7 @@ void ClassifObject::VisSavePolicy::Serialize(ostream & s) const void ClassifObject::VisLoadPolicy::Name(string const & name) const { + static_cast(name); // Assume that classificator doesn't changed for saved visibility. ASSERT ( name == Current()->m_name, () ); } diff --git a/indexer/feature.cpp b/indexer/feature.cpp index 0804021d5e..c609875c11 100644 --- a/indexer/feature.cpp +++ b/indexer/feature.cpp @@ -341,7 +341,7 @@ namespace uint8_t m_pos; public: - BitSink(TSink & sink) : m_sink(sink), m_pos(0), m_current(0) {} + BitSink(TSink & sink) : m_sink(sink), m_current(0), m_pos(0) {} void Finish() { diff --git a/map/drawer_yg.cpp b/map/drawer_yg.cpp index 3969b8eeed..094b70d4f2 100644 --- a/map/drawer_yg.cpp +++ b/map/drawer_yg.cpp @@ -79,12 +79,12 @@ void DrawerYG::onSize(int w, int h) m_pScreen->onSize(w, h); } -void DrawerYG::drawSymbol(m2::PointD const & pt, string const & symbolName, int depth) +void DrawerYG::drawSymbol(m2::PointD const & pt, string const & symbolName, yg::EPosition pos, int depth) { - m_pScreen->drawPoint(pt, m_pSkin->mapSymbol(symbolName.c_str()), depth); + m_pScreen->drawPoint(pt, m_pSkin->mapSymbol(symbolName.c_str()), pos, depth); } -void DrawerYG::drawSymbol(m2::PointD const & pt, rule_ptr_t pRule, int depth) +void DrawerYG::drawSymbol(m2::PointD const & pt, rule_ptr_t pRule, yg::EPosition pos, int depth) { // Use BaseRule::m_id to cache for point draw rule. // This rules doesn't mix with other rule-types. @@ -105,7 +105,7 @@ void DrawerYG::drawSymbol(m2::PointD const & pt, rule_ptr_t pRule, int depth) } } - m_pScreen->drawPoint(pt, id, depth); + m_pScreen->drawPoint(pt, id, pos, depth); } void DrawerYG::drawPath(vector const & pts, rule_ptr_t pRule, int depth) @@ -226,13 +226,13 @@ void DrawerYG::Draw(di::DrawInfo const * pInfo, rule_ptr_t pRule, int depth) if (isFill) drawArea(i->m_path, pRule, depth); else if (isSym) - drawSymbol(i->GetCenter(), pRule, depth); + drawSymbol(i->GetCenter(), pRule, yg::EPosLeft, depth); } } // draw point symbol if (!isPath && !isArea && isSymbol && ((pRule->GetType() & drule::node) != 0)) - drawSymbol(pInfo->m_point, pRule, depth); + drawSymbol(pInfo->m_point, pRule, yg::EPosLeft, depth); } else { diff --git a/map/drawer_yg.hpp b/map/drawer_yg.hpp index 4243582bdc..649970ad16 100644 --- a/map/drawer_yg.hpp +++ b/map/drawer_yg.hpp @@ -63,7 +63,7 @@ private: org_map_t m_pathsOrg; protected: - void drawSymbol(m2::PointD const & pt, rule_ptr_t pRule, int depth); + void drawSymbol(m2::PointD const & pt, rule_ptr_t pRule, yg::EPosition pos, int depth); void drawPath(vector const & pts, rule_ptr_t pRule, int depth); void drawArea(vector const & pts, rule_ptr_t pRule, int depth); @@ -87,7 +87,7 @@ public: DrawerYG(string const & skinName, params_t const & params = params_t()); - void drawSymbol(m2::PointD const & pt, string const & symbolName, int depth); + void drawSymbol(m2::PointD const & pt, string const & symbolName, yg::EPosition pos, int depth); void beginFrame(); void endFrame(); diff --git a/map/information_display.cpp b/map/information_display.cpp index 508e648191..dfb77dd07c 100644 --- a/map/information_display.cpp +++ b/map/information_display.cpp @@ -79,7 +79,7 @@ void InformationDisplay::drawPosition(DrawerYG * pDrawer) { /// Drawing position and heading m2::PointD pxPosition = m_screen.GtoP(m_position); - pDrawer->drawSymbol(pxPosition, "current-position", yg::maxDepth); + pDrawer->drawSymbol(pxPosition, "current-position", yg::EPosCenter, yg::maxDepth); double pxConfidenceRadius = pxPosition.Length(m_screen.GtoP(m_position + m2::PointD(m_confidenceRadius, 0))); diff --git a/map/navigator.cpp b/map/navigator.cpp index a858e66ca0..f5b52a7586 100644 --- a/map/navigator.cpp +++ b/map/navigator.cpp @@ -118,7 +118,7 @@ void Navigator::StartScale(m2::PointD const & pt1, m2::PointD const & pt2, doubl m_InAction = true; } -void Navigator::ScaleToPoint(m2::PointD const & pt, double factor, double timeInSec) +void Navigator::ScaleToPoint(m2::PointD const & pt, double factor, double /*timeInSec*/) { m2::PointD startPt; m2::PointD endPt; diff --git a/yg/geometry_batcher.cpp b/yg/geometry_batcher.cpp index d6be3cdeb1..acb104c8ea 100644 --- a/yg/geometry_batcher.cpp +++ b/yg/geometry_batcher.cpp @@ -217,7 +217,7 @@ namespace yg // } } - void GeometryBatcher::drawPoint(m2::PointD const & pt, uint32_t styleID, double depth) + void GeometryBatcher::drawPoint(m2::PointD const & pt, uint32_t styleID, EPosition pos, double depth) { ResourceStyle const * style(m_skin->fromID(styleID)); @@ -227,13 +227,26 @@ namespace yg m2::RectU texRect(style->m_texRect); texRect.Inflate(-1, -1); - float const polyMinY = my::rounds(pt.y - texRect.SizeY() / 2.0); - float const polyMaxY = polyMinY + texRect.SizeY(); + m2::PointD posPt; + + if (pos & EPosLeft) + posPt.x = pt.x - texRect.SizeX(); + else if (pos & EPosRight) + posPt.x = pt.x; + else + posPt.x = pt.x - texRect.SizeX() / 2; + + if (pos & EPosAbove) + posPt.y = pt.y - texRect.SizeY(); + else if (pos & EPosUnder) + posPt.y = pt.y; + else + posPt.y = pt.y - texRect.SizeY() / 2; + drawTexturedPolygon(m2::PointD(0.0, 0.0), 0.0, texRect.minX(), texRect.minY(), texRect.maxX(), texRect.maxY(), - // move symbol to the left from origin point (do not mix with texts) - pt.x - texRect.SizeX(), polyMinY, pt.x, polyMaxY, + posPt.x, posPt.y, posPt.x + texRect.SizeX(), posPt.y + texRect.SizeY(), depth, style->m_pageID); } diff --git a/yg/geometry_batcher.hpp b/yg/geometry_batcher.hpp index b7e6821a29..83cab85861 100644 --- a/yg/geometry_batcher.hpp +++ b/yg/geometry_batcher.hpp @@ -27,6 +27,19 @@ namespace yg class Skin; struct CharStyle; + enum EPosition + { + EPosCenter = 0x00, + EPosAbove = 0x01, + EPosUnder = 0x02, + EPosLeft = 0x04, + EPosRight = 0x10, + EPosAboveLeft = EPosAbove | EPosLeft, + EPosAboveRight = EPosAbove | EPosRight, + EPosUnderLeft = EPosUnder | EPosLeft, + EPosUnderRight = EPosUnder | EPosRight + }; + namespace gl { class GeometryBatcher : public RenderStateUpdater @@ -111,7 +124,9 @@ namespace yg void drawPoint(m2::PointD const & pt, uint32_t styleID, + EPosition pos, double depth); + void drawPath(m2::PointD const * points, size_t pointsCount, uint32_t styleID, diff --git a/yg/glyph_cache.cpp b/yg/glyph_cache.cpp index a73b6c4a7f..e37a1252f5 100644 --- a/yg/glyph_cache.cpp +++ b/yg/glyph_cache.cpp @@ -50,16 +50,6 @@ namespace yg FTC_FaceID faceID = reinterpret_cast(font); - FTC_ScalerRec fontScaler = - { - faceID, - key.m_fontSize, - key.m_fontSize, - 1, - 0, - 0 - }; - int charIDX = FTC_CMapCache_Lookup( m_impl->m_charMapCache, faceID, @@ -220,7 +210,7 @@ namespace yg return info; } - void GlyphInfo::dump(const char *fileName) + void GlyphInfo::dump(const char * /*fileName */) { /* gil::lodepng_write_view(fileName, gil::interleaved_view(m_width, diff --git a/yg/glyph_cache_impl.cpp b/yg/glyph_cache_impl.cpp index 64b5ba9d63..f3fdb9e5c6 100644 --- a/yg/glyph_cache_impl.cpp +++ b/yg/glyph_cache_impl.cpp @@ -46,7 +46,7 @@ namespace yg FT_Done_FreeType(m_lib); } - FT_Error GlyphCacheImpl::RequestFace(FTC_FaceID faceID, FT_Library library, FT_Pointer requestData, FT_Face * face) + FT_Error GlyphCacheImpl::RequestFace(FTC_FaceID faceID, FT_Library library, FT_Pointer /*requestData*/, FT_Face * face) { //GlyphCacheImpl * glyphCacheImpl = reinterpret_cast(requestData); Font * font = reinterpret_cast(faceID); diff --git a/yg/path_renderer.cpp b/yg/path_renderer.cpp index 27aa7a36d9..c6827ae7d0 100644 --- a/yg/path_renderer.cpp +++ b/yg/path_renderer.cpp @@ -25,10 +25,11 @@ namespace yg for (size_t i = 0; i < pointsCount - 1; ++i) { m2::PointD dir = points[i + 1] - points[i]; - dir *= 1.0 / dir.Length(m2::PointD(0, 0)); + double len = dir.Length(m2::PointD(0, 0)); + dir *= 1.0 / len; m2::PointD norm(-dir.y, dir.x); + m2::PointD const & nextPt = points[i + 1]; - float segLen = points[i + 1].Length(points[i]); float geomHalfWidth = (lineStyle->m_penInfo.m_w + 4 - aaShift() * 2) / 2.0; float texMinX = lineStyle->m_texRect.minX() + 1; @@ -50,11 +51,11 @@ namespace yg points[i] + fNorm, /// inner part points[i] - fNorm, - points[i + 1] + fNorm, - points[i + 1] - fNorm, + nextPt + fNorm, + nextPt - fNorm, /// right round cap - points[i + 1] + fDir + fNorm, - points[i + 1] + fDir - fNorm + nextPt + fDir + fNorm, + nextPt + fDir - fNorm }; shared_ptr texture = skin()->pages()[lineStyle->m_pageID]->texture(); diff --git a/yg/skin_loader.cpp b/yg/skin_loader.cpp index 607425b0ac..09cb6e34ff 100644 --- a/yg/skin_loader.cpp +++ b/yg/skin_loader.cpp @@ -20,9 +20,9 @@ namespace yg m_xAdvance(0), m_fileName(""), m_resourceManager(resourceManager), + m_skin(0), m_dynamicPagesCount(dynamicPagesCount), - m_textPagesCount(textPagesCount), - m_skin(0) + m_textPagesCount(textPagesCount) { m_mode.push_back(ERoot); } diff --git a/yg/yg_tests/screengl_test.cpp b/yg/yg_tests/screengl_test.cpp index ad6829bdc7..28c5132305 100644 --- a/yg/yg_tests/screengl_test.cpp +++ b/yg/yg_tests/screengl_test.cpp @@ -21,9 +21,9 @@ namespace { void DoDraw(shared_ptr p) { - p->drawPoint(m2::PointD(40, 40), 0, 0); - p->drawPoint(m2::PointD(40.5, 60), 0, 0); - p->drawPoint(m2::PointD(41, 80), 0, 0); + p->drawPoint(m2::PointD(40, 40), 0, yg::EPosCenter, 0); + p->drawPoint(m2::PointD(40.5, 60), 0, yg::EPosCenter, 0); + p->drawPoint(m2::PointD(41, 80), 0, yg::EPosCenter, 0); } };