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