move EmptyVideoTimer to platform/video_timer.

This commit is contained in:
ExMix 2013-09-10 15:41:48 +03:00 committed by Alex Zolotarev
parent 0eca7c07eb
commit 8a76d786cd
11 changed files with 97 additions and 211 deletions

View file

@ -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 \

View file

@ -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 <android/log.h>
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;

View file

@ -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;
};

View file

@ -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

View file

@ -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

View file

@ -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,

View file

@ -2,61 +2,11 @@
#include "../map/render_policy.hpp"
#include "../map/framework.hpp"
#include "../platform/platform.hpp"
#include "../platform/video_timer.hpp"
#include <qjsonrpcservice.h>
#include <QGLPixelBuffer>
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(

View file

@ -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()
{
}

View file

@ -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);

View file

@ -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<graphics::RenderContext> 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)
{

View file

@ -3,11 +3,13 @@
#include <QtOpenGL/QGLWidget>
#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;
};