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
17class MythMainWindow;
18class MythGLTexture;
20class QOpenGLBuffer;
21class QOpenGLFramebufferObject;
22class QOpenGLShaderProgram;
23
24static 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
std::list< MythGLTexture * > m_textureDeleteList
QString GetName(void) override
bool SupportsAlpha(void) override
bool SupportsAnimation(void) override
MythImage * GetFormatImagePriv(void) override
Creates a reference counted image, call DecrRef() to delete.
QVector< MythGLTexture * > m_mappedTextures
QHash< QString, QOpenGLShaderProgram * > m_procedurals
bool SupportsClipping(void) override
QRecursiveMutex m_imageAndTextureLock
std::list< MythImage * > m_imageExpireList
QMap< MythImage *, MythGLTexture * > m_imageToTextureMap
virtual void PushTransformation(const UIEffects &zoom, QPointF center=QPointF())
Definition: mythpainter.h:86
virtual void DrawProcedural(QRect, int, const ProcSource &, const ProcSource &, const QString &)
Definition: mythpainter.h:65
virtual void DeleteFormatImagePriv(MythImage *im)=0
virtual void DrawRect(QRect area, const QBrush &fillBrush, const QPen &linePen, int alpha)
virtual void DrawImage(QRect dest, MythImage *im, QRect src, int alpha)=0
virtual void Begin(QPaintDevice *)
Definition: mythpainter.h:54
virtual void PopTransformation(void)
Definition: mythpainter.h:88
virtual void DrawRoundRect(QRect area, int cornerRadius, const QBrush &fillBrush, const QPen &linePen, int alpha)
virtual void End()
Definition: mythpainter.h:55
virtual void FreeResources(void)
Definition: mythpainter.h:53
std::shared_ptr< QByteArray > ProcSource
Definition: mythpainter.h:32
static constexpr size_t MAX_BUFFER_POOL
#define MUI_PUBLIC
Definition: mythuiexp.h:9