summaryrefslogtreecommitdiffstats
path: root/src/plugins/graphicssystems/fb_base/fb_base.h
blob: 8b130d23bfce472d316e77bf486017145470be7b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
#ifndef QLIGHTHOUSEGRAPHICSSCREEN_H
#define QLIGHTHOUSEGRAPHICSSCREEN_H

#include <QtGui/private/qgraphicssystem_p.h>
#include <qrect.h>
#include <qimage.h>
#include <qtimer.h>
#include <qpainter.h>
#include <QGraphicsSystemCursor>

class QMouseEvent;
class QSize;
class QPainter;

class QGraphicsSystemFbWindowSurface;
class QGraphicsSystemFbScreen;

class QGraphicsSystemSoftwareCursor : public QGraphicsSystemCursor
{
public:
    QGraphicsSystemSoftwareCursor(QGraphicsSystemScreen * scr);

    // output methods
    QRect dirtyRect();
    virtual QRect drawCursor(QPainter & painter);

    // input methods
    virtual void pointerEvent(const QMouseEvent & event);
    virtual void changeCursor(QCursor * widgetCursor, QWidget * widget);

protected:
    QGraphicsSystemCursorImage * graphic;

private:
    void setCursor(const uchar *data, const uchar *mask, int width, int height, int hotX, int hotY);
    void setCursor(Qt::CursorShape shape);
    void setCursor(const QImage * image, int hotx, int hoty);
    QRect currentRect;      // next place to draw the cursor
    QRect prevRect;         // last place the cursor was drawn
    QRect getCurrentRect();
};

class QGraphicsSystemFbWindowSurface : public QWindowSurface
{
public:
    QGraphicsSystemFbWindowSurface(QGraphicsSystemFbScreen *screen, QWidget *window);
    ~QGraphicsSystemFbWindowSurface();

    virtual QPaintDevice *paintDevice() { return &mImage; }
    virtual void flush(QWidget *widget, const QRegion &region, const QPoint &offset);
    virtual bool scroll(const QRegion &area, int dx, int dy);

    virtual void beginPaint(const QRegion &region);
    virtual void endPaint(const QRegion &region);
    virtual void setVisible(bool visible);
    virtual bool visible() { return visibleFlag; }

    const QImage image() { return mImage; }
    void setGeometry(const QRect &rect);

    virtual void raise();
    virtual void lower();

    virtual Qt::WindowFlags setWindowFlags(Qt::WindowFlags type);
    virtual Qt::WindowFlags windowFlags() const;

    WId winId() const { return windowId; }
protected:
    QGraphicsSystemFbScreen *mScreen;
    QRect oldGeometry;
    QImage mImage;
    bool visibleFlag;
    Qt::WindowFlags flags;

    WId windowId;
};

class QGraphicsSystemFbScreen : public QGraphicsSystemScreen
{
    Q_OBJECT
public:
    QGraphicsSystemFbScreen();
    ~QGraphicsSystemFbScreen();

    virtual QRect geometry() const { return mGeometry; }
    virtual int depth() const { return mDepth; }
    virtual QImage::Format format() const { return mFormat; }
    virtual QSize physicalSize() const { return mPhysicalSize; }

    virtual void setGeometry(QRect rect);
    virtual void setDepth(int depth);
    virtual void setFormat(QImage::Format format);
    virtual void setPhysicalSize(QSize size);

    virtual void setDirty(const QRect &rect);

    virtual void removeWindowSurface(QGraphicsSystemFbWindowSurface * surface);
    virtual void addWindowSurface(QGraphicsSystemFbWindowSurface * surface) { windowStack.prepend(surface); }
    virtual void raise(QWindowSurface * surface);
    virtual void lower(QWindowSurface * surface);
    virtual QWidget * topLevelAt(const QPoint & p) const;

    QImage * image() const { return mScreenImage; }
    QPaintDevice * paintDevice() const { return mScreenImage; }

protected:
    QList<QGraphicsSystemFbWindowSurface *> windowStack;
    QRegion repaintRegion;
    QGraphicsSystemSoftwareCursor * cursor;
    QTimer redrawTimer;

protected slots:
    virtual QRegion doRedraw();

protected:
    QRect mGeometry;
    int mDepth;
    QImage::Format mFormat;
    QSize mPhysicalSize;
    QImage *mScreenImage;
};

#endif // QLIGHTHOUSEGRAPHICSSCREEN_H