summaryrefslogtreecommitdiffstats
path: root/src/gui
diff options
context:
space:
mode:
authorJørgen Lind <jorgen.lind@nokia.com>2010-03-29 08:06:52 (GMT)
committerJørgen Lind <jorgen.lind@nokia.com>2010-03-29 08:06:52 (GMT)
commita5e1442d8960d3a9f363a8101d02e6fae804b6f8 (patch)
treee4ccac01df0d33b79dfd06e3f335766e25a34831 /src/gui
parent9e12625b31e1d95f023fe67deb50e8bf97903994 (diff)
downloadQt-a5e1442d8960d3a9f363a8101d02e6fae804b6f8.zip
Qt-a5e1442d8960d3a9f363a8101d02e6fae804b6f8.tar.gz
Qt-a5e1442d8960d3a9f363a8101d02e6fae804b6f8.tar.bz2
Make sure the blitter api works with Raster GS(x11 and win) and QWS
Diffstat (limited to 'src/gui')
-rw-r--r--src/gui/image/qpixmap_blitter.cpp9
-rw-r--r--src/gui/image/qpixmap_blitter_p.h3
-rw-r--r--src/gui/painting/painting.pri10
-rw-r--r--src/gui/painting/qblittable.cpp64
-rw-r--r--src/gui/painting/qblittable_p.h48
-rw-r--r--src/gui/painting/qgraphicssystem_p.h4
-rw-r--r--src/gui/painting/qpaintengine_blitter.cpp61
-rw-r--r--src/gui/painting/qpaintengine_blitter_p.h40
-rw-r--r--src/gui/painting/qwindowsurface_rasterblittable.cpp26
-rw-r--r--src/gui/painting/qwindowsurface_rasterblittable_p.h21
10 files changed, 189 insertions, 97 deletions
diff --git a/src/gui/image/qpixmap_blitter.cpp b/src/gui/image/qpixmap_blitter.cpp
index a22bd8f..6dcf7c7 100644
--- a/src/gui/image/qpixmap_blitter.cpp
+++ b/src/gui/image/qpixmap_blitter.cpp
@@ -5,10 +5,13 @@
#include <private/qapplication_p.h>
#include <private/qgraphicssystem_p.h>
+#include <private/qblittable_p.h>
#include <private/qdrawhelper_p.h>
#ifndef QT_NO_BLITTABLE
+QT_BEGIN_NAMESPACE
+
static int global_ser_no = 0;
QBlittablePixmapData::QBlittablePixmapData(QPixmapData::PixelType type)
@@ -34,7 +37,7 @@ QBlittable *QBlittablePixmapData::blittable() const
{
if (!m_blittable) {
QBlittablePixmapData *that = const_cast<QBlittablePixmapData *>(this);
- that->m_blittable = QApplicationPrivate::graphicsSystem()->createBlittable(QRect(0,0,w,h));
+ that->m_blittable = QApplicationPrivate::graphicsSystem()->createBlittable(QSize(w,h));
}
return m_blittable;
@@ -42,7 +45,7 @@ QBlittable *QBlittablePixmapData::blittable() const
void QBlittablePixmapData::setBlittable(QBlittable *blittable)
{
- resize(blittable->rect().width(),blittable->rect().height());
+ resize(blittable->size().width(),blittable->size().height());
m_blittable = blittable;
}
@@ -259,6 +262,8 @@ QRectF QBlittablePixmapData::clipAndTransformRect(const QRectF &rect) const
}
return transformationRect;
}
+
+QT_END_NAMESPACE
#endif //QT_BLITTER_RASTEROVERLAY
#endif //QT_NO_BLITTABLE
diff --git a/src/gui/image/qpixmap_blitter_p.h b/src/gui/image/qpixmap_blitter_p.h
index 1d85cd3..b9f7630 100644
--- a/src/gui/image/qpixmap_blitter_p.h
+++ b/src/gui/image/qpixmap_blitter_p.h
@@ -5,6 +5,8 @@
#include <private/qpaintengine_blitter_p.h>
#ifndef QT_NO_BLITTABLE
+QT_BEGIN_NAMESPACE
+
class Q_GUI_EXPORT QBlittablePixmapData : public QPixmapData
{
// Q_DECLARE_PRIVATE(QBlittablePixmapData);
@@ -117,5 +119,6 @@ inline void QBlittablePixmapData::unmarkRasterOverlay(const QRectF &rect)
#endif
}
+QT_END_NAMESPACE
#endif // QT_NO_BLITTABLE
#endif // QPIXMAP_BLITTER_P_H
diff --git a/src/gui/painting/painting.pri b/src/gui/painting/painting.pri
index 8e7bba7..a3fe2e1 100644
--- a/src/gui/painting/painting.pri
+++ b/src/gui/painting/painting.pri
@@ -89,12 +89,16 @@ SOURCES += \
painting/qpaintengine_raster.cpp \
painting/qdrawhelper.cpp \
painting/qimagescale.cpp \
- painting/qgrayraster.c
+ painting/qgrayraster.c \
+ painting/qpaintengine_blitter.cpp \
+ painting/qblittable.cpp \
HEADERS += \
painting/qpaintengine_raster_p.h \
painting/qrasterdefs_p.h \
- painting/qgrayraster_p.h
+ painting/qgrayraster_p.h \
+ painting/qpaintengine_blitter_p.h \
+ painting/qblittable_p.h \
win32 {
HEADERS += painting/qprintengine_win_p.h
@@ -121,12 +125,14 @@ embedded {
painting/qgraphicssystemfactory_p.h \
painting/qgraphicssystemplugin_p.h \
painting/qwindowsurface_raster_p.h \
+ painting/qwindowsurface_rasterblittable_p.h \
SOURCES += \
painting/qgraphicssystem_raster.cpp \
painting/qgraphicssystemfactory.cpp \
painting/qgraphicssystemplugin.cpp \
painting/qwindowsurface_raster.cpp \
+ painting/qwindowsurface_rasterblittable.cpp \
}
unix:x11 {
diff --git a/src/gui/painting/qblittable.cpp b/src/gui/painting/qblittable.cpp
new file mode 100644
index 0000000..0b2bd64
--- /dev/null
+++ b/src/gui/painting/qblittable.cpp
@@ -0,0 +1,64 @@
+#include "qblittable_p.h"
+
+#ifndef QT_NO_BLITTABLE
+QT_BEGIN_NAMESPACE
+
+class QBlittablePrivate
+{
+public:
+ QBlittablePrivate(const QSize &size, QBlittable::Capabilities caps)
+ : caps(caps), m_size(size), locked(false), cachedImg(0)
+ {}
+ QBlittable::Capabilities caps;
+ QSize m_size;
+ bool locked;
+ QImage *cachedImg;
+};
+
+
+QBlittable::QBlittable(const QSize &size, Capabilities caps)
+ : d_ptr(new QBlittablePrivate(size,caps))
+{
+}
+
+QBlittable::~QBlittable()
+{
+ delete d_ptr;
+}
+
+
+QBlittable::Capabilities QBlittable::capabilities() const
+{
+ Q_D(const QBlittable);
+ return d->caps;
+}
+
+QSize QBlittable::size() const
+{
+ Q_D(const QBlittable);
+ return d->m_size;
+}
+
+QImage *QBlittable::lock()
+{
+ Q_D(QBlittable);
+ if (!d->locked) {
+ d->cachedImg = doLock();
+ d->locked = true;
+ }
+
+ return d->cachedImg;
+}
+
+void QBlittable::unlock()
+{
+ Q_D(QBlittable);
+ if (d->locked) {
+ doUnlock();
+ d->locked = false;
+ }
+}
+
+QT_END_NAMESPACE
+#endif //QT_NO_BLITTABLE
+
diff --git a/src/gui/painting/qblittable_p.h b/src/gui/painting/qblittable_p.h
new file mode 100644
index 0000000..98caab7d
--- /dev/null
+++ b/src/gui/painting/qblittable_p.h
@@ -0,0 +1,48 @@
+#ifndef QBLITTABLE_P_H
+#define QBLITTABLE_P_H
+
+#include <QtCore/qsize.h>
+
+#ifndef QT_NO_BLITTABLE
+QT_BEGIN_NAMESPACE
+
+class QImage;
+class QBlittablePrivate;
+
+class Q_GUI_EXPORT QBlittable
+{
+ Q_DECLARE_PRIVATE(QBlittable);
+public:
+ enum Capability {
+
+ SolidRectCapability = 0x0001,
+ SourcePixmapCapability = 0x0002,
+ SourceOverPixmapCapability = 0x0004,
+ SourceOverScaledPixmapCapability = 0x0008,
+
+ // Internal ones
+ OutlineCapability = 0x0001000,
+ };
+ Q_DECLARE_FLAGS (Capabilities, Capability);
+
+ QBlittable(const QSize &size, Capabilities caps);
+ virtual ~QBlittable();
+
+ Capabilities capabilities() const;
+ QSize size() const;
+
+ virtual void fillRect(const QRectF &rect, const QColor &color) = 0;
+ virtual void drawPixmap(const QRectF &rect, const QPixmap &pixmap, const QRectF &subrect) = 0;
+
+ QImage *lock();
+ void unlock();
+
+protected:
+ virtual QImage *doLock() = 0;
+ virtual void doUnlock() = 0;
+ QBlittablePrivate *d_ptr;
+};
+
+QT_END_NAMESPACE
+#endif //QT_NO_BLITTABLE
+#endif //QBLITTABLE_P_H
diff --git a/src/gui/painting/qgraphicssystem_p.h b/src/gui/painting/qgraphicssystem_p.h
index 8e35f9f..03b0f48 100644
--- a/src/gui/painting/qgraphicssystem_p.h
+++ b/src/gui/painting/qgraphicssystem_p.h
@@ -62,6 +62,7 @@
QT_BEGIN_NAMESPACE
class QPixmapFilter;
+class QBlittable;
#ifdef Q_WS_LITE
class Q_GUI_EXPORT QGraphicsSystemScreen : public QObject
@@ -86,7 +87,7 @@ class Q_GUI_EXPORT QGraphicsSystem
public:
virtual QPixmapData *createPixmapData(QPixmapData::PixelType type) const = 0;
virtual QWindowSurface *createWindowSurface(QWidget *widget) const = 0;
- virtual QBlittable *createBlittable(const QRect &) const { return 0; }
+ virtual QBlittable *createBlittable(const QSize &) const { return 0; }
virtual ~QGraphicsSystem() = 0;
@@ -94,6 +95,7 @@ public:
virtual QList<QGraphicsSystemScreen *> screens() const;
virtual QPixmap grabWindow(WId window, int x, int y, int width, int height) const;
#endif
+
//### Remove this & change qpixmap.cpp & qbitmap.cpp once every platform is gaurenteed
// to have a graphics system.
static QPixmapData *createDefaultPixmapData(QPixmapData::PixelType type);
diff --git a/src/gui/painting/qpaintengine_blitter.cpp b/src/gui/painting/qpaintengine_blitter.cpp
index 1032852..0b74a4d 100644
--- a/src/gui/painting/qpaintengine_blitter.cpp
+++ b/src/gui/painting/qpaintengine_blitter.cpp
@@ -1,10 +1,13 @@
#include "private/qpaintengine_blitter_p.h"
+
+#include "private/qblittable_p.h"
#include "private/qpaintengine_raster_p.h"
#include "private/qpainter_p.h"
#include "private/qapplication_p.h"
#include "private/qpixmap_blitter_p.h"
#ifndef QT_NO_BLITTABLE
+QT_BEGIN_NAMESPACE
#define STATE_XFORM_SCALE 0x00000001
#define STATE_XFORM_COMPLEX 0x00000002
@@ -617,60 +620,6 @@ inline QRasterPaintEngine *QBlitterPaintEngine::raster() const
return d->raster;
}
-class QBlittablePrivate
-{
-public:
- QBlittablePrivate(const QRect &rect, QBlittable::Capabilities caps)
- : caps(caps), m_rect(rect), locked(false), cachedImg(0)
- {}
- QBlittable::Capabilities caps;
- QRect m_rect;
- bool locked;
- QImage *cachedImg;
-};
-
-
-QBlittable::QBlittable(const QRect &rect, Capabilities caps)
- : d_ptr(new QBlittablePrivate(rect,caps))
-{
-}
-
-QBlittable::~QBlittable()
-{
- delete d_ptr;
-}
-
-
-QBlittable::Capabilities QBlittable::capabilities() const
-{
- Q_D(const QBlittable);
- return d->caps;
-}
-
-QRect QBlittable::rect() const
-{
- Q_D(const QBlittable);
- return d->m_rect;
-}
-
-QImage *QBlittable::lock()
-{
- Q_D(QBlittable);
- if (!d->locked) {
- d->cachedImg = doLock();
- d->locked = true;
- }
-
- return d->cachedImg;
-}
-
-void QBlittable::unlock()
-{
- Q_D(QBlittable);
- if (d->locked) {
- doUnlock();
- d->locked = false;
- }
-}
-
+QT_END_NAMESPACE
#endif //QT_NO_BLITTABLE
+
diff --git a/src/gui/painting/qpaintengine_blitter_p.h b/src/gui/painting/qpaintengine_blitter_p.h
index 1a2ad9e..d436993 100644
--- a/src/gui/painting/qpaintengine_blitter_p.h
+++ b/src/gui/painting/qpaintengine_blitter_p.h
@@ -5,45 +5,11 @@
#include "private/qpaintengine_raster_p.h"
#ifndef QT_NO_BLITTABLE
+QT_BEGIN_NAMESPACE
-class QBlittablePrivate;
class QBlitterPaintEnginePrivate;
class QBlittablePixmapData;
-
-class Q_GUI_EXPORT QBlittable
-{
- Q_DECLARE_PRIVATE(QBlittable);
-public:
- enum Capability {
-
- SolidRectCapability = 0x0001,
- SourcePixmapCapability = 0x0002,
- SourceOverPixmapCapability = 0x0004,
- SourceOverScaledPixmapCapability = 0x0008,
-
- // Internal ones
- OutlineCapability = 0x0001000,
- };
- Q_DECLARE_FLAGS (Capabilities, Capability);
-
- QBlittable(const QRect &rect, Capabilities caps);
- virtual ~QBlittable();
-
- Capabilities capabilities() const;
- QRect rect() const;
-
- virtual void fillRect(const QRectF &rect, const QColor &color) = 0;
- virtual void drawPixmap(const QRectF &rect, const QPixmap &pixmap, const QRectF &subrect) = 0;
-
- QImage *lock();
- void unlock();
-
-protected:
- virtual QImage *doLock() = 0;
- virtual void doUnlock() = 0;
- QBlittablePrivate *d_ptr;
-};
-
+class QBlittable;
class Q_GUI_EXPORT QBlitterPaintEngine : public QPaintEngineEx
{
@@ -101,5 +67,7 @@ private:
};
+QT_END_NAMESPACE
#endif //QT_NO_BLITTABLE
#endif // QPAINTENGINE_BLITTER_P_H
+
diff --git a/src/gui/painting/qwindowsurface_rasterblittable.cpp b/src/gui/painting/qwindowsurface_rasterblittable.cpp
new file mode 100644
index 0000000..56a79ba
--- /dev/null
+++ b/src/gui/painting/qwindowsurface_rasterblittable.cpp
@@ -0,0 +1,26 @@
+#include "qwindowsurface_rasterblittable_p.h"
+
+#include <private/qpaintengine_blitter_p.h>
+#include <private/qpixmap_blitter_p.h>
+
+QRasterBlittableWindowSurface::QRasterBlittableWindowSurface(QWidget *widget)
+ : QRasterWindowSurface(widget),
+ m_currentImage(0),
+ m_blittable(0),
+ m_pmData(new QBlittablePixmapData(QPixmapData::PixmapType)),
+ m_pixmap(new QPixmap(m_pmData))
+{
+}
+
+QPaintDevice *QRasterBlittableWindowSurface::paintDevice()
+{
+ QPaintDevice *device = QRasterWindowSurface::paintDevice();
+ if (m_currentImage != device) {
+ if (device->devType() == QInternal::Image) {
+ m_currentImage = static_cast<QImage *>(device);
+ m_blittable = createBlittable(m_currentImage);
+ m_pmData->setBlittable(m_blittable);
+ }
+ }
+ return m_pixmap;
+}
diff --git a/src/gui/painting/qwindowsurface_rasterblittable_p.h b/src/gui/painting/qwindowsurface_rasterblittable_p.h
new file mode 100644
index 0000000..1e697c7
--- /dev/null
+++ b/src/gui/painting/qwindowsurface_rasterblittable_p.h
@@ -0,0 +1,21 @@
+#include <private/qwindowsurface_raster_p.h>
+#include <private/qpixmapdata_p.h>
+
+class QBlittable;
+class QBlittablePixmapData;
+
+class Q_GUI_EXPORT QRasterBlittableWindowSurface : public QRasterWindowSurface
+{
+public:
+ QRasterBlittableWindowSurface(QWidget *widget);
+
+ virtual QBlittable *createBlittable(QImage *rasterSurface) = 0;
+
+ QPaintDevice *paintDevice();
+
+private:
+ QImage *m_currentImage;
+ QBlittable *m_blittable;
+ QBlittablePixmapData *m_pmData;
+ QPixmap *m_pixmap;
+};