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