summaryrefslogtreecommitdiffstats
path: root/src/plugins/gfxdrivers/blittableqvfb/qgraphicssystem_blittableqvfb.h
blob: 89940d0932117d0ec3e5525a7b9ff76307411f8e (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
#include <private/qgraphicssystem_p.h>
#include <private/qpixmap_blitter_p.h>
#include <private/qpixmap_raster_p.h>
#include <QScreen>

#include "qwindowsurface_qwsblittable.h"
#include "qblittable_image.h"
#include <qapplication.h>

class QBlittableVFbGraphicsSystem : public QGraphicsSystem
{
public:
        QPixmapData *createPixmapData(QPixmapData::PixelType type) const
        {
            if (type == QPixmapData::PixmapType) {
                return new QBlittablePixmapData(type);
            } else {
                return new QRasterPixmapData(type);
            }
        }

        QWindowSurface *createWindowSurface(QWidget *widget) const
        {
             if (QApplication::type() == QApplication::GuiServer)
                 return new QWSBlittableMemSurface(widget);
             else
                 return QScreen::instance()->createSurface(widget);
        }

        QBlittable *createBlittable(const QSize &size) const
        {
            QImage *image = new QImage(size,QImage::Format_ARGB32);
            return new QImageBlittable(image,true);
        }

        static QGraphicsSystem *instance()
        {
            static QGraphicsSystem *system = 0;
            if (!system) {
                system = new QBlittableVFbGraphicsSystem;
            }
            return system;
        }

private:
        QBlittableVFbGraphicsSystem() { }
};