diff options
Diffstat (limited to 'drape_head/drape_surface.cpp')
-rw-r--r-- | drape_head/drape_surface.cpp | 43 |
1 files changed, 20 insertions, 23 deletions
diff --git a/drape_head/drape_surface.cpp b/drape_head/drape_surface.cpp index 8aeca78781..886f3b4eab 100644 --- a/drape_head/drape_surface.cpp +++ b/drape_head/drape_surface.cpp @@ -5,47 +5,44 @@ #include "base/logging.hpp" DrapeSurface::DrapeSurface() - : m_contextFactory(nullptr) { - setSurfaceType(QSurface::OpenGLSurface); - - QObject::connect(this, SIGNAL(heightChanged(int)), this, SLOT(sizeChanged(int))); - QObject::connect(this, SIGNAL(widthChanged(int)), this, SLOT(sizeChanged(int))); } DrapeSurface::~DrapeSurface() { + m_timer.stop(); + m_drapeEngine.reset(); } -void DrapeSurface::exposeEvent(QExposeEvent *e) +void DrapeSurface::initializeGL() { - Q_UNUSED(e); + CreateEngine(); + m_timer.setInterval(1000 / 30); + m_timer.setSingleShot(false); - if (isExposed()) - { - if (m_contextFactory == nullptr) - { - m_contextFactory = make_unique_dp<dp::ThreadSafeFactory>(new QtOGLContextFactory(this), false); - CreateEngine(); - } - } + connect(&m_timer, SIGNAL(timeout()), SLOT(update())); + m_timer.start(); } -void DrapeSurface::CreateEngine() +void DrapeSurface::paintGL() { - float const pixelRatio = devicePixelRatio(); - m_drapeEngine = make_unique_dp<df::TestingEngine>(make_ref(m_contextFactory), - df::Viewport(0, 0, pixelRatio * width(), pixelRatio * height()), - pixelRatio); + m_drapeEngine->Draw(); } -void DrapeSurface::sizeChanged(int) +void DrapeSurface::resizeGL(int width, int height) { if (m_drapeEngine != nullptr) { float const vs = devicePixelRatio(); - int const w = width() * vs; - int const h = height() * vs; + int const w = width * vs; + int const h = height * vs; m_drapeEngine->Resize(w, h); } } + +void DrapeSurface::CreateEngine() +{ + float const pixelRatio = devicePixelRatio(); + m_drapeEngine = make_unique_dp<df::TestingEngine>(df::Viewport(0, 0, pixelRatio * width(), pixelRatio * height()), + pixelRatio); +} |