MythTV
master
mythtv
libs
libmythui
opengl
mythpainterwindowopengl.cpp
Go to the documentation of this file.
1
#include "
mythpainterwindowopengl.h
"
2
3
#include <QGuiApplication>
4
#include <QWindow>
5
6
#include "
libmythbase/mythlogging.h
"
7
#include "
mythmainwindow.h
"
8
9
#define LOC QString("GLPaintWin: "
)
10
11
MythPainterWindowOpenGL::MythPainterWindowOpenGL
(
MythMainWindow
*MainWin)
12
:
MythPainterWindow
(MainWin),
13
m_parent(MainWin)
14
{
15
setAttribute(Qt::WA_NoSystemBackground);
16
setAttribute(Qt::WA_NativeWindow);
17
setAttribute(Qt::WA_DontCreateNativeAncestors);
18
// The eglfs QPA platform works without setting the surface type and
19
// can only have one OpenGLSurface, which must be the top level widget
20
// (which for us is currently the MythMainWindow).
21
if
(QGuiApplication::platformName() !=
"eglfs"
&& windowHandle() !=
nullptr
)
22
{
23
windowHandle()->setSurfaceType(QWindow::OpenGLSurface);
24
QWindow* window = MainWin->windowHandle();
25
if
(window !=
nullptr
) {
26
window->setSurfaceType(QWindow::OpenGLSurface);
27
}
28
}
29
winId();
30
#ifdef Q_OS_MACOS
31
// must be visible before OpenGL initialisation on OSX
32
setVisible(
true
);
33
#endif
34
MythRenderOpenGL
*render =
MythRenderOpenGL::Create
(
this
);
35
if
(render)
36
{
37
m_render
= render;
38
if
(render->
Init
() && render->
IsRecommendedRenderer
())
39
m_valid
=
true
;
40
}
41
else
42
{
43
LOG
(VB_GENERAL, LOG_ERR,
LOC
+
"Failed to create MythRenderOpenGL"
);
44
}
45
}
46
47
QPaintEngine *
MythPainterWindowOpenGL::paintEngine
(
void
)
const
48
{
49
return
testAttribute(Qt::WA_PaintOnScreen) ? nullptr :
m_parent
->
paintEngine
();
50
}
51
52
MythPainterWindowOpenGL::~MythPainterWindowOpenGL
()
53
{
54
if
(
m_render
)
55
m_render
->
DecrRef
();
56
}
57
58
bool
MythPainterWindowOpenGL::IsValid
(
void
)
const
59
{
60
return
m_valid
;
61
}
62
63
void
MythPainterWindowOpenGL::paintEvent
(QPaintEvent*
/*PaintEvent*/
)
64
{
65
m_parent
->
drawScreen
();
66
}
MythMainWindow
Definition:
mythmainwindow.h:29
MythMainWindow::drawScreen
void drawScreen(QPaintEvent *Event=nullptr)
Definition:
mythmainwindow.cpp:380
MythMainWindow::paintEngine
QPaintEngine * paintEngine() const override
Definition:
mythmainwindow.cpp:476
MythPainterWindowOpenGL::MythPainterWindowOpenGL
MythPainterWindowOpenGL(MythMainWindow *MainWin)
Definition:
mythpainterwindowopengl.cpp:11
MythPainterWindowOpenGL::m_parent
MythMainWindow * m_parent
Definition:
mythpainterwindowopengl.h:27
MythPainterWindowOpenGL::~MythPainterWindowOpenGL
~MythPainterWindowOpenGL() override
Definition:
mythpainterwindowopengl.cpp:52
MythPainterWindowOpenGL::paintEngine
QPaintEngine * paintEngine(void) const override
Definition:
mythpainterwindowopengl.cpp:47
MythPainterWindowOpenGL::IsValid
bool IsValid(void) const
Definition:
mythpainterwindowopengl.cpp:58
MythPainterWindowOpenGL::m_valid
bool m_valid
Definition:
mythpainterwindowopengl.h:28
MythPainterWindowOpenGL::paintEvent
void paintEvent(QPaintEvent *PaintEvent) override
Definition:
mythpainterwindowopengl.cpp:63
MythPainterWindow
Definition:
mythpainterwindow.h:36
MythPainterWindow::m_render
MythRender * m_render
Definition:
mythpainterwindow.h:59
MythRenderOpenGL
Definition:
mythrenderopengl.h:96
MythRenderOpenGL::Create
static MythRenderOpenGL * Create(QWidget *Widget)
Definition:
mythrenderopengl.cpp:77
MythRenderOpenGL::Init
bool Init(void)
Definition:
mythrenderopengl.cpp:206
MythRenderOpenGL::IsRecommendedRenderer
bool IsRecommendedRenderer(void)
Definition:
mythrenderopengl.cpp:461
ReferenceCounter::DecrRef
virtual int DecrRef(void)
Decrements reference count and deletes on 0.
Definition:
referencecounter.cpp:124
mythlogging.h
LOG
#define LOG(_MASK_, _LEVEL_, _QSTRING_)
Definition:
mythlogging.h:39
mythmainwindow.h
LOC
#define LOC
Definition:
mythpainterwindowopengl.cpp:9
mythpainterwindowopengl.h
Generated on Sat Aug 1 2026 03:17:02 for MythTV by
1.9.4