summaryrefslogtreecommitdiff
path: root/src/plugins/gfxdrivers/blittableqvfb/qwindowsurface_qwsblittable.h
blob: b9553222f862c5d4325bf1eb687bbd0460cb9cc9 (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
#include "qblittable_image.h"

#include <private/qpixmap_blitter_p.h>
#include <private/qwindowsurface_qws_p.h>

class QBlittablePixmapData;

class Q_GUI_EXPORT QWSBlittableMemSurface : public QWSLocalMemSurface
{
public:
    QWSBlittableMemSurface( QWidget *window )
        : QWSLocalMemSurface(window),
        m_currentPaintDevice(0),
        pmData(new QBlittablePixmapData(QPixmapData::PixmapType)),
        pm(pmData)
    {
    }

    QPaintDevice *paintDevice()
    {
        if (QWSLocalMemSurface::paintDevice() != m_currentPaintDevice) {
            QPaintDevice *device = QWSLocalMemSurface::paintDevice();
            if (device->devType() == QInternal::Image) {
                img = *static_cast<QImage *>(device);
                pmData->setBlittable(new QImageBlittable(&img,false));
            }
        }
        return &pm;
    }

private:
    QPaintDevice *m_currentPaintDevice;
    QBlittablePixmapData *pmData;
    QPixmap pm;
};