MythTV  master
mythpainteropengl.h
Go to the documentation of this file.
1 #ifndef MYTHPAINTER_OPENGL_H_
2 #define MYTHPAINTER_OPENGL_H_
3 
4 // Std
5 #include <array>
6 #include <list>
7 
8 // Qt
9 #include <QMutex>
10 #include <QRecursiveMutex>
11 #include <QQueue>
12 
13 // MythTV
14 #include "libmythui/mythimage.h"
16 
17 class MythMainWindow;
18 class MythGLTexture;
19 class MythRenderOpenGL;
20 class QOpenGLBuffer;
21 class QOpenGLFramebufferObject;
22 class QOpenGLShaderProgram;
23 
24 static constexpr size_t MAX_BUFFER_POOL { 70 };
25 
27 {
28  Q_OBJECT
29 
30  public:
32  ~MythOpenGLPainter() override;
33 
34  void DeleteTextures(void);
35 
36  QString GetName(void) override { return {"OpenGL"}; }
37  bool SupportsAnimation(void) override { return true; }
38  bool SupportsAlpha(void) override { return true; }
39  bool SupportsClipping(void) override { return false; }
40  void FreeResources(void) override;
41  void Begin(QPaintDevice *Parent) override;
42  void End() override;
43  void DrawImage(QRect Dest, MythImage *Image, QRect Source, int Alpha) override;
44  void DrawProcedural(QRect Dest, int Alpha, const ProcSource& VertexSource, const ProcSource& FragmentSource, const QString& SourceHash) override;
45 
46  void DrawRect(QRect Area, const QBrush &FillBrush,
47  const QPen &LinePen, int Alpha) override;
48  void DrawRoundRect(QRect Area, int CornerRadius,
49  const QBrush &FillBrush, const QPen &LinePen, int Alpha) override;
50  void PushTransformation(const UIEffects &Fx, QPointF Center = QPointF()) override;
51  void PopTransformation(void) override;
52 
53  protected:
54  void ClearCache(void);
55  MythGLTexture* GetTextureFromCache(MythImage *Image);
56  QOpenGLShaderProgram* GetProceduralShader(const ProcSource& VertexSource, const ProcSource& FragmentSource, const QString& SourceHash);
57 
58  MythImage* GetFormatImagePriv(void) override { return new MythImage(this); }
59  void DeleteFormatImagePriv(MythImage *Image) override;
60 
61  protected:
62  MythRenderOpenGL *m_render { nullptr };
63 
64  QRecursiveMutex m_imageAndTextureLock;
65  QMap<MythImage *, MythGLTexture*> m_imageToTextureMap;
66  std::list<MythImage *> m_imageExpireList;
67  std::list<MythGLTexture*> m_textureDeleteList;
68 
69  QVector<MythGLTexture*> m_mappedTextures;
70  std::array<QOpenGLBuffer*,MAX_BUFFER_POOL> m_mappedBufferPool { nullptr };
71  size_t m_mappedBufferPoolIdx { 0 };
72  bool m_mappedBufferPoolReady { false };
73 
74  QHash<QString,QOpenGLShaderProgram*> m_procedurals;
75 };
76 
77 #endif
MythOpenGLPainter
Definition: mythpainteropengl.h:26
MythOpenGLPainter::m_imageExpireList
std::list< MythImage * > m_imageExpireList
Definition: mythpainteropengl.h:66
MythOpenGLPainter::SupportsAlpha
bool SupportsAlpha(void) override
Definition: mythpainteropengl.h:38
MythGLTexture
Definition: mythrenderopengl.h:56
MUI_PUBLIC
#define MUI_PUBLIC
Definition: mythuiexp.h:9
MythPainter::DrawProcedural
virtual void DrawProcedural(QRect, int, const ProcSource &, const ProcSource &, const QString &)
Definition: mythpainter.h:65
mythpaintergpu.h
MythOpenGLPainter::GetFormatImagePriv
MythImage * GetFormatImagePriv(void) override
Creates a reference counted image, call DecrRef() to delete.
Definition: mythpainteropengl.h:58
MythOpenGLPainter::m_imageAndTextureLock
QRecursiveMutex m_imageAndTextureLock
Definition: mythpainteropengl.h:64
MAX_BUFFER_POOL
static constexpr size_t MAX_BUFFER_POOL
Definition: mythpainteropengl.h:24
MythPainter::DrawRect
virtual void DrawRect(QRect area, const QBrush &fillBrush, const QPen &linePen, int alpha)
Definition: mythpainter.cpp:157
MythOpenGLPainter::SupportsAnimation
bool SupportsAnimation(void) override
Definition: mythpainteropengl.h:37
Image
Definition: image.h:33
MythPainter::DeleteFormatImagePriv
virtual void DeleteFormatImagePriv(MythImage *im)=0
Source
Definition: channelsettings.cpp:93
MythOpenGLPainter::SupportsClipping
bool SupportsClipping(void) override
Definition: mythpainteropengl.h:39
MythPainter::DrawImage
virtual void DrawImage(QRect dest, MythImage *im, QRect src, int alpha)=0
MythPainter::FreeResources
virtual void FreeResources(void)
Definition: mythpainter.h:53
MythOpenGLPainter::m_procedurals
QHash< QString, QOpenGLShaderProgram * > m_procedurals
Definition: mythpainteropengl.h:74
MythPainter::End
virtual void End()
Definition: mythpainter.h:55
MythRenderOpenGL
Definition: mythrenderopengl.h:96
mythimage.h
ProcSource
std::shared_ptr< QByteArray > ProcSource
Definition: mythpainter.h:32
MythOpenGLPainter::GetName
QString GetName(void) override
Definition: mythpainteropengl.h:36
MythOpenGLPainter::m_mappedTextures
QVector< MythGLTexture * > m_mappedTextures
Definition: mythpainteropengl.h:69
MythImage
Definition: mythimage.h:36
UIEffects
Definition: mythuianimation.h:13
MythPainter::PopTransformation
virtual void PopTransformation(void)
Definition: mythpainter.h:88
MythPainter::Begin
virtual void Begin(QPaintDevice *)
Definition: mythpainter.h:54
MythPainter::DrawRoundRect
virtual void DrawRoundRect(QRect area, int cornerRadius, const QBrush &fillBrush, const QPen &linePen, int alpha)
Definition: mythpainter.cpp:168
MythMainWindow
Definition: mythmainwindow.h:28
MythOpenGLPainter::m_imageToTextureMap
QMap< MythImage *, MythGLTexture * > m_imageToTextureMap
Definition: mythpainteropengl.h:65
MythOpenGLPainter::m_textureDeleteList
std::list< MythGLTexture * > m_textureDeleteList
Definition: mythpainteropengl.h:67
MythPainterGPU
Definition: mythpaintergpu.h:11
MythPainter::PushTransformation
virtual void PushTransformation([[maybe_unused]] const UIEffects &zoom, [[maybe_unused]] QPointF center=QPointF())
Definition: mythpainter.h:86