summaryrefslogtreecommitdiffstats
path: root/src/plugins/graphicssystems/blittable
diff options
context:
space:
mode:
Diffstat (limited to 'src/plugins/graphicssystems/blittable')
-rw-r--r--src/plugins/graphicssystems/blittable/blittable.pro11
-rw-r--r--src/plugins/graphicssystems/blittable/main.cpp73
-rw-r--r--src/plugins/graphicssystems/blittable/qblittable_image.h48
-rw-r--r--src/plugins/graphicssystems/blittable/qgraphicssystem_blittable.h53
4 files changed, 185 insertions, 0 deletions
diff --git a/src/plugins/graphicssystems/blittable/blittable.pro b/src/plugins/graphicssystems/blittable/blittable.pro
new file mode 100644
index 0000000..34c4165
--- /dev/null
+++ b/src/plugins/graphicssystems/blittable/blittable.pro
@@ -0,0 +1,11 @@
+TARGET = qblittablegraphicssystem
+include(../../qpluginbase.pri)
+
+QTDIR_build:DESTDIR = $$QT_BUILD_TREE/plugins/graphicssystems
+
+SOURCES = main.cpp
+HEADERS = qblittable_image.h \
+ qgraphicssystem_blittable.h
+
+target.path += $$[QT_INSTALL_PLUGINS]/graphicssystems
+INSTALLS += target
diff --git a/src/plugins/graphicssystems/blittable/main.cpp b/src/plugins/graphicssystems/blittable/main.cpp
new file mode 100644
index 0000000..06c3189
--- /dev/null
+++ b/src/plugins/graphicssystems/blittable/main.cpp
@@ -0,0 +1,73 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the plugins of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <private/qgraphicssystemplugin_p.h>
+
+#include "qgraphicssystem_blittable.h"
+
+QT_BEGIN_NAMESPACE
+
+class QBlittableGraphicsSystemPlugin : public QGraphicsSystemPlugin
+{
+public:
+ QStringList keys() const;
+ QGraphicsSystem *create(const QString&);
+};
+
+QStringList QBlittableGraphicsSystemPlugin::keys() const
+{
+ QStringList list;
+ list << QLatin1String("Blittable");
+ return list;
+}
+
+QGraphicsSystem* QBlittableGraphicsSystemPlugin::create(const QString& system)
+{
+ if (system.toLower() == QLatin1String("blittable")) {
+ return new QBlittableGraphicsSystem;
+ }
+
+ return 0;
+}
+
+Q_EXPORT_PLUGIN2(blittable, QBlittableGraphicsSystemPlugin)
+
+QT_END_NAMESPACE
diff --git a/src/plugins/graphicssystems/blittable/qblittable_image.h b/src/plugins/graphicssystems/blittable/qblittable_image.h
new file mode 100644
index 0000000..3f8dc69
--- /dev/null
+++ b/src/plugins/graphicssystems/blittable/qblittable_image.h
@@ -0,0 +1,48 @@
+#include <qimage.h>
+
+#include <private/qblittable_p.h>
+
+
+class QImageBlittable : public QBlittable
+{
+public:
+ QImageBlittable(QImage *image, bool deleteImage)
+ : QBlittable(image->size(), QBlittable::Capabilities(QBlittable::SolidRectCapability
+ |QBlittable::SourcePixmapCapability
+ |QBlittable::SourceOverPixmapCapability
+ |QBlittable::SourceOverScaledPixmapCapability)),
+ m_image(image), m_deleteImage(deleteImage)
+ {
+
+ }
+
+ ~QImageBlittable() {
+ if (m_deleteImage)
+ delete m_image;
+ }
+
+ void fillRect(const QRectF &rect, const QColor &color)
+ {
+ QPainter p(lock());
+ p.fillRect(rect,color);
+ }
+ void drawPixmap(const QRectF &rect, const QPixmap &pixmap, const QRectF &source)
+ {
+ //here it is possible to do a pixmap.pixmapData()->buffer()
+ //but is like this to show how to get the the blitter
+ QPixmapData *data = pixmap.pixmapData();
+ Q_ASSERT(data->width() && data->height());
+ Q_ASSERT(data->classId() == QPixmapData::BlitterClass);
+ QBlittablePixmapData *blittableData = static_cast<QBlittablePixmapData*>(data);
+
+ QPainter p(lock());
+ p.drawImage(rect, *blittableData->blittable()->lock(),source);
+ }
+
+protected:
+ QImage *doLock() { return m_image; }
+ void doUnlock() { }
+private:
+ QImage *m_image;
+ bool m_deleteImage;
+};
diff --git a/src/plugins/graphicssystems/blittable/qgraphicssystem_blittable.h b/src/plugins/graphicssystems/blittable/qgraphicssystem_blittable.h
new file mode 100644
index 0000000..d45907f
--- /dev/null
+++ b/src/plugins/graphicssystems/blittable/qgraphicssystem_blittable.h
@@ -0,0 +1,53 @@
+#include <private/qgraphicssystem_p.h>
+#include <private/qblittable_p.h>
+#include <private/qpixmap_blitter_p.h>
+#include <private/qpixmap_raster_p.h>
+#include <private/qwindowsurface_rasterblittable_p.h>
+
+#include "qblittable_image.h"
+
+class QImageBlittableWindowSurface : public QRasterBlittableWindowSurface
+{
+public:
+ QImageBlittableWindowSurface(QWidget *widget)
+ : QRasterBlittableWindowSurface(widget)
+ {}
+
+ QBlittable *createBlittable(QImage *rasterSurface)
+ {
+ return new QImageBlittable(rasterSurface,false);
+ }
+
+};
+
+class QBlittableGraphicsSystem : public QGraphicsSystem
+{
+public:
+ ~QBlittableGraphicsSystem() { }
+
+ QPixmapData *createPixmapData(QPixmapData::PixelType type) const
+ {
+ if (type == QPixmapData::PixmapType)
+ return new QBlittablePixmapData(type);
+ else
+ return new QRasterPixmapData(type);
+ }
+
+ QWindowSurface *createWindowSurface(QWidget *widget) const
+ {
+ return new QImageBlittableWindowSurface(widget);
+ }
+
+ QBlittable *createBlittable(const QSize &size) const
+ {
+ QImage *image = new QImage(size, QImage::Format_ARGB32_Premultiplied);
+ return new QImageBlittable(image,true);
+ }
+
+ QList<QGraphicsSystemScreen *> screens()
+ { return m_screens; }
+
+ QList<QGraphicsSystemScreen *> m_screens;
+};
+
+