MythTV  master
videovisualgoom.cpp
Go to the documentation of this file.
1 // MythTV
2 #include "mythlogging.h"
3 #include "mythmainwindow.h"
4 #ifdef USING_OPENGL
6 #endif
7 #include "videovisualgoom.h"
8 
9 // Goom
10 #include "goom/goom_tools.h"
11 #include "goom/goom_core.h"
12 
14  : VideoVisual(Audio, Render),
15  m_buffer(nullptr),
16  m_glSurface(nullptr),
17  m_hd(HD)
18 {
19  int max_width = m_hd ? 1200 : 600;
20  int max_height = m_hd ? 800 : 400;
22  QSize sz = mw ? mw->GetUIScreenRect().size() : QSize(600, 400);
23  int width = (sz.width() > max_width) ? max_width : sz.width();
24  int height = (sz.height() > max_height) ? max_height : sz.height();
25  m_area = QRect(0, 0, width, height);
26  goom_init(static_cast<guint32>(width), static_cast<guint32>(height), 0);
27  LOG(VB_GENERAL, LOG_INFO, QString("Initialised Goom (%1x%2)").arg(width).arg(height));
28 }
29 
31 {
32 #ifdef USING_OPENGL
34  {
35  auto * glrender = dynamic_cast<MythRenderOpenGL*>(m_render);
36  if (glrender)
37  glrender->DeleteTexture(m_glSurface);
38  m_glSurface = nullptr;
39  }
40 #endif
41 
42  goom_close();
43 }
44 
45 void VideoVisualGoom::Draw(const QRect Area, MythPainter* /*Painter*/, QPaintDevice* /*Device*/)
46 {
47  if (m_disabled || !m_render || Area.isEmpty())
48  return;
49 
50  QMutexLocker lock(mutex());
51  unsigned int* last = m_buffer;
52  VisualNode* node = GetNode();
53  if (node)
54  {
55  size_t numSamps = 512;
56  if (node->m_length < 512)
57  numSamps = static_cast<size_t>(node->m_length);
58 
59  GoomDualData data {};
60  for (size_t i = 0; i < numSamps; i++)
61  {
62  data[0][i] = node->m_left[i];
63  data[1][i] = node->m_right ? node->m_right[i] : data[0][i];
64  }
65 
66  m_buffer = goom_update(data, 0);
67  }
68 
69 #ifdef USING_OPENGL
70  if ((m_render->Type() == kRenderOpenGL))
71  {
72  auto * glrender = dynamic_cast<MythRenderOpenGL*>(m_render);
73  if (glrender && m_buffer)
74  {
75  glrender->makeCurrent();
76 
77  if (!m_glSurface)
78  {
79  QImage image(m_area.size(), QImage::Format_ARGB32);
80  m_glSurface = glrender->CreateTextureFromQImage(&image);
81  }
82 
83  if (m_glSurface)
84  {
85  m_glSurface->m_crop = false;
86  if (m_buffer != last)
88  // goom doesn't render properly due to changes in video alpha blending
89  // so turn blend off
90  glrender->SetBlend(false);
91  std::vector<MythGLTexture*> surfaces {m_glSurface};
92  glrender->DrawBitmap(surfaces, nullptr, m_area, Area, nullptr, 0);
93  glrender->SetBlend(true);
94  }
95  glrender->doneCurrent();
96  }
97  return;
98  }
99 #endif
100 }
101 
103 {
104  public:
105  const QString& name(void) const override
106  {
107  static QString s_name(GOOM_NAME);
108  return s_name;
109  }
110 
111  VideoVisual* Create(AudioPlayer* Audio, MythRender* Render) const override
112  {
113  return new VideoVisualGoom(Audio, Render, false);
114  }
115 
116  bool SupportedRenderer(RenderType Type) override;
118 
120 {
121  return (Type == kRenderOpenGL);
122 }
123 
125 {
126  public:
127  const QString& name(void) const override
128  {
129  static QString s_name(GOOMHD_NAME);
130  return s_name;
131  }
132 
133  VideoVisual* Create(AudioPlayer* Audio, MythRender *Render) const override
134  {
135  return new VideoVisualGoom(Audio, Render, true);
136  }
137 
138  bool SupportedRenderer(RenderType Type) override;
140 
142 {
143  return (Type == kRenderOpenGL);
144 }
GoomDualData
std::array< GoomSingleData, 2 > GoomDualData
Definition: goom_core.h:12
VideoVisualGoom::VideoVisualGoom
VideoVisualGoom(AudioPlayer *Audio, MythRender *Render, bool HD)
Definition: videovisualgoom.cpp:13
MythGLTexture::m_texture
QOpenGLTexture * m_texture
Definition: mythrenderopengl.h:69
MythUIScreenBounds::GetUIScreenRect
QRect GetUIScreenRect()
Definition: mythuiscreenbounds.cpp:195
VideoVisualGoom::m_hd
bool m_hd
Definition: videovisualgoom.h:23
AudioPlayer
Definition: audioplayer.h:28
VisualNode
Definition: videovisual.h:24
GOOMHD_NAME
#define GOOMHD_NAME
Definition: videovisualgoom.h:9
VideoVisual::m_disabled
bool m_disabled
Definition: videovisual.h:70
VideoVisualGoom::m_glSurface
MythGLTexture * m_glSurface
Definition: videovisualgoom.h:22
MythGLTexture::m_pixelFormat
QOpenGLTexture::PixelFormat m_pixelFormat
Definition: mythrenderopengl.h:70
MythGLTexture::m_crop
bool m_crop
Definition: mythrenderopengl.h:76
VideoVisualGoomHDFactory
Definition: videovisualgoom.cpp:124
kRenderOpenGL
@ kRenderOpenGL
Definition: mythrender_base.h:19
LOG
#define LOG(_MASK_, _LEVEL_, _QSTRING_)
Definition: mythlogging.h:23
VideoVisualGoomHDFactory
VideoVisualGoomHDFactory VideoVisualGoomHDFactory
VisualNode::m_left
short * m_left
Definition: videovisual.h:36
VideoVisualGoomHDFactory::Create
VideoVisual * Create(AudioPlayer *Audio, MythRender *Render) const override
Definition: videovisualgoom.cpp:133
VideoVisualGoomFactory::SupportedRenderer
bool SupportedRenderer(RenderType Type) override
Definition: videovisualgoom.cpp:119
MythGLTexture::m_pixelType
QOpenGLTexture::PixelType m_pixelType
Definition: mythrenderopengl.h:71
mythrenderopengl.h
mythlogging.h
VisualNode::m_right
short * m_right
Definition: videovisual.h:37
VideoVisualGoomHDFactory::name
const QString & name(void) const override
Definition: videovisualgoom.cpp:127
goom_core.h
VideoVisualFactory
Definition: videovisual.h:77
MythTV::Visual::mutex
QMutex * mutex()
Definition: visual.h:26
RenderType
RenderType
Definition: mythrender_base.h:15
MythRenderOpenGL::makeCurrent
void makeCurrent()
Definition: mythrenderopengl.cpp:564
MythRenderOpenGL::DeleteTexture
void DeleteTexture(MythGLTexture *Texture)
Definition: mythrenderopengl.cpp:714
goom_init
void goom_init(guint32 resx, guint32 resy, int cinemascope)
Definition: goom_core.cpp:69
VideoVisualGoomFactory
Definition: videovisualgoom.cpp:102
goom_update
guint32 * goom_update(GoomDualData &data, int forceMode)
Definition: goom_core.cpp:137
goom_close
void goom_close()
Definition: goom_core.cpp:853
MythRenderOpenGL
Definition: mythrenderopengl.h:99
VisualNode::m_length
long m_length
Definition: videovisual.h:38
VideoVisualGoomHDFactory::SupportedRenderer
bool SupportedRenderer(RenderType Type) override
Definition: videovisualgoom.cpp:141
MythRender
Definition: mythrender_base.h:23
MythPainter
Definition: mythpainter.h:32
VideoVisualGoom
Definition: videovisualgoom.h:11
goom_tools.h
VideoVisual::m_render
MythRender * m_render
Definition: videovisual.h:72
VideoVisualGoom::m_buffer
unsigned int * m_buffer
Definition: videovisualgoom.h:21
GOOM_NAME
#define GOOM_NAME
Definition: videovisualgoom.h:8
VideoVisualGoom::Draw
void Draw(QRect Area, MythPainter *Painter, QPaintDevice *Device) override
Definition: videovisualgoom.cpp:45
GetMythMainWindow
MythMainWindow * GetMythMainWindow(void)
Definition: mythmainwindow.cpp:104
VideoVisualGoomFactory::Create
VideoVisual * Create(AudioPlayer *Audio, MythRender *Render) const override
Definition: videovisualgoom.cpp:111
VideoVisual
Definition: videovisual.h:42
MythRender::Type
RenderType Type(void) const
Definition: mythrender_base.h:32
guint32
#define guint32
Definition: goomconfig.h:35
videovisualgoom.h
VideoVisual::m_area
QRect m_area
Definition: videovisual.h:71
VideoVisualGoomFactory
VideoVisualGoomFactory VideoVisualGoomFactory
VideoVisual::GetNode
VisualNode * GetNode(void)
Definition: videovisual.cpp:82
mythmainwindow.h
VideoVisualGoom::~VideoVisualGoom
~VideoVisualGoom() override
Definition: videovisualgoom.cpp:30
MythMainWindow
Definition: mythmainwindow.h:35
VideoVisualGoomFactory::name
const QString & name(void) const override
Definition: videovisualgoom.cpp:105