MythTV  master
mythpainteropengl.h
Go to the documentation of this file.
1 #ifndef MYTHPAINTER_OPENGL_H_
2 #define MYTHPAINTER_OPENGL_H_
3 
4 // Qt
5 #include <QMutex>
6 #include <QQueue>
7 
8 // MythTV
9 #include "mythdisplay.h"
10 #include "mythpainter.h"
11 #include "mythimage.h"
12 
13 // Std
14 #include <list>
15 
16 class QWidget;
17 class MythGLTexture;
18 class MythRenderOpenGL;
19 class QOpenGLBuffer;
20 class QOpenGLFramebufferObject;
21 
22 #define MAX_BUFFER_POOL 70
23 
25 {
26  Q_OBJECT
27 
28  public:
29  explicit MythOpenGLPainter(MythRenderOpenGL *Render = nullptr, QWidget *Parent = nullptr);
30  ~MythOpenGLPainter() override;
31 
32  void SetTarget(QOpenGLFramebufferObject* NewTarget) { m_target = NewTarget; }
33  void SetSwapControl(bool Swap) { m_swapControl = Swap; }
34  void DeleteTextures(void);
35 
36  // MythPainter
37  QString GetName(void) override { return QString("OpenGL"); }
38  bool SupportsAnimation(void) override { return true; }
39  bool SupportsAlpha(void) override { return true; }
40  bool SupportsClipping(void) override { return false; }
41  void FreeResources(void) override;
42  void Begin(QPaintDevice *Parent) override;
43  void End() override;
44  void DrawImage(const QRect &Dest, MythImage *Image, const QRect &Source, int Alpha) override;
45  void DrawRect(const QRect &Area, const QBrush &FillBrush,
46  const QPen &LinePen, int Alpha) override;
47  void DrawRoundRect(const QRect &Area, int CornerRadius,
48  const QBrush &FillBrush, const QPen &LinePen, int Alpha) override;
49  void PushTransformation(const UIEffects &Fx, QPointF Center = QPointF()) override;
50  void PopTransformation(void) override;
51 
52  public slots:
53  void CurrentDPIChanged(qreal DPI);
54 
55  protected:
56  void ClearCache(void);
57  MythGLTexture* GetTextureFromCache(MythImage *Image);
58 
59  // MythPainter
60  MythImage* GetFormatImagePriv(void) override { return new MythImage(this); }
61  void DeleteFormatImagePriv(MythImage *Image) override;
62 
63  protected:
64  QWidget *m_widget { nullptr };
65  MythRenderOpenGL *m_render { nullptr };
66  QOpenGLFramebufferObject* m_target { nullptr };
67  bool m_swapControl { true };
68  QSize m_lastSize { };
69  qreal m_pixelRatio { 1.0 };
70  MythDisplay* m_display { nullptr };
71  bool m_usingHighDPI { false };
72 
73  QMap<MythImage *, MythGLTexture*> m_imageToTextureMap;
74  std::list<MythImage *> m_ImageExpireList;
75  std::list<MythGLTexture*> m_textureDeleteList;
77 
78  QVector<MythGLTexture*> m_mappedTextures;
79  QOpenGLBuffer* m_mappedBufferPool[MAX_BUFFER_POOL] { nullptr };
80  int m_mappedBufferPoolIdx { 0 };
81  bool m_mappedBufferPoolReady { false };
82 };
83 
84 #endif
MythOpenGLPainter
Definition: mythpainteropengl.h:24
MythOpenGLPainter::SupportsAlpha
bool SupportsAlpha(void) override
Definition: mythpainteropengl.h:39
MythGLTexture
Definition: mythrenderopengl.h:44
MUI_PUBLIC
#define MUI_PUBLIC
Definition: mythuiexp.h:9
MythOpenGLPainter::m_textureDeleteLock
QMutex m_textureDeleteLock
Definition: mythpainteropengl.h:76
MythPainter::DrawRoundRect
virtual void DrawRoundRect(const QRect &area, int cornerRadius, const QBrush &fillBrush, const QPen &linePen, int alpha)
Definition: mythpainter.cpp:168
MythOpenGLPainter::GetFormatImagePriv
MythImage * GetFormatImagePriv(void) override
Creates a reference counted image, call DecrRef() to delete.
Definition: mythpainteropengl.h:60
MythOpenGLPainter::m_ImageExpireList
std::list< MythImage * > m_ImageExpireList
Definition: mythpainteropengl.h:74
slots
unsigned int slots[4]
Definition: element.cpp:38
MythOpenGLPainter::SupportsAnimation
bool SupportsAnimation(void) override
Definition: mythpainteropengl.h:38
MythPainter::PushTransformation
virtual void PushTransformation(const UIEffects &zoom, QPointF center=QPointF())
Definition: mythpainter.cpp:191
MythPainter::DeleteFormatImagePriv
virtual void DeleteFormatImagePriv(MythImage *im)=0
mythdisplay.h
Source
Definition: channelsettings.cpp:68
MythOpenGLPainter::SetSwapControl
void SetSwapControl(bool Swap)
Definition: mythpainteropengl.h:33
MythOpenGLPainter::SupportsClipping
bool SupportsClipping(void) override
Definition: mythpainteropengl.h:40
MythPainter::DrawImage
virtual void DrawImage(const QRect &dest, MythImage *im, const QRect &src, int alpha)=0
mythpainter.h
MythPainter::FreeResources
virtual void FreeResources(void)
Definition: mythpainter.h:51
MythDisplay
Definition: mythdisplay.h:18
MAX_BUFFER_POOL
#define MAX_BUFFER_POOL
Definition: mythpainteropengl.h:22
MythPainter::End
virtual void End()
Definition: mythpainter.h:53
MythRenderOpenGL
Definition: mythrenderopengl.h:86
MythPainter::DrawRect
virtual void DrawRect(const QRect &area, const QBrush &fillBrush, const QPen &linePen, int alpha)
Definition: mythpainter.cpp:157
mythimage.h
MythOpenGLPainter::GetName
QString GetName(void) override
Definition: mythpainteropengl.h:37
MythOpenGLPainter::m_mappedTextures
QVector< MythGLTexture * > m_mappedTextures
Definition: mythpainteropengl.h:78
MythPainter
Definition: mythpainter.h:32
MythImage
Definition: mythimage.h:36
MythPainter::Begin
virtual void Begin(QPaintDevice *parent)
Definition: mythpainter.h:52
UIEffects
Definition: mythuianimation.h:9
MythPainter::PopTransformation
virtual void PopTransformation(void)
Definition: mythpainter.h:84
MythOpenGLPainter::m_imageToTextureMap
QMap< MythImage *, MythGLTexture * > m_imageToTextureMap
Definition: mythpainteropengl.h:73
MythOpenGLPainter::m_textureDeleteList
std::list< MythGLTexture * > m_textureDeleteList
Definition: mythpainteropengl.h:75
MythOpenGLPainter::SetTarget
void SetTarget(QOpenGLFramebufferObject *NewTarget)
Definition: mythpainteropengl.h:32