#ifndef DRAWING_WINDOW_H
#define DRAWING_WINDOW_H
+#include <QBasicTimer>
+#include <QColor>
+#include <QImage>
+#include <QMutex>
+#include <QRect>
+#include <QWaitCondition>
#include <QWidget>
#include <Qt>
-class DrawingWindowPrivate;
+class DrawingThread;
class DrawingWindow: public QWidget {
public:
void timerEvent(QTimerEvent *ev);
private:
- DrawingWindowPrivate * const d;
+ static const int paintInterval = 33;
- friend class DrawingWindowPrivate;
+ QBasicTimer timer;
+ QMutex imageMutex;
+ QMutex syncMutex;
+ QWaitCondition syncCondition;
+ bool terminateThread;
+ int lockCount;
+
+ QImage *image;
+ QPainter *painter;
+
+ QColor fgColor;
+ QColor bgColor;
+
+ bool dirtyFlag;
+ QRect dirtyRect;
+
+ DrawingThread *thread;
+
+ void initialize(ThreadFunction f);
+
+ void applyColor();
+
+ void safeLock(QMutex &mutex);
+ void safeUnlock(QMutex &mutex);
+
+ void dirty();
+ void dirty(int x, int y);
+ void dirty(int x1, int y1, int x2, int y2);
+ void dirty(const QRect &rect);
+
+ void mayUpdate();
};
#endif // !DRAWING_WINDOW_H