From a48fcf33aae5585f8cefff0b333872c506fe3370 Mon Sep 17 00:00:00 2001 From: vng Date: Tue, 3 Jul 2012 16:15:46 -0700 Subject: [PATCH] Remove useless Framework::m_hasPendingXXX. --- map/benchmark_framework.cpp | 6 ++-- map/framework.cpp | 61 +++++++++++++++++++++++-------------- map/framework.hpp | 46 +++++++++++++++------------- qt/draw_widget.cpp | 2 +- qt/mainwindow.cpp | 1 + 5 files changed, 68 insertions(+), 48 deletions(-) diff --git a/map/benchmark_framework.cpp b/map/benchmark_framework.cpp index 11fef0463f..cd15debe7f 100644 --- a/map/benchmark_framework.cpp +++ b/map/benchmark_framework.cpp @@ -1,14 +1,16 @@ #include "benchmark_framework.hpp" #include "benchmark_provider.hpp" +#include "../platform/settings.hpp" +#include "../platform/platform.hpp" + #include "../coding/file_container.hpp" #include "../std/fstream.hpp" -#include "../platform/settings.hpp" - #include "../version/version.hpp" + template class DoGetBenchmarks { set m_processed; diff --git a/map/framework.cpp b/map/framework.cpp index b42d2a0a07..fff8642bc0 100644 --- a/map/framework.cpp +++ b/map/framework.cpp @@ -6,14 +6,6 @@ #include "../defines.hpp" -#include "../gui/controller.hpp" - -#include "../platform/settings.hpp" -#include "../platform/preferred_languages.hpp" -#include "../platform/location.hpp" - -#include "../yg/rendercontext.hpp" - #include "../search/search_engine.hpp" #include "../search/result.hpp" @@ -21,6 +13,15 @@ #include "../indexer/feature.hpp" #include "../indexer/scales.hpp" +#include "../gui/controller.hpp" + +#include "../platform/settings.hpp" +#include "../platform/preferred_languages.hpp" +#include "../platform/platform.hpp" + +#include "../yg/rendercontext.hpp" +#include "../yg/render_state.hpp" + #include "../base/math.hpp" #include "../std/algorithm.hpp" @@ -140,11 +141,12 @@ static void GetResourcesMaps(vector & outMaps) } Framework::Framework() - : m_hasPendingInvalidate(false), - m_doForceUpdate(false), + : //m_hasPendingInvalidate(false), + //m_doForceUpdate(false), + m_etalonSize(GetPlatform().ScaleEtalonSize()), m_queryMaxScaleMode(false), m_drawPlacemark(false), - m_hasPendingShowRectFixed(false), + //m_hasPendingShowRectFixed(false), m_metresMinWidth(10), m_metresMaxWidth(1000000), #if defined(OMIM_OS_MAC) || defined(OMIM_OS_WINDOWS) || defined(OMIM_OS_LINUX) @@ -201,8 +203,8 @@ Framework::Framework() for_each(maps.begin(), maps.end(), bind(&Framework::AddMap, this, _1)); m_storage.Init(bind(&Framework::AddMap, this, _1), - bind(&Framework::RemoveMap, this, _1), - bind(&Framework::InvalidateRect, this, _1, true)); + bind(&Framework::RemoveMap, this, _1), + bind(&Framework::InvalidateRect, this, _1, true)); LOG(LDEBUG, ("Storage initialized")); } @@ -348,8 +350,8 @@ bool Framework::NeedRedraw() const void Framework::SetNeedRedraw(bool flag) { m_renderPolicy->GetWindowHandle()->setNeedRedraw(flag); - if (!flag) - m_doForceUpdate = false; + //if (!flag) + // m_doForceUpdate = false; } void Framework::Invalidate(bool doForceUpdate) @@ -366,12 +368,14 @@ void Framework::InvalidateRect(m2::RectD const & rect, bool doForceUpdate) m_renderPolicy->SetInvalidRect(m2::AnyRectD(rect)); m_renderPolicy->GetWindowHandle()->invalidate(); } + /* else { m_hasPendingInvalidate = true; m_doForceUpdate = doForceUpdate; m_invalidRect = m2::AnyRectD(rect); } + */ } void Framework::SaveState() @@ -602,19 +606,22 @@ void Framework::ShowRectFixed(m2::RectD rect) { CheckMinGlobalRect(rect); + /* if (!m_renderPolicy) { m_pendingFixedRect = rect; m_hasPendingShowRectFixed = true; return; } + */ - size_t const sz = m_renderPolicy->ScaleEtalonSize(); - m2::RectD etalonRect(0, 0, sz, sz); - etalonRect.Offset(-etalonRect.SizeX() / 2, -etalonRect.SizeY()); + //size_t const sz = m_renderPolicy->ScaleEtalonSize(); + + /// @todo Get stored value instead of m_renderPolicy call because of invalid render policy here. + m2::RectD etalonRect(0, 0, m_etalonSize, m_etalonSize); + etalonRect.Offset(-m_etalonSize / 2, -m_etalonSize); m2::PointD const pxCenter = m_navigator.Screen().PixelRect().Center(); - etalonRect.Offset(pxCenter); m_navigator.SetFromRects(m2::AnyRectD(rect), etalonRect); @@ -940,11 +947,14 @@ void Framework::SetRenderPolicy(RenderPolicy * renderPolicy) m_guiController->ResetRenderParams(); m_renderPolicy.reset(renderPolicy); - if (m_renderPolicy.get()) + if (m_renderPolicy) { - gui::Controller::RenderParams rp(renderPolicy->VisualScale(), - bind(&WindowHandle::invalidate, renderPolicy->GetWindowHandle().get()), - renderPolicy->GetGlyphCache()); + m_etalonSize = m_renderPolicy->ScaleEtalonSize(); + + gui::Controller::RenderParams rp(m_renderPolicy->VisualScale(), + bind(&WindowHandle::invalidate, + renderPolicy->GetWindowHandle().get()), + m_renderPolicy->GetGlyphCache()); m_guiController->SetRenderParams(rp); @@ -958,6 +968,10 @@ void Framework::SetRenderPolicy(RenderPolicy * renderPolicy) if (m_width != 0 && m_height != 0) OnSize(m_width, m_height); + // Do full invalidate except of any "pending" stuff. + Invalidate(); + + /* if (m_hasPendingInvalidate) { m_renderPolicy->SetForceUpdate(m_doForceUpdate); @@ -971,6 +985,7 @@ void Framework::SetRenderPolicy(RenderPolicy * renderPolicy) ShowRectFixed(m_pendingFixedRect); m_hasPendingShowRectFixed = false; } + */ } } diff --git a/map/framework.hpp b/map/framework.hpp index 3edb7acea0..44e2003edf 100644 --- a/map/framework.hpp +++ b/map/framework.hpp @@ -1,8 +1,8 @@ #pragma once #include "events.hpp" -#include "drawer_yg.hpp" -#include "tile_renderer.hpp" +//#include "drawer_yg.hpp" +#include "render_policy.hpp" #include "information_display.hpp" #include "window_handle.hpp" #include "location_state.hpp" @@ -16,30 +16,30 @@ #include "../storage/storage.hpp" -#include "../indexer/mercator.hpp" -#include "../indexer/data_header.hpp" -#include "../indexer/scales.hpp" +//#include "../indexer/mercator.hpp" +//#include "../indexer/data_header.hpp" +//#include "../indexer/scales.hpp" -#include "../platform/platform.hpp" +//#include "../platform/platform.hpp" #include "../platform/location.hpp" #include "../yg/defines.hpp" #include "../yg/screen.hpp" #include "../yg/color.hpp" -#include "../yg/render_state.hpp" -#include "../yg/skin.hpp" -#include "../yg/resource_manager.hpp" -#include "../yg/overlay.hpp" +//#include "../yg/render_state.hpp" +//#include "../yg/skin.hpp" +//#include "../yg/resource_manager.hpp" +//#include "../yg/overlay.hpp" -#include "../coding/file_reader.hpp" -#include "../coding/file_writer.hpp" +//#include "../coding/file_reader.hpp" +//#include "../coding/file_writer.hpp" #include "../geometry/rect2d.hpp" #include "../geometry/screenbase.hpp" #include "../base/logging.hpp" //#include "../base/mutex.hpp" -#include "../base/timer.hpp" +//#include "../base/timer.hpp" #include "../base/strings_bundle.hpp" #include "../std/vector.hpp" @@ -50,13 +50,10 @@ //#define DRAW_TOUCH_POINTS -class DrawerYG; -class RenderPolicy; +//class DrawerYG; +//class RenderPolicy; namespace search { class Result; } -namespace gui -{ - class Controller; -} +namespace gui { class Controller; } class CountryStatusDisplay; @@ -73,10 +70,15 @@ protected: vector m_bookmarks; scoped_ptr m_renderPolicy; - bool m_hasPendingInvalidate, m_doForceUpdate, m_queryMaxScaleMode, m_drawPlacemark, m_hasPendingShowRectFixed; + /// @todo Need deep analyzing in future. + /// Now it's like a replacement of "m_hasPendingXXX" stuff. + int m_etalonSize; - m2::RectD m_pendingFixedRect; - m2::AnyRectD m_invalidRect; + //bool m_hasPendingInvalidate, m_doForceUpdate, m_queryMaxScaleMode, m_drawPlacemark, m_hasPendingShowRectFixed; + bool m_queryMaxScaleMode, m_drawPlacemark; + + //m2::RectD m_pendingFixedRect; + //m2::AnyRectD m_invalidRect; m2::PointD m_placemark; double const m_metresMinWidth; diff --git a/qt/draw_widget.cpp b/qt/draw_widget.cpp index fd90f8d21c..ebc4358953 100644 --- a/qt/draw_widget.cpp +++ b/qt/draw_widget.cpp @@ -10,13 +10,13 @@ #include "../yg/internal/opengl.hpp" #include "../platform/settings.hpp" +#include "../platform/platform.hpp" #include #include #include #include -using namespace storage; namespace qt { diff --git a/qt/mainwindow.cpp b/qt/mainwindow.cpp index 1aa9369c94..a28f7e6c0f 100644 --- a/qt/mainwindow.cpp +++ b/qt/mainwindow.cpp @@ -8,6 +8,7 @@ #include "../defines.hpp" #include "../platform/settings.hpp" +#include "../platform/platform.hpp" #include "../std/bind.hpp"