forked from mapsme/omim
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathqtoglcontext.hpp
65 lines (52 loc) · 1.63 KB
/
qtoglcontext.hpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#pragma once
#include "drape/oglcontext.hpp"
#include <QtGui/QOffscreenSurface>
#include <QtGui/QOpenGLFramebufferObject>
#include <QtGui/QOpenGLContext>
#include <atomic>
#include <memory>
#include <mutex>
namespace qt
{
namespace common
{
class QtRenderOGLContext : public dp::OGLContext
{
public:
QtRenderOGLContext(QOpenGLContext * rootContext, QOffscreenSurface * surface);
void Present() override;
void MakeCurrent() override;
void DoneCurrent() override;
void SetFramebuffer(ref_ptr<dp::BaseFramebuffer> framebuffer) override;
void Resize(int w, int h) override;
bool AcquireFrame();
GLuint GetTextureHandle() const;
QRectF const & GetTexRect() const;
private:
QOffscreenSurface * m_surface = nullptr;
std::unique_ptr<QOpenGLContext> m_ctx;
std::unique_ptr<QOpenGLFramebufferObject> m_frontFrame;
std::unique_ptr<QOpenGLFramebufferObject> m_backFrame;
std::unique_ptr<QOpenGLFramebufferObject> m_acquiredFrame;
QRectF m_acquiredFrameRect = QRectF(0.0, 0.0, 0.0, 0.0);
QRectF m_frameRect = QRectF(0.0, 0.0, 0.0, 0.0);
bool m_frameUpdated = false;
std::atomic<bool> m_isContextAvailable;
int m_width = 0;
int m_height = 0;
std::mutex m_frameMutex;
};
class QtUploadOGLContext: public dp::OGLContext
{
public:
QtUploadOGLContext(QOpenGLContext * rootContext, QOffscreenSurface * surface);
void Present() override;
void MakeCurrent() override;
void DoneCurrent() override;
void SetFramebuffer(ref_ptr<dp::BaseFramebuffer> framebuffer) override;
private:
QOffscreenSurface * m_surface = nullptr; // non-owning ptr
std::unique_ptr<QOpenGLContext> m_ctx;
};
} // namespace common
} // namespace qt