MythTV  master
mythpainterwindow.cpp
Go to the documentation of this file.
1 // MythTV
2 #include "mythcorecontext.h"
3 #include "mythmainwindow.h"
4 #include "mythpainter_qt.h"
5 #include "mythpainterwindowqt.h"
6 #include "mythpainterwindow.h"
7 
8 #ifdef USING_OPENGL
11 #endif
12 
13 #ifdef USING_VULKAN
16 #endif
17 
19  MythPainterWindow *&PaintWin,
20  MythPainter *&Painter)
21 {
22  bool warn = false;
23 
24 #ifdef USING_VULKAN
25  auto *vulkan = new MythPainterWindowVulkan(MainWindow);
26  if (vulkan && vulkan->IsValid())
27  {
28  PaintWin = vulkan;
29  auto *render = dynamic_cast<MythRenderVulkan*>(vulkan->GetRenderDevice());
30  auto *window = dynamic_cast<MythWindowVulkan*>(vulkan->GetVulkanWindow());
31  Painter = new MythPainterVulkan(render, window);
32  return QString();
33  }
34  delete vulkan;
35 #endif
36 
37  // only OpenGL provides video playback
38 #ifdef USING_OPENGL
39  auto* glwindow = new MythPainterWindowOpenGL(MainWindow);
40  if (glwindow && glwindow->IsValid())
41  {
42  PaintWin = glwindow;
43  auto *render = dynamic_cast<MythRenderOpenGL*>(glwindow->GetRenderDevice());
44  Painter = new MythOpenGLPainter(render, MainWindow);
45  return QString();
46  }
47  delete glwindow;
48 #endif
49 
50  // Fallback to Qt painter as the last resort.
51  LOG(VB_GENERAL, LOG_INFO, "Using the Qt painter. Video playback will not work!");
52  Painter = new MythQtPainter();
53  PaintWin = new MythPainterWindowQt(MainWindow);
54  warn = QCoreApplication::applicationName() == MYTH_APPNAME_MYTHFRONTEND;
55 
56  return warn ? tr("Warning: OpenGL is not available.") : QString();
57 }
58 
60 {
61  delete Painter;
62  delete PaintWin;
63  Painter = nullptr;
64  PaintWin = nullptr;
65 }
66 
68  : QWidget(MainWin)
69 {
70 }
71 
73 {
74  return m_render;
75 }
76 
78 {
79  return m_render && m_render->IsShared();
80 }
MythPainterWindow::DestroyPainters
static void DestroyPainters(MythPainterWindow *&PaintWin, MythPainter *&Painter)
Definition: mythpainterwindow.cpp:59
MythOpenGLPainter
Definition: mythpainteropengl.h:25
mythpainter_qt.h
MythQtPainter
Definition: mythpainter_qt.h:14
mythpainterwindowqt.h
MythPainterWindow
Definition: mythpainterwindow.h:14
MythPainterWindowOpenGL
Definition: mythpainterwindowopengl.h:11
LOG
#define LOG(_MASK_, _LEVEL_, _QSTRING_)
Definition: mythlogging.h:23
MYTH_APPNAME_MYTHFRONTEND
#define MYTH_APPNAME_MYTHFRONTEND
Definition: mythcorecontext.h:20
mythpaintervulkan.h
MythPainterWindowQt
Definition: mythpainterwindowqt.h:8
MythWindowVulkan
Definition: mythwindowvulkan.h:11
mythpainterwindow.h
MythPainterVulkan
Definition: mythpaintervulkan.h:20
MythPainterWindow::CreatePainters
static QString CreatePainters(MythMainWindow *MainWindow, MythPainterWindow *&PaintWin, MythPainter *&Painter)
Definition: mythpainterwindow.cpp:18
MythPainterWindow::RenderIsShared
bool RenderIsShared(void)
Definition: mythpainterwindow.cpp:77
MythPainterWindow::m_render
MythRender * m_render
Definition: mythpainterwindow.h:29
MythPainterWindow::GetRenderDevice
MythRender * GetRenderDevice(void)
Definition: mythpainterwindow.cpp:72
mythpainteropengl.h
MythRenderOpenGL
Definition: mythrenderopengl.h:95
MythPainterWindowVulkan
Definition: mythpainterwindowvulkan.h:11
mythcorecontext.h
MythRender
Definition: mythrender_base.h:23
MythPainter
Definition: mythpainter.h:33
MythRender::IsShared
bool IsShared(void) const
Warning: The reference count can be decremented between the call to this function and the use of it's...
Definition: mythrender_base.h:33
MythPainterWindow::MythPainterWindow
MythPainterWindow(MythMainWindow *MainWin)
Definition: mythpainterwindow.cpp:67
MythRenderVulkan
Definition: mythrendervulkan.h:29
mythmainwindow.h
MythMainWindow
Definition: mythmainwindow.h:33
mythpainterwindowvulkan.h
mythpainterwindowopengl.h