diff --git a/android/YoPme/jni/Android.mk b/android/YoPme/jni/Android.mk index 89a91b3745..e65e2c61a1 100644 --- a/android/YoPme/jni/Android.mk +++ b/android/YoPme/jni/Android.mk @@ -130,15 +130,13 @@ LOCAL_CFLAGS := -ffunction-sections -fdata-sections -Wno-psabi TARGET_PLATFORM := android-15 # Add your headers below -LOCAL_HEADER_FILES := Stubs.hpp \ - Framework.hpp \ +LOCAL_HEADER_FILES := Framework.hpp \ ../../jni/com/mapswithme/core/jni_helper.hpp \ ../../jni/com/mapswithme/core/logging.hpp \ ../../jni/com/mapswithme/platform/Platform.hpp \ # Add your sources below -LOCAL_SRC_FILES := Stubs.cpp \ - Framework.cpp \ +LOCAL_SRC_FILES := Framework.cpp \ MapRenderer.cpp \ BackscreenActivity.cpp \ ../../jni/com/mapswithme/core/logging.cpp \ diff --git a/android/YoPme/jni/Framework.cpp b/android/YoPme/jni/Framework.cpp index 77d86fbfdc..d3414e8cf2 100644 --- a/android/YoPme/jni/Framework.cpp +++ b/android/YoPme/jni/Framework.cpp @@ -1,27 +1,33 @@ #include "Framework.hpp" -#include "Stubs.hpp" - #include "../../../map/events.hpp" #include "../../../map/navigator.hpp" #include "../../../map/yopme_render_policy.hpp" #include "../../../platform/platform.hpp" #include "../../../geometry/any_rect2d.hpp" +#include "../../../graphics/opengl/gl_render_context.hpp" #include "../../../base/logging.hpp" #include +namespace +{ + class RenderContext: public graphics::gl::RenderContext + { + public: + virtual void makeCurrent() {} + virtual graphics::RenderContext * createShared() { return this; } + }; +} + namespace yopme { - static EmptyVideoTimer s_timer; Framework::Framework(int width, int height) : m_width(width) , m_height(height) { - LOG(LDEBUG, ("Framework Constructor")); // TODO move this in some method like ExternalStorageConnected m_framework.AddLocalMaps(); - LOG(LDEBUG, ("Local maps addeded")); } Framework::~Framework() @@ -48,7 +54,7 @@ namespace yopme RenderPolicy::Params rpParams; - rpParams.m_videoTimer = &s_timer; + rpParams.m_videoTimer = &m_timer; rpParams.m_useDefaultFB = true; rpParams.m_rmParams = rmParams; rpParams.m_primaryRC = primaryRC; diff --git a/android/YoPme/jni/Framework.hpp b/android/YoPme/jni/Framework.hpp index d9deecd4bd..45c2dd4f33 100644 --- a/android/YoPme/jni/Framework.hpp +++ b/android/YoPme/jni/Framework.hpp @@ -3,8 +3,6 @@ #include "../../../map/framework.hpp" #include "../../../platform/video_timer.hpp" -#include "../../../std/shared_ptr.hpp" - namespace yopme { class Framework @@ -22,6 +20,7 @@ namespace yopme private: ::Framework m_framework; + EmptyVideoTimer m_timer; int m_width; int m_height; }; diff --git a/android/YoPme/jni/Stubs.cpp b/android/YoPme/jni/Stubs.cpp deleted file mode 100644 index 90e1f3e000..0000000000 --- a/android/YoPme/jni/Stubs.cpp +++ /dev/null @@ -1,62 +0,0 @@ -#include "Stubs.hpp" - -#include "../../../std/bind.hpp" - -namespace yopme -{ - -void RenderContext::makeCurrent() -{ -} - -graphics::RenderContext * RenderContext::createShared() -{ - return this; -} - -void empty() -{ -} - -EmptyVideoTimer::EmptyVideoTimer() - : VideoTimer(bind(&empty)) -{ -} - -EmptyVideoTimer::~EmptyVideoTimer() -{ - stop(); -} - -void EmptyVideoTimer::start() -{ - if (m_state == EStopped) - m_state = ERunning; -} - -void EmptyVideoTimer::resume() -{ - if (m_state == EPaused) - { - m_state = EStopped; - start(); - } -} - -void EmptyVideoTimer::pause() -{ - stop(); - m_state = EPaused; -} - -void EmptyVideoTimer::stop() -{ - if (m_state == ERunning) - m_state = EStopped; -} - -void EmptyVideoTimer::perform() -{ -} - -} // namespace yopme diff --git a/android/YoPme/jni/Stubs.hpp b/android/YoPme/jni/Stubs.hpp deleted file mode 100644 index fc9f299075..0000000000 --- a/android/YoPme/jni/Stubs.hpp +++ /dev/null @@ -1,28 +0,0 @@ -#include "../../../graphics/opengl/gl_render_context.hpp" -#include "../../../platform/video_timer.hpp" - -namespace yopme -{ - -class RenderContext: public graphics::gl::RenderContext -{ -public: - virtual void makeCurrent(); - virtual graphics::RenderContext * createShared(); -}; - -class EmptyVideoTimer: public VideoTimer -{ - typedef VideoTimer base_t; -public: - EmptyVideoTimer(); - ~EmptyVideoTimer(); - - void start(); - void resume(); - void pause(); - void stop(); - void perform(); -}; - -} // namespace yopme diff --git a/map_server/main.cpp b/map_server/main.cpp index 00d63a7cd4..b747cdbdda 100644 --- a/map_server/main.cpp +++ b/map_server/main.cpp @@ -46,9 +46,7 @@ MwmRpcService::MwmRpcService(QObject * parent) : m_pixelBuffer(new QGLPixelBuffe rmParams.m_texRtFormat = graphics::Data4Bpp; rmParams.m_videoMemoryLimit = GetPlatform().VideoMemoryLimit(); - m_videoTimer = new EmptyVideoTimer(); - - m_rpParams.m_videoTimer = m_videoTimer; + m_rpParams.m_videoTimer = &m_videoTimer; m_rpParams.m_useDefaultFB = true; m_rpParams.m_rmParams = rmParams; m_rpParams.m_primaryRC = primaryRC; @@ -67,6 +65,11 @@ MwmRpcService::MwmRpcService(QObject * parent) : m_pixelBuffer(new QGLPixelBuffe } } +MwmRpcService::~MwmRpcService() +{ + m_framework.PrepareToShutdown(); +} + QString MwmRpcService::RenderBox( QVariant const & bbox, int width, diff --git a/map_server/main.hpp b/map_server/main.hpp index 52691e3ea4..24bc608c82 100644 --- a/map_server/main.hpp +++ b/map_server/main.hpp @@ -2,61 +2,11 @@ #include "../map/render_policy.hpp" #include "../map/framework.hpp" - -#include "../platform/platform.hpp" +#include "../platform/video_timer.hpp" #include #include -namespace -{ - void empty() - {} - - class EmptyVideoTimer : public VideoTimer - { - public: - EmptyVideoTimer() - : VideoTimer(bind(&empty)) - {} - - ~EmptyVideoTimer() - { - stop(); - } - - void start() - { - if (m_state == EStopped) - m_state = ERunning; - } - - void resume() - { - if (m_state == EPaused) - { - m_state = EStopped; - start(); - } - } - - void pause() - { - stop(); - m_state = EPaused; - } - - void stop() - { - if (m_state == ERunning) - m_state = EStopped; - } - - void perform() - {} - }; -} - class MwmRpcService : public QJsonRpcService { Q_OBJECT @@ -65,9 +15,10 @@ private: Framework m_framework; QGLPixelBuffer * m_pixelBuffer; RenderPolicy::Params m_rpParams; - VideoTimer * m_videoTimer; + EmptyVideoTimer m_videoTimer; public: MwmRpcService(QObject * parent = 0); + ~MwmRpcService(); public Q_SLOTS: QString RenderBox( diff --git a/platform/video_timer.cpp b/platform/video_timer.cpp index 8f731f58a3..8a2fab5c9d 100644 --- a/platform/video_timer.cpp +++ b/platform/video_timer.cpp @@ -1,5 +1,7 @@ #include "video_timer.hpp" +#include "../std/bind.hpp" + VideoTimer::VideoTimer(TFrameFn fn) : m_frameFn(fn), m_state(EStopped) {} @@ -20,3 +22,49 @@ void VideoTimer::setFrameFn(TFrameFn fn) { m_frameFn = fn; } + +namespace +{ + void empty() {} +} + +EmptyVideoTimer::EmptyVideoTimer() + : base_t(bind(&empty)) +{ +} + +EmptyVideoTimer::~EmptyVideoTimer() +{ + stop(); +} + +void EmptyVideoTimer::start() +{ + if (m_state == EStopped) + m_state = ERunning; +} + +void EmptyVideoTimer::resume() +{ + if (m_state == EPaused) + { + m_state = EStopped; + start(); + } +} + +void EmptyVideoTimer::pause() +{ + stop(); + m_state = EPaused; +} + +void EmptyVideoTimer::stop() +{ + if (m_state == ERunning) + m_state = EStopped; +} + +void EmptyVideoTimer::perform() +{ +} diff --git a/platform/video_timer.hpp b/platform/video_timer.hpp index 58e4201f7c..b91c13736f 100644 --- a/platform/video_timer.hpp +++ b/platform/video_timer.hpp @@ -37,6 +37,20 @@ public: virtual void stop() = 0; }; +class EmptyVideoTimer : public VideoTimer +{ + typedef VideoTimer base_t; +public: + EmptyVideoTimer(); + ~EmptyVideoTimer(); + + void start(); + void resume(); + void pause(); + void stop(); + void perform(); +}; + extern "C" VideoTimer * CreateIOSVideoTimer(VideoTimer::TFrameFn frameFn); extern "C" VideoTimer * CreateAppleVideoTimer(VideoTimer::TFrameFn frameFn); extern "C" VideoTimer * CreateWin32VideoTimer(VideoTimer::TFrameFn frameFn); diff --git a/yopme_desktop/glwidget.cpp b/yopme_desktop/glwidget.cpp index 46f65eb26f..f1c5447f37 100644 --- a/yopme_desktop/glwidget.cpp +++ b/yopme_desktop/glwidget.cpp @@ -1,71 +1,25 @@ #include "glwidget.hpp" -#include "../base/logging.hpp" -#include "../graphics/render_context.hpp" #include "../map/qgl_render_context.hpp" #include "../map/simple_render_policy.hpp" #include "../map/yopme_render_policy.hpp" #include "../graphics/render_context.hpp" -#include "../std/shared_ptr.hpp" -#include "../platform/video_timer.hpp" +#include "../graphics/render_context.hpp" #include "../platform/platform.hpp" -namespace -{ - void empty() - { - } - class EmptyVideoTimer : public VideoTimer - { - typedef VideoTimer base_t; - public: - EmptyVideoTimer(TFrameFn func) - : base_t(bind(&empty)) - { - } - - ~EmptyVideoTimer() { stop(); } - - void start() - { - if (m_state == EStopped) - m_state = ERunning; - } - - void resume() - { - if (m_state == EPaused) - { - m_state = EStopped; - start(); - } - } - - void pause() - { - stop(); - m_state = EPaused; - } - - void stop() - { - if (m_state == ERunning) - m_state = EStopped; - } - - void perform() {} - }; -} - GLWidget::GLWidget(QWidget * parent) : QGLWidget(parent) { m_f.AddLocalMaps(); } +GLWidget::~GLWidget() +{ + m_f.PrepareToShutdown(); +} + void GLWidget::initializeGL() { - EmptyVideoTimer * timer = new EmptyVideoTimer(bind(&QGLWidget::updateGL, this)); shared_ptr primaryRC(new qt::gl::RenderContext(this)); graphics::ResourceManager::Params rmParams; rmParams.m_rtFormat = graphics::Data8Bpp; @@ -75,7 +29,7 @@ void GLWidget::initializeGL() RenderPolicy::Params rpParams; - rpParams.m_videoTimer = timer; + rpParams.m_videoTimer = &m_timer; rpParams.m_useDefaultFB = true; rpParams.m_rmParams = rmParams; rpParams.m_primaryRC = primaryRC; @@ -86,8 +40,8 @@ void GLWidget::initializeGL() try { - //m_f.SetRenderPolicy(new SimpleRenderPolicy(rpParams)); m_f.SetRenderPolicy(new YopmeRP(rpParams)); + m_f.InitGuiSubsystem(); } catch (RootException & e) { diff --git a/yopme_desktop/glwidget.hpp b/yopme_desktop/glwidget.hpp index b97389645c..22d14de6e6 100644 --- a/yopme_desktop/glwidget.hpp +++ b/yopme_desktop/glwidget.hpp @@ -3,11 +3,13 @@ #include #include "../map/framework.hpp" +#include "../platform/video_timer.hpp" class GLWidget : public QGLWidget { public: GLWidget(QWidget * parent); + ~GLWidget(); protected: void initializeGL(); @@ -16,4 +18,5 @@ protected: private: Framework m_f; + EmptyVideoTimer m_timer; };