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