MythTV master
mythpainterwindowopengl.cpp
Go to the documentation of this file.
2
3#include <QGuiApplication>
4#include <QWindow>
5
7#include "mythmainwindow.h"
8
9#define LOC QString("GLPaintWin: ")
10
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
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
47QPaintEngine *MythPainterWindowOpenGL::paintEngine(void) const
48{
49 return testAttribute(Qt::WA_PaintOnScreen) ? nullptr : m_parent->paintEngine();
50}
51
53{
54 if (m_render)
56}
57
59{
60 return m_valid;
61}
62
63void MythPainterWindowOpenGL::paintEvent(QPaintEvent* /*PaintEvent*/)
64{
66}
void drawScreen(QPaintEvent *Event=nullptr)
QPaintEngine * paintEngine() const override
MythPainterWindowOpenGL(MythMainWindow *MainWin)
QPaintEngine * paintEngine(void) const override
void paintEvent(QPaintEvent *PaintEvent) override
MythRender * m_render
static MythRenderOpenGL * Create(QWidget *Widget)
bool IsRecommendedRenderer(void)
virtual int DecrRef(void)
Decrements reference count and deletes on 0.
#define LOG(_MASK_, _LEVEL_, _QSTRING_)
Definition: mythlogging.h:39
#define LOC