From 544b62728ec0d7284a33518563a191bd62441af0 Mon Sep 17 00:00:00 2001 From: rachytski Date: Mon, 5 Sep 2011 14:06:26 +0300 Subject: [PATCH] fixed plenty of casting warnings. --- map/drawer_yg.cpp | 6 +++--- map/drawer_yg.hpp | 2 +- map/information_display.cpp | 6 +++--- map/render_policy.cpp | 12 ++++++------ map/render_queue_routine.cpp | 22 +++++++++++----------- map/screen_coverage.cpp | 4 ++-- map/tile_renderer.cpp | 3 +-- map/tile_renderer.hpp | 1 - map/tiler.cpp | 12 ++++++------ map/tiling_render_policy_mt.cpp | 1 - yg/glyph_cache.cpp | 2 +- yg/path_renderer.cpp | 2 +- yg/pen_info.cpp | 6 +++--- yg/render_state.cpp | 4 ++-- yg/resource_style.cpp | 6 ++++-- yg/shape_renderer.cpp | 6 +++--- yg/skin_page.cpp | 22 +++++++++++++--------- yg/symbol_element.cpp | 4 ++-- 18 files changed, 62 insertions(+), 59 deletions(-) diff --git a/map/drawer_yg.cpp b/map/drawer_yg.cpp index d2ab6d85d8..72280c9da6 100644 --- a/map/drawer_yg.cpp +++ b/map/drawer_yg.cpp @@ -133,7 +133,7 @@ void DrawerYG::drawSymbol(m2::PointD const & pt, rule_ptr_t pRule, yg::EPosition // Use BaseRule::m_id to cache for point draw rule. // This rules doesn't mix with other rule-types. - uint32_t id = pRule->GetID(m_threadID); +// uint32_t id = pRule->GetID(m_threadID); string name; pRule->GetSymbol(name); @@ -285,7 +285,7 @@ bool DrawerYG::drawPathText(di::PathInfo const & info, string const & name, uint void DrawerYG::drawPathNumber(di::PathInfo const & path, di::DrawInfo const * pInfo) { - int const textHeight = 12 * m_visualScale; + int const textHeight = static_cast(12 * m_visualScale); m2::PointD pt; double const length = path.GetFullLength(); if (length >= (pInfo->m_road.size() + 2)*textHeight) @@ -313,7 +313,7 @@ shared_ptr DrawerYG::screen() const return m_pScreen; } -int DrawerYG::VisualScale() const +double DrawerYG::VisualScale() const { return m_visualScale; } diff --git a/map/drawer_yg.hpp b/map/drawer_yg.hpp index 085a570e8f..1a9dc3a602 100644 --- a/map/drawer_yg.hpp +++ b/map/drawer_yg.hpp @@ -114,7 +114,7 @@ public: shared_ptr screen() const; - int VisualScale() const; + double VisualScale() const; void SetScale(int level); void Draw(di::DrawInfo const * pInfo, di::DrawRule const * rules, size_t count); diff --git a/map/information_display.cpp b/map/information_display.cpp index 1682b9d238..bac78154ab 100644 --- a/map/information_display.cpp +++ b/map/information_display.cpp @@ -104,7 +104,7 @@ void InformationDisplay::drawRuler(DrawerYG * pDrawer) /// finding the closest higher metric value unsigned curFirstDigit = 2; - unsigned curVal = m_metresMinWidth; + unsigned curVal = static_cast(m_metresMinWidth); unsigned maxVal = 1000000; bool lessThanMin = false; bool isInfinity = false; @@ -193,8 +193,8 @@ void InformationDisplay::setVisualScale(double visualScale) { m_visualScale = visualScale; - m_fontDesc.m_size = 12 * visualScale; - m_emptyMessageFont.m_size = 14 * visualScale; + m_fontDesc.m_size = static_cast(12 * visualScale); + m_emptyMessageFont.m_size = static_cast(14 * visualScale); } void InformationDisplay::enableCenter(bool doEnable) diff --git a/map/render_policy.cpp b/map/render_policy.cpp index d5f66a0c34..beeec2d701 100644 --- a/map/render_policy.cpp +++ b/map/render_policy.cpp @@ -40,32 +40,32 @@ m2::RectI const RenderPolicy::OnSize(int w, int h) return m2::RectI(0, 0, w, h); } -void RenderPolicy::StartDrag(m2::PointD const & pt, double timeInSec) +void RenderPolicy::StartDrag(m2::PointD const &, double) { m_windowHandle->invalidate(); } -void RenderPolicy::DoDrag(m2::PointD const & pt, double timeInSec) +void RenderPolicy::DoDrag(m2::PointD const &, double) { m_windowHandle->invalidate(); } -void RenderPolicy::StopDrag(m2::PointD const & pt, double timeInSec) +void RenderPolicy::StopDrag(m2::PointD const &, double) { m_windowHandle->invalidate(); } -void RenderPolicy::StartScale(m2::PointD const & pt1, m2::PointD const & pt2, double timeInSec) +void RenderPolicy::StartScale(m2::PointD const &, m2::PointD const &, double) { m_windowHandle->invalidate(); } -void RenderPolicy::DoScale(m2::PointD const & pt1, m2::PointD const & pt2, double timeInSec) +void RenderPolicy::DoScale(m2::PointD const &, m2::PointD const &, double) { m_windowHandle->invalidate(); } -void RenderPolicy::StopScale(m2::PointD const & pt1, m2::PointD const & pt2, double timeInSec) +void RenderPolicy::StopScale(m2::PointD const &, m2::PointD const &, double) { m_windowHandle->invalidate(); } diff --git a/map/render_queue_routine.cpp b/map/render_queue_routine.cpp index 36ddff891d..a6a3315be6 100644 --- a/map/render_queue_routine.cpp +++ b/map/render_queue_routine.cpp @@ -142,7 +142,7 @@ void RenderQueueRoutine::getUpdateAreas( return; if (!o.IsIntersect(n)) { - areas.push_back(m2::RectI(n)); + areas.push_back(newRect); return; } @@ -164,14 +164,14 @@ void RenderQueueRoutine::getUpdateAreas( if (o.maxY() < n.maxY()) bottomBarMinY = floor(o.maxY()); - if (leftBarMinX != leftBarMaxX) - areas.push_back(m2::RectI(leftBarMinX, topBarMinY, leftBarMaxX, bottomBarMinY)); - if (topBarMinY != topBarMaxY) - areas.push_back(m2::RectI(leftBarMaxX, topBarMinY, rightBarMaxX, topBarMaxY)); - if (rightBarMinX != rightBarMaxX) - areas.push_back(m2::RectI(rightBarMinX, topBarMaxY, rightBarMaxX, bottomBarMaxY)); - if (bottomBarMinY != bottomBarMaxY) - areas.push_back(m2::RectI(leftBarMinX, bottomBarMinY, rightBarMinX, bottomBarMaxY)); + if ((int)leftBarMinX != (int)leftBarMaxX) + areas.push_back(m2::RectI((int)leftBarMinX, (int)topBarMinY, (int)leftBarMaxX, (int)bottomBarMinY)); + if ((int)topBarMinY != (int)topBarMaxY) + areas.push_back(m2::RectI((int)leftBarMaxX, (int)topBarMinY, (int)rightBarMaxX, (int)topBarMaxY)); + if ((int)rightBarMinX != (int)rightBarMaxX) + areas.push_back(m2::RectI((int)rightBarMinX, (int)topBarMaxY, (int)rightBarMaxX, (int)bottomBarMaxY)); + if ((int)bottomBarMinY != (int)bottomBarMaxY) + areas.push_back(m2::RectI((int)leftBarMinX, (int)bottomBarMinY, (int)rightBarMinX, (int)bottomBarMaxY)); } else { @@ -386,8 +386,8 @@ void RenderQueueRoutine::Do() ScreenBase const & frameScreen = m_currentRenderCommand->m_frameScreen; m2::RectD glbRect; - frameScreen.PtoG(m2::RectD(textureRect.Center() - m2::PointD(m_scaleEtalonSize / 2, m_scaleEtalonSize / 2), - textureRect.Center() + m2::PointD(m_scaleEtalonSize / 2, m_scaleEtalonSize / 2)), + frameScreen.PtoG(m2::RectD(m2::RectD(textureRect).Center() - m2::PointD(m_scaleEtalonSize / 2, m_scaleEtalonSize / 2), + m2::RectD(textureRect).Center() + m2::PointD(m_scaleEtalonSize / 2, m_scaleEtalonSize / 2)), glbRect); // frameScreen.PtoG(m2::RectD(surfaceRect), glbRect); int scaleLevel = scales::GetScaleLevel(glbRect); diff --git a/map/screen_coverage.cpp b/map/screen_coverage.cpp index 0272e3c38c..bac8ef88a6 100644 --- a/map/screen_coverage.cpp +++ b/map/screen_coverage.cpp @@ -101,7 +101,7 @@ bool LessRectInfo::operator()(Tile const * l, Tile const * r) const return l->m_rectInfo.toUInt64Cell() < r->m_rectInfo.toUInt64Cell(); } -void ScreenCoverage::SetScreen(ScreenBase const & screen, bool mergePathNames) +void ScreenCoverage::SetScreen(ScreenBase const & screen, bool /*mergePathNames*/) { m_screen = screen; @@ -123,7 +123,7 @@ void ScreenCoverage::SetScreen(ScreenBase const & screen, bool mergePathNames) if (drawScale == -1) drawScale = allRects[i].m_drawScale; else - ASSERT(drawScale == allRects[i].m_drawScale, (drawScale, allRects[i].m_drawScale)); + CHECK(drawScale == allRects[i].m_drawScale, (drawScale, allRects[i].m_drawScale)); for (unsigned i = 0; i < allRects.size(); ++i) { diff --git a/map/tile_renderer.cpp b/map/tile_renderer.cpp index 4a69ee365f..f5d3287dfe 100644 --- a/map/tile_renderer.cpp +++ b/map/tile_renderer.cpp @@ -14,7 +14,6 @@ TileRenderer::TileRenderer( string const & skinName, - unsigned scaleEtalonSize, unsigned maxTilesCount, unsigned executorsCount, yg::Color const & bgColor, @@ -76,7 +75,7 @@ TileRenderer::~TileRenderer() m_queue.Cancel(); } -void TileRenderer::CancelThread(core::CommandsQueue::Environment const & env) +void TileRenderer::CancelThread(core::CommandsQueue::Environment const & /*env*/) { m_resourceManager->renderTargets().Cancel(); } diff --git a/map/tile_renderer.hpp b/map/tile_renderer.hpp index 6fc541127d..fcc6dfcda0 100644 --- a/map/tile_renderer.hpp +++ b/map/tile_renderer.hpp @@ -60,7 +60,6 @@ public: /// constructor. TileRenderer(string const & skinName, - unsigned scaleEtalonSize, unsigned maxTilesCount, unsigned tasksCount, yg::Color const & bgColor, diff --git a/map/tiler.cpp b/map/tiler.cpp index 9fe35dda90..f89d9e1b05 100644 --- a/map/tiler.cpp +++ b/map/tiler.cpp @@ -81,7 +81,7 @@ void Tiler::seed(ScreenBase const & screen, m2::PointD const & centerPt) m2::RectD const screenRect = m_screen.GlobalRect(); /// slightly smaller than original to produce "antialiasing" effect using bilinear filtration. - size_t tileSize = m_tileSize / 1.05; + size_t tileSize = static_cast(m_tileSize / 1.05); screen.PtoG(m2::RectD(pxCenter - m2::PointD(tileSize / 2, tileSize / 2), pxCenter + m2::PointD(tileSize / 2, tileSize / 2)), @@ -89,15 +89,15 @@ void Tiler::seed(ScreenBase const & screen, m2::PointD const & centerPt) double glbRectSize = min(glbRect.SizeX(), glbRect.SizeY()); - m_tileScale = ceil(log((MercatorBounds::maxX - MercatorBounds::minX) / glbRectSize) / log(2.0)); + m_tileScale = static_cast(ceil(log((MercatorBounds::maxX - MercatorBounds::minX) / glbRectSize) / log(2.0))); double rectSizeX = (MercatorBounds::maxX - MercatorBounds::minX) / (1 << m_tileScale); double rectSizeY = (MercatorBounds::maxY - MercatorBounds::minY) / (1 << m_tileScale); - int minTileX = floor(screenRect.minX() / rectSizeX); - int maxTileX = ceil(screenRect.maxX() / rectSizeX); - int minTileY = floor(screenRect.minY() / rectSizeY); - int maxTileY = ceil(screenRect.maxY() / rectSizeY); + int minTileX = static_cast(floor(screenRect.minX() / rectSizeX)); + int maxTileX = static_cast(ceil(screenRect.maxX() / rectSizeX)); + int minTileY = static_cast(floor(screenRect.minY() / rectSizeY)); + int maxTileY = static_cast(ceil(screenRect.maxY() / rectSizeY)); /// clearing previous coverage m_coverage.clear(); diff --git a/map/tiling_render_policy_mt.cpp b/map/tiling_render_policy_mt.cpp index 193cabb85a..6541a8a01e 100644 --- a/map/tiling_render_policy_mt.cpp +++ b/map/tiling_render_policy_mt.cpp @@ -17,7 +17,6 @@ TilingRenderPolicyMT::TilingRenderPolicyMT(shared_ptr const & wind RenderPolicy::TRenderFn const & renderFn) : RenderPolicy(windowHandle, renderFn), m_tileRenderer(GetPlatform().SkinName(), - GetPlatform().ScaleEtalonSize(), GetPlatform().MaxTilesCount(), 1, //GetPlatform().CpuCores(), bgColor(), diff --git a/yg/glyph_cache.cpp b/yg/glyph_cache.cpp index 9044e29c5a..ba20b96ab6 100644 --- a/yg/glyph_cache.cpp +++ b/yg/glyph_cache.cpp @@ -290,7 +290,7 @@ namespace yg double len = 0; for (unsigned i = 0; i < s.size(); ++i) { - GlyphKey k(s[i], fontSize, false, yg::Color(0, 0, 0, 255)); + GlyphKey k(s[i], static_cast(fontSize), false, yg::Color(0, 0, 0, 255)); len += getGlyphMetrics(k).m_xAdvance; } diff --git a/yg/path_renderer.cpp b/yg/path_renderer.cpp index 8652a6ccf9..764ad7a87b 100644 --- a/yg/path_renderer.cpp +++ b/yg/path_renderer.cpp @@ -72,7 +72,7 @@ namespace yg } /// Geometry width. It's 1px wider than the pattern width. - int geomWidth = lineStyle->m_penInfo.m_w + 4 - 2 * aaShift(); + int geomWidth = static_cast(lineStyle->m_penInfo.m_w) + 4 - 2 * aaShift(); float geomHalfWidth = geomWidth / 2.0; /// Starting point of the tiles on this segment diff --git a/yg/pen_info.cpp b/yg/pen_info.cpp index f8f8948e34..b26f817c34 100644 --- a/yg/pen_info.cpp +++ b/yg/pen_info.cpp @@ -108,12 +108,12 @@ namespace yg m2::PointU const PenInfo::patternSize() const { if (m_isSolid) - return m2::PointU(ceil(m_w / 2) * 2 + 4, - ceil(m_w / 2) * 2 + 4); + return m2::PointU(static_cast(ceil(m_w / 2)) * 2 + 4, + static_cast(ceil(m_w / 2)) * 2 + 4); else { uint32_t len = static_cast(accumulate(m_pat.begin(), m_pat.end(), 0.0)); - return m2::PointU(len + 4, m_w + 4); + return m2::PointU(len + 4, static_cast(m_w) + 4); } } diff --git a/yg/render_state.cpp b/yg/render_state.cpp index 8fcdb5a167..10b4301774 100644 --- a/yg/render_state.cpp +++ b/yg/render_state.cpp @@ -57,8 +57,8 @@ namespace yg //unsigned oldTextureWidth = m_textureWidth; //unsigned oldTextureHeight = m_textureHeight; - m_textureWidth = pow(2, ceil(log(double(w)) / log2)); - m_textureHeight = pow(2, ceil(log(double(h)) / log2)); + m_textureWidth = static_cast(pow(2, ceil(log(double(w)) / log2))); + m_textureHeight = static_cast(pow(2, ceil(log(double(h)) / log2))); //bool hasChangedTextureSize; //if ((oldTextureWidth != m_textureWidth) || (oldTextureHeight != m_textureHeight)) diff --git a/yg/resource_style.cpp b/yg/resource_style.cpp index 7b3ab35297..20e75d903d 100644 --- a/yg/resource_style.cpp +++ b/yg/resource_style.cpp @@ -37,8 +37,10 @@ namespace yg else { double firstDashOffset = penInfo.firstDashOffset(); - m_centerColorPixel = m2::PointU(firstDashOffset + texRect.minX() + 3, texRect.minY() + texRect.SizeY() / 2.0); - m_borderColorPixel = m2::PointU(firstDashOffset + texRect.minX() + 3, texRect.minY() + 1); + m_centerColorPixel = m2::PointU(static_cast(firstDashOffset + texRect.minX() + 3), + static_cast(texRect.minY() + texRect.SizeY() / 2.0)); + m_borderColorPixel = m2::PointU(static_cast(firstDashOffset + texRect.minX() + 3), + static_cast(texRect.minY() + 1)); } } diff --git a/yg/shape_renderer.cpp b/yg/shape_renderer.cpp index 8d22f24cb9..caa448b08c 100644 --- a/yg/shape_renderer.cpp +++ b/yg/shape_renderer.cpp @@ -28,7 +28,7 @@ namespace yg void ShapeRenderer::approximateArc(m2::PointD const & center, double startA, double endA, double r, vector & pts) { double sectorA = math::pi / 30.0; - size_t const sectorsCount = floor(fabs(endA - startA) / sectorA); + size_t const sectorsCount = static_cast(floor(fabs(endA - startA) / sectorA)); sectorA = (endA - startA) / sectorsCount; for (size_t i = 0; i <= sectorsCount; ++i) @@ -88,7 +88,7 @@ namespace yg for (int i = 0; i < 4; ++i) rectPtsF[i] = m2::PointF(rectPts[i].x, rectPts[i].y); - m2::PointF texPt = skin()->pages()[style->m_pageID]->texture()->mapPixel(style->m_texRect.Center()); + m2::PointF texPt = skin()->pages()[style->m_pageID]->texture()->mapPixel(m2::RectF(style->m_texRect).Center()); addTexturedStripStrided( rectPtsF, @@ -117,7 +117,7 @@ namespace yg m2::PointD(r.maxX(), r.maxY()) }; - m2::PointF texPt = skin()->pages()[style->m_pageID]->texture()->mapPixel(style->m_texRect.Center()); + m2::PointF texPt = skin()->pages()[style->m_pageID]->texture()->mapPixel(m2::RectF(style->m_texRect).Center()); addTexturedStripStrided( rectPts, diff --git a/yg/skin_page.cpp b/yg/skin_page.cpp index f3dd63604d..3ae6abdfe0 100644 --- a/yg/skin_page.cpp +++ b/yg/skin_page.cpp @@ -378,11 +378,13 @@ namespace yg penInfo.m_color.b, penInfo.m_color.a)); + uint32_t ri = static_cast(r); + /// pixels that are used to texture inner part of the line should be fully opaque - v(2 + r - 1, 2) = penColor; - v(2 + r , 2) = penColor; - v(2 + r - 1, 2 + r * 2 - 1) = penColor; - v(2 + r , 2 + r * 2 - 1) = penColor; + v(2 + ri - 1, 2) = penColor; + v(2 + ri , 2) = penColor; + v(2 + ri - 1, 2 + ri * 2 - 1) = penColor; + v(2 + ri , 2 + ri * 2 - 1) = penColor; /// in non-transparent areas - premultiply color value with alpha and make it opaque for (size_t x = 2; x < v.width() - 2; ++x) @@ -435,8 +437,10 @@ namespace yg /// In general case this code is incorrect. /// TODO : Make a pattern start and end with a dash. - v(curLen, y) = px; - v(curLen + 1, y) = px; + uint32_t curLenI = static_cast(curLen); + + v(curLenI, y) = px; + v(curLenI + 1, y) = px; for (size_t i = 0; i < penInfo.m_pat.size(); ++i) { @@ -449,11 +453,11 @@ namespace yg else gil::get_color(px, gil::alpha_t()) = penInfoColor.a; - v(curLen + j + 2, y) = px; + v(curLenI + j + 2, y) = px; } - v(curLen + 2 + penInfo.m_pat[i], y) = px; - v(curLen + 2 + penInfo.m_pat[i] + 1, y) = px; + v(static_cast(curLen + 2 + penInfo.m_pat[i]), y) = px; + v(static_cast(curLen + 2 + penInfo.m_pat[i] + 1), y) = px; curLen += penInfo.m_pat[i]; } diff --git a/yg/symbol_element.cpp b/yg/symbol_element.cpp index ffb2242ca2..2b750b8c68 100644 --- a/yg/symbol_element.cpp +++ b/yg/symbol_element.cpp @@ -36,7 +36,7 @@ namespace yg m2::AARectD const SymbolElement::boundRect() const { - m2::RectU texRect = m_symbolRect; + m2::RectI texRect(m_symbolRect); texRect.Inflate(-1, -1); m2::PointD posPt = tieRect(m2::RectD(texRect), math::Identity()); @@ -56,7 +56,7 @@ namespace yg if (m_style == 0) return; - m2::RectU texRect = m_symbolRect; + m2::RectI texRect(m_symbolRect); texRect.Inflate(-1, -1); m2::PointD posPt = tieRect(m2::RectD(texRect), m);