summaryrefslogtreecommitdiffstats
path: root/src/gui/image/qpixmap_blitter.cpp
diff options
context:
space:
mode:
authorJørgen Lind <jorgen.lind@nokia.com>2009-11-16 10:33:26 (GMT)
committerJørgen Lind <jorgen.lind@nokia.com>2009-11-25 09:55:59 (GMT)
commit7dea84cd015538dc327e489113919d75c8e275bb (patch)
tree4255c5f05fb73ea17eb2a5fb2c078df190652256 /src/gui/image/qpixmap_blitter.cpp
parentefa0d024fc262b89189c0589a0ee81fe083635b1 (diff)
downloadQt-7dea84cd015538dc327e489113919d75c8e275bb.zip
Qt-7dea84cd015538dc327e489113919d75c8e275bb.tar.gz
Qt-7dea84cd015538dc327e489113919d75c8e275bb.tar.bz2
Added QBlittablePixmapData
Is going to be used by everyone that reimplements QBlittable
Diffstat (limited to 'src/gui/image/qpixmap_blitter.cpp')
-rw-r--r--src/gui/image/qpixmap_blitter.cpp65
1 files changed, 65 insertions, 0 deletions
diff --git a/src/gui/image/qpixmap_blitter.cpp b/src/gui/image/qpixmap_blitter.cpp
new file mode 100644
index 0000000..9730ecc
--- /dev/null
+++ b/src/gui/image/qpixmap_blitter.cpp
@@ -0,0 +1,65 @@
+#include "qpixmap_blitter_p.h"
+
+#include <private/qapplication_p.h>
+#include <private/qgraphicssystem_p.h>
+
+QBlittablePixmapData::QBlittablePixmapData(PixelType type)
+ : QPixmapData(type,BlitterClass), m_blittable(0), m_engine(0)
+{
+}
+
+QBlittablePixmapData::~QBlittablePixmapData()
+{
+}
+
+void QBlittablePixmapData::resize(int width, int height)
+{
+ delete m_blittable;
+ m_blittable = QApplicationPrivate::graphicsSystem()->createBlittable(QRect(0,0,width,height));
+ m_engine = 0;
+}
+
+int QBlittablePixmapData::metric(QPaintDevice::PaintDeviceMetric metric) const
+{
+ QImage *image = m_blittable->lock();
+ return image->metric(metric);
+}
+
+void QBlittablePixmapData::fill(const QColor &color)
+{
+ if (m_blittable->capabilities() & QBlittable::SolidRectCapability)
+ m_blittable->fillRect(m_blittable->rect(),color);
+ else
+ m_blittable->lock()->fill(color.rgb());
+}
+
+QImage *QBlittablePixmapData::buffer()
+{
+ return m_blittable->lock();
+}
+
+QImage QBlittablePixmapData::toImage()
+{
+ return m_blittable->lock()->copy();
+}
+
+bool QBlittablePixmapData::hasAlphaChannel()
+{
+ return m_blittable->lock()->hasAlphaChannel();
+}
+
+void QBlittablePixmapData::fromImage(const QImage &image,
+ Qt::ImageConversionFlags flags)
+{
+ m_blittable = new QImageBlitter(image);
+ m_engine = 0;
+}
+
+QPaintEngine *QBlittablePixmapData::paintEngine() const
+{
+ if (!m_engine) {
+ QBlittablePixmapData *that = const_cast<QBlittablePixmapData *>(this);
+ that->m_engine = new QBlitterPaintEngine(that);
+ }
+ return m_engine;
+}