Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mapsme/omim.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/qt
diff options
context:
space:
mode:
authorDaria Volvenkova <d.volvenkova@corp.mail.ru>2018-07-30 21:10:25 +0300
committerRoman Kuznetsov <r.kuznetsow@gmail.com>2018-08-01 16:21:56 +0300
commitbc461840fe7462cb6d55cd3f577824de07583e0c (patch)
tree660b121ddc9dcecc4405151117b355687a77773e /qt
parentbf38632215f55ed8fe284d2e53013bf2fd216aff (diff)
Graphic context added.
Diffstat (limited to 'qt')
-rw-r--r--qt/drape_surface.cpp130
-rw-r--r--qt/drape_surface.hpp48
-rw-r--r--qt/qt_common/qtoglcontext.cpp32
-rw-r--r--qt/qt_common/qtoglcontext.hpp26
-rw-r--r--qt/qt_common/qtoglcontextfactory.cpp12
-rw-r--r--qt/qt_common/qtoglcontextfactory.hpp14
6 files changed, 42 insertions, 220 deletions
diff --git a/qt/drape_surface.cpp b/qt/drape_surface.cpp
deleted file mode 100644
index 67236a2447..0000000000
--- a/qt/drape_surface.cpp
+++ /dev/null
@@ -1,130 +0,0 @@
-#include "qt/drape_surface.hpp"
-
-#include "drape_frontend/viewport.hpp"
-
-#include "base/stl_add.hpp"
-#include "base/logging.hpp"
-
-#include "std/bind.hpp"
-#include "std/cmath.hpp"
-
-#include <QtGui/QMouseEvent>
-
-namespace qt
-{
-
-DrapeSurface::DrapeSurface()
- : m_dragState(false)
- , m_contextFactory(NULL)
-{
- 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_framework.PrepareToShutdown();
- m_contextFactory.Destroy();
-}
-
-void DrapeSurface::LoadState()
-{
- if (!m_framework.LoadState())
- m_framework.ShowAll();
- else
- m_framework.Invalidate();
-}
-
-void DrapeSurface::SaveState()
-{
- m_framework.SaveState();
-}
-
-void DrapeSurface::exposeEvent(QExposeEvent *e)
-{
- Q_UNUSED(e);
-
- if (isExposed())
- {
- if (m_contextFactory.IsNull())
- {
- dp::ThreadSafeFactory * factory = new dp::ThreadSafeFactory(new QtOGLContextFactory(this));
- m_contextFactory = dp::MasterPointer<dp::OGLContextFactory>(factory);
- CreateEngine();
- }
- }
-}
-
-void DrapeSurface::mousePressEvent(QMouseEvent * e)
-{
- QWindow::mousePressEvent(e);
- if (!isExposed())
- return;
-
- if (e->button() == Qt::LeftButton)
- {
- m2::PointF const p = GetDevicePosition(e->pos());
- DragEvent const event(p.x, p.y);
- m_framework.StartDrag(event);
- m_dragState = true;
- }
-}
-
-void DrapeSurface::mouseMoveEvent(QMouseEvent * e)
-{
- QWindow::mouseMoveEvent(e);
- if (!isExposed())
- return;
-
- if (m_dragState)
- {
- m2::PointF const p = GetDevicePosition(e->pos());
- DragEvent const event(p.x, p.y);
- m_framework.DoDrag(event);
- }
-}
-
-void DrapeSurface::mouseReleaseEvent(QMouseEvent * e)
-{
- QWindow::mouseReleaseEvent(e);
- if (!isExposed())
- return;
-
- if (m_dragState)
- {
- m2::PointF const p = GetDevicePosition(e->pos());
- DragEvent const event(p.x, p.y);
- m_framework.StopDrag(event);
- m_dragState = false;
- }
-}
-
-void DrapeSurface::wheelEvent(QWheelEvent * e)
-{
- if (!m_dragState)
- {
- m2::PointF const p = GetDevicePosition(e->pos());
- ScaleToPointEvent const event(p.x, p.y, exp(e->delta() / 360.0));
- m_framework.ScaleToPoint(event, false);
- }
-}
-
-void DrapeSurface::CreateEngine()
-{
- m_framework.CreateDrapeEngine(m_contextFactory.GetRefPointer(), devicePixelRatio(), width(), height());
-}
-
-void DrapeSurface::sizeChanged(int)
-{
- m_framework.OnSize(width(), height());
-}
-
-m2::PointF DrapeSurface::GetDevicePosition(QPoint const & p)
-{
- qreal const ratio = devicePixelRatio();
- return m2::PointF(p.x() * ratio, p.y() * ratio);
-}
-
-}
diff --git a/qt/drape_surface.hpp b/qt/drape_surface.hpp
deleted file mode 100644
index 0e81a95eba..0000000000
--- a/qt/drape_surface.hpp
+++ /dev/null
@@ -1,48 +0,0 @@
-#pragma once
-
-#include "qtoglcontextfactory.hpp"
-
-#include "map/framework.hpp"
-#include "drape_frontend/drape_engine.hpp"
-
-#include <QtGui/QWindow>
-
-namespace qt
-{
-
-class DrapeSurface : public QWindow
-{
- Q_OBJECT
-
-public:
- DrapeSurface();
- ~DrapeSurface();
-
- void LoadState();
- void SaveState();
-
- Framework & GetFramework() { return m_framework; }
-
-protected:
- void exposeEvent(QExposeEvent * e);
- void mousePressEvent(QMouseEvent * e);
- void mouseMoveEvent(QMouseEvent * e);
- void mouseReleaseEvent(QMouseEvent * e);
- void wheelEvent(QWheelEvent * e);
-
-private:
- void CreateEngine();
-
- Q_SLOT void sizeChanged(int);
-
-private:
- m2::PointF GetDevicePosition(QPoint const & p);
-
- bool m_dragState;
-
-private:
- Framework m_framework;
- dp::MasterPointer<dp::OGLContextFactory> m_contextFactory;
-};
-
-} // namespace qt
diff --git a/qt/qt_common/qtoglcontext.cpp b/qt/qt_common/qtoglcontext.cpp
index cfc57799e1..c47f8acd78 100644
--- a/qt/qt_common/qtoglcontext.cpp
+++ b/qt/qt_common/qtoglcontext.cpp
@@ -23,29 +23,29 @@ QtRenderOGLContext::QtRenderOGLContext(QOpenGLContext * rootContext, QOffscreenS
ASSERT(m_ctx->isValid(), ());
}
-void QtRenderOGLContext::present()
+void QtRenderOGLContext::Present()
{
if (!m_resizeLock)
- lockFrame();
+ LockFrame();
m_resizeLock = false;
GLFunctions::glFinish();
std::swap(m_frontFrame, m_backFrame);
- unlockFrame();
+ UnlockFrame();
}
-void QtRenderOGLContext::makeCurrent()
+void QtRenderOGLContext::MakeCurrent()
{
VERIFY(m_ctx->makeCurrent(m_surface), ());
}
-void QtRenderOGLContext::doneCurrent()
+void QtRenderOGLContext::DoneCurrent()
{
m_ctx->doneCurrent();
}
-void QtRenderOGLContext::setDefaultFramebuffer()
+void QtRenderOGLContext::SetDefaultFramebuffer()
{
if (m_backFrame == nullptr)
return;
@@ -53,9 +53,9 @@ void QtRenderOGLContext::setDefaultFramebuffer()
m_backFrame->bind();
}
-void QtRenderOGLContext::resize(int w, int h)
+void QtRenderOGLContext::Resize(int w, int h)
{
- lockFrame();
+ LockFrame();
m_resizeLock = true;
QSize size(my::NextPowOf2(w), my::NextPowOf2(h));
@@ -66,17 +66,17 @@ void QtRenderOGLContext::resize(int w, int h)
m_backFrame = my::make_unique<QOpenGLFramebufferObject>(size, QOpenGLFramebufferObject::Depth);
}
-void QtRenderOGLContext::lockFrame()
+void QtRenderOGLContext::LockFrame()
{
m_lock.lock();
}
-QRectF const & QtRenderOGLContext::getTexRect() const
+QRectF const & QtRenderOGLContext::GetTexRect() const
{
return m_texRect;
}
-GLuint QtRenderOGLContext::getTextureHandle() const
+GLuint QtRenderOGLContext::GetTextureHandle() const
{
if (!m_frontFrame)
return 0;
@@ -84,7 +84,7 @@ GLuint QtRenderOGLContext::getTextureHandle() const
return m_frontFrame->texture();
}
-void QtRenderOGLContext::unlockFrame()
+void QtRenderOGLContext::UnlockFrame()
{
m_lock.unlock();
}
@@ -99,22 +99,22 @@ QtUploadOGLContext::QtUploadOGLContext(QOpenGLContext * rootContext, QOffscreenS
ASSERT(m_ctx->isValid(), ());
}
-void QtUploadOGLContext::makeCurrent()
+void QtUploadOGLContext::MakeCurrent()
{
m_ctx->makeCurrent(m_surface);
}
-void QtUploadOGLContext::doneCurrent()
+void QtUploadOGLContext::DoneCurrent()
{
m_ctx->doneCurrent();
}
-void QtUploadOGLContext::present()
+void QtUploadOGLContext::Present()
{
ASSERT(false, ());
}
-void QtUploadOGLContext::setDefaultFramebuffer()
+void QtUploadOGLContext::SetDefaultFramebuffer()
{
ASSERT(false, ());
}
diff --git a/qt/qt_common/qtoglcontext.hpp b/qt/qt_common/qtoglcontext.hpp
index ff409ea0dc..679fad5313 100644
--- a/qt/qt_common/qtoglcontext.hpp
+++ b/qt/qt_common/qtoglcontext.hpp
@@ -19,16 +19,16 @@ public:
QtRenderOGLContext(QOpenGLContext * rootContext, QOffscreenSurface * surface);
// dp::OGLContext overrides:
- void present() override;
- void makeCurrent() override;
- void doneCurrent() override;
- void setDefaultFramebuffer() override;
- void resize(int w, int h) override;
+ void Present() override;
+ void MakeCurrent() override;
+ void DoneCurrent() override;
+ void SetDefaultFramebuffer() override;
+ void Resize(int w, int h) override;
- void lockFrame();
- GLuint getTextureHandle() const;
- QRectF const & getTexRect() const;
- void unlockFrame();
+ void LockFrame();
+ GLuint GetTextureHandle() const;
+ QRectF const & GetTexRect() const;
+ void UnlockFrame();
private:
QOffscreenSurface * m_surface = nullptr;
@@ -48,10 +48,10 @@ public:
QtUploadOGLContext(QOpenGLContext * rootContext, QOffscreenSurface * surface);
// dp::OGLContext overrides:
- void present() override;
- void makeCurrent() override;
- void doneCurrent() override;
- void setDefaultFramebuffer() override;
+ void Present() override;
+ void MakeCurrent() override;
+ void DoneCurrent() override;
+ void SetDefaultFramebuffer() override;
private:
QOffscreenSurface * m_surface = nullptr; // non-owning ptr
diff --git a/qt/qt_common/qtoglcontextfactory.cpp b/qt/qt_common/qtoglcontextfactory.cpp
index cf16bb3850..525ad736e9 100644
--- a/qt/qt_common/qtoglcontextfactory.cpp
+++ b/qt/qt_common/qtoglcontextfactory.cpp
@@ -32,29 +32,29 @@ bool QtOGLContextFactory::LockFrame()
if (m_preparedToShutdown || !m_drawContext)
return false;
- m_drawContext->lockFrame();
+ m_drawContext->LockFrame();
return true;
}
QRectF const & QtOGLContextFactory::GetTexRect() const
{
ASSERT(m_drawContext != nullptr, ());
- return m_drawContext->getTexRect();
+ return m_drawContext->GetTexRect();
}
GLuint QtOGLContextFactory::GetTextureHandle() const
{
ASSERT(m_drawContext != nullptr, ());
- return m_drawContext->getTextureHandle();
+ return m_drawContext->GetTextureHandle();
}
void QtOGLContextFactory::UnlockFrame()
{
ASSERT(m_drawContext != nullptr, ());
- m_drawContext->unlockFrame();
+ m_drawContext->UnlockFrame();
}
-dp::OGLContext * QtOGLContextFactory::getDrawContext()
+dp::GraphicContext * QtOGLContextFactory::GetDrawContext()
{
if (!m_drawContext)
m_drawContext = my::make_unique<QtRenderOGLContext>(m_rootContext, m_drawSurface.get());
@@ -62,7 +62,7 @@ dp::OGLContext * QtOGLContextFactory::getDrawContext()
return m_drawContext.get();
}
-dp::OGLContext * QtOGLContextFactory::getResourcesUploadContext()
+dp::GraphicContext * QtOGLContextFactory::GetResourcesUploadContext()
{
if (!m_uploadContext)
m_uploadContext = my::make_unique<QtUploadOGLContext>(m_rootContext, m_uploadSurface.get());
diff --git a/qt/qt_common/qtoglcontextfactory.hpp b/qt/qt_common/qtoglcontextfactory.hpp
index 21c133d229..209d556c33 100644
--- a/qt/qt_common/qtoglcontextfactory.hpp
+++ b/qt/qt_common/qtoglcontextfactory.hpp
@@ -1,6 +1,6 @@
#pragma once
-#include "drape/oglcontextfactory.hpp"
+#include "drape/graphic_context_factory.hpp"
#include "qt/qt_common/qtoglcontext.hpp"
#include <QtGui/QOpenGLContext>
@@ -12,7 +12,7 @@ namespace qt
{
namespace common
{
-class QtOGLContextFactory : public dp::OGLContextFactory
+class QtOGLContextFactory : public dp::GraphicContextFactory
{
public:
QtOGLContextFactory(QOpenGLContext * rootContext);
@@ -25,11 +25,11 @@ public:
QRectF const & GetTexRect() const;
void UnlockFrame();
- // dp::OGLContextFactory overrides:
- dp::OGLContext * getDrawContext() override;
- dp::OGLContext * getResourcesUploadContext() override;
- bool isDrawContextCreated() const override { return m_drawContext != nullptr; }
- bool isUploadContextCreated() const override { return m_uploadContext != nullptr; }
+ // dp::GraphicContextFactory overrides:
+ dp::GraphicContext * GetDrawContext() override;
+ dp::GraphicContext * GetResourcesUploadContext() override;
+ bool IsDrawContextCreated() const override { return m_drawContext != nullptr; }
+ bool IsUploadContextCreated() const override { return m_uploadContext != nullptr; }
private:
std::unique_ptr<QOffscreenSurface> CreateSurface();