blob: 2d8093da5376c603494c3a638b35cedbcc8a1219 (
plain)
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
66
67
68
69
70
71
72
73
74
75
76
77
78
|
#include "qt/qtoglcontextfactory.hpp"
#include "base/assert.hpp"
QtOGLContextFactory::QtOGLContextFactory(QOpenGLContext * rootContext)
: m_rootContext(rootContext)
, m_drawContext(nullptr)
, m_uploadContext(nullptr)
{
m_uploadSurface = createSurface();
m_drawSurface = createSurface();
}
QtOGLContextFactory::~QtOGLContextFactory()
{
delete m_drawContext;
delete m_uploadContext;
m_drawSurface->destroy();
m_uploadSurface->destroy();
delete m_drawSurface;
delete m_uploadSurface;
}
bool QtOGLContextFactory::LockFrame()
{
if (m_drawContext == nullptr)
return false;
m_drawContext->lockFrame();
return true;
}
QRectF const & QtOGLContextFactory::GetTexRect() const
{
ASSERT(m_drawContext != nullptr, ());
return m_drawContext->getTexRect();
}
GLuint QtOGLContextFactory::GetTextureHandle() const
{
ASSERT(m_drawContext != nullptr, ());
return m_drawContext->getTextureHandle();
}
void QtOGLContextFactory::UnlockFrame()
{
ASSERT(m_drawContext != nullptr, ());
m_drawContext->unlockFrame();
}
dp::OGLContext * QtOGLContextFactory::getDrawContext()
{
if (m_drawContext == nullptr)
m_drawContext = new QtRenderOGLContext(m_rootContext, m_drawSurface);
return m_drawContext;
}
dp::OGLContext * QtOGLContextFactory::getResourcesUploadContext()
{
if (m_uploadContext == nullptr)
m_uploadContext = new QtUploadOGLContext(m_rootContext, m_uploadSurface);
return m_uploadContext;
}
QOffscreenSurface * QtOGLContextFactory::createSurface()
{
QSurfaceFormat format = m_rootContext->format();
QOffscreenSurface * result = new QOffscreenSurface(m_rootContext->screen());
result->setFormat(format);
result->create();
ASSERT(result->isValid(), ());
return result;
}
|