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 "mythpainter.h"
10 #include "mythimage.h"
11 
12 // Std
13 #include <list>
14 
15 class QWidget;
16 class MythGLTexture;
17 class MythRenderOpenGL;
18 class QOpenGLBuffer;
19 class QOpenGLFramebufferObject;
20 
21 #define MAX_BUFFER_POOL 70
22 
24 {
25  public:
26  explicit MythOpenGLPainter(MythRenderOpenGL *Render = nullptr, QWidget *Parent = nullptr);
27  ~MythOpenGLPainter() override;
28 
29  void SetTarget(QOpenGLFramebufferObject* NewTarget) { m_target = NewTarget; }
30  void SetSwapControl(bool Swap) { m_swapControl = Swap; }
31  void DeleteTextures(void);
32 
33  // MythPainter
34  QString GetName(void) override { return QString("OpenGL"); }
35  bool SupportsAnimation(void) override { return true; }
36  bool SupportsAlpha(void) override { return true; }
37  bool SupportsClipping(void) override { return false; }
38  void FreeResources(void) override;
39  void Begin(QPaintDevice *Parent) override;
40  void End() override;
41  void DrawImage(const QRect &Dest, MythImage *Image, const QRect &Source, int Alpha) override;
42  void DrawRect(const QRect &Area, const QBrush &FillBrush,
43  const QPen &LinePen, int Alpha) override;
44  void DrawRoundRect(const QRect &Area, int CornerRadius,
45  const QBrush &FillBrush, const QPen &LinePen, int Alpha) override;
46  void PushTransformation(const UIEffects &Fx, QPointF Center = QPointF()) override;
47  void PopTransformation(void) override;
48 
49  protected:
50  void ClearCache(void);
51  MythGLTexture* GetTextureFromCache(MythImage *Image);
52 
53  // MythPainter
54  MythImage* GetFormatImagePriv(void) override { return new MythImage(this); }
55  void DeleteFormatImagePriv(MythImage *Image) override;
56 
57  protected:
58  QWidget *m_parent { nullptr };
59  MythRenderOpenGL *m_render { nullptr };
60  QOpenGLFramebufferObject* m_target { nullptr };
61  bool m_swapControl { true };
62  QSize m_lastSize { };
63 
64  QMap<MythImage *, MythGLTexture*> m_imageToTextureMap;
65  std::list<MythImage *> m_ImageExpireList;
66  std::list<MythGLTexture*> m_textureDeleteList;
68 
69  QVector<MythGLTexture*> m_mappedTextures;
70  QOpenGLBuffer* m_mappedBufferPool[MAX_BUFFER_POOL] { nullptr };
71  int m_mappedBufferPoolIdx { 0 };
72  bool m_mappedBufferPoolReady { false };
73 };
74 
75 #endif
void SetTarget(QOpenGLFramebufferObject *NewTarget)
QMap< MythImage *, MythGLTexture * > m_imageToTextureMap
void SetSwapControl(bool Swap)
std::list< MythGLTexture * > m_textureDeleteList
virtual void DrawRoundRect(const QRect &area, int cornerRadius, const QBrush &fillBrush, const QPen &linePen, int alpha)
bool SupportsClipping(void) override
virtual void End()
Definition: mythpainter.h:51
bool SupportsAnimation(void) override
std::list< MythImage * > m_ImageExpireList
virtual void FreeResources(void)
Definition: mythpainter.h:49
virtual void PushTransformation(const UIEffects &zoom, QPointF center=QPointF())
virtual void DrawRect(const QRect &area, const QBrush &fillBrush, const QPen &linePen, int alpha)
virtual void DeleteFormatImagePriv(MythImage *im)=0
virtual void DrawImage(const QRect &dest, MythImage *im, const QRect &src, int alpha)=0
#define MUI_PUBLIC
Definition: mythuiexp.h:9
Definition: image.h:30
QString GetName(void) override
bool SupportsAlpha(void) override
MythImage * GetFormatImagePriv(void) override
Creates a reference counted image, call DecrRef() to delete.
#define MAX_BUFFER_POOL
virtual void Begin(QPaintDevice *parent)
Definition: mythpainter.h:50
virtual void PopTransformation(void)
Definition: mythpainter.h:82
QVector< MythGLTexture * > m_mappedTextures