diff options
author | Jørgen Lind <jorgen.lind@nokia.com> | 2009-11-16 10:33:26 (GMT) |
---|---|---|
committer | Jørgen Lind <jorgen.lind@nokia.com> | 2009-11-25 09:55:59 (GMT) |
commit | 7dea84cd015538dc327e489113919d75c8e275bb (patch) | |
tree | 4255c5f05fb73ea17eb2a5fb2c078df190652256 /src/gui/image/qpixmap_blitter.cpp | |
parent | efa0d024fc262b89189c0589a0ee81fe083635b1 (diff) | |
download | Qt-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.cpp | 65 |
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; +} |