00001 #ifndef MYTHPAINTER_OPENGL_H_
00002 #define MYTHPAINTER_OPENGL_H_
00003
00004 #include <QMutex>
00005 #include <QGLWidget>
00006
00007 #include <list>
00008
00009 #include "mythpainter.h"
00010 #include "mythimage.h"
00011 #include "mythrender_opengl.h"
00012
00013 class MUI_PUBLIC MythOpenGLPainter : public MythPainter
00014 {
00015 public:
00016 MythOpenGLPainter(MythRenderOpenGL *render = NULL, QGLWidget *parent = NULL);
00017 ~MythOpenGLPainter();
00018
00019 void SetTarget(int new_target) { target = new_target; }
00020 void SetSwapControl(bool swap) { swapControl = swap; }
00021 virtual QString GetName(void) { return QString("OpenGL"); }
00022 virtual bool SupportsAnimation(void) { return true; }
00023 virtual bool SupportsAlpha(void) { return true; }
00024 virtual bool SupportsClipping(void) { return false; }
00025 virtual void FreeResources(void);
00026 virtual void Begin(QPaintDevice *parent);
00027 virtual void End();
00028
00029 virtual void DrawImage(const QRect &dest, MythImage *im, const QRect &src,
00030 int alpha);
00031 virtual void DrawRect(const QRect &area, const QBrush &fillBrush,
00032 const QPen &linePen, int alpha);
00033 virtual void DrawRoundRect(const QRect &area, int cornerRadius,
00034 const QBrush &fillBrush, const QPen &linePen,
00035 int alpha);
00036
00037 virtual void PushTransformation(const UIEffects &fx, QPointF center = QPointF());
00038 virtual void PopTransformation(void);
00039
00040 protected:
00041 virtual MythImage* GetFormatImagePriv(void) { return new MythImage(this); }
00042 virtual void DeleteFormatImagePriv(MythImage *im);
00043
00044 void ClearCache(void);
00045 void DeleteTextures(void);
00046 int GetTextureFromCache(MythImage *im);
00047
00048 QGLWidget *realParent;
00049 MythRenderOpenGL *realRender;
00050 int target;
00051 bool swapControl;
00052
00053 QMap<MythImage *, uint> m_ImageIntMap;
00054 std::list<MythImage *> m_ImageExpireList;
00055 std::list<uint> m_textureDeleteList;
00056 QMutex m_textureDeleteLock;
00057 };
00058
00059 #endif