void tst_QVolatileImage::create() { QVolatileImage nullImg; QVERIFY(nullImg.isNull()); QVolatileImage img(100, 200, QImage::Format_ARGB32); QVERIFY(!img.isNull()); QCOMPARE(img.width(), 100); QCOMPARE(img.height(), 200); QCOMPARE(img.format(), QImage::Format_ARGB32); QCOMPARE(img.byteCount(), img.bytesPerLine() * img.height()); QCOMPARE(img.hasAlphaChannel(), true); QCOMPARE(img.depth(), 32); QImage source(12, 23, QImage::Format_ARGB32_Premultiplied); img = QVolatileImage(source); QVERIFY(!img.isNull()); QCOMPARE(img.width(), 12); QCOMPARE(img.height(), 23); QCOMPARE(img.format(), source.format()); QCOMPARE(img.byteCount(), img.bytesPerLine() * img.height()); QVERIFY(img.imageRef() == source); QVERIFY(img.toImage() == source); QCOMPARE(img.hasAlphaChannel(), true); QCOMPARE(img.hasAlphaChannel(), img.imageRef().hasAlphaChannel()); QCOMPARE(img.hasAlphaChannel(), img.toImage().hasAlphaChannel()); QCOMPARE(img.depth(), 32); }
void QVolatileImagePaintEngine::drawPixmap(const QRectF &r, const QPixmap &pm, const QRectF &sr) { #ifdef Q_OS_SYMBIAN QVolatileImage img = pm.pixmapData()->toVolatileImage(); if (!img.isNull()) { img.beginDataAccess(); QRasterPaintEngine::drawImage(r, img.constImageRef(), sr); img.endDataAccess(true); } else { QRasterPaintEngine::drawPixmap(r, pm, sr); } #else QRasterPaintEngine::drawPixmap(r, pm, sr); #endif }
void QVolatileImagePaintEngine::drawPixmap(const QPointF &p, const QPixmap &pm) { #ifdef Q_OS_SYMBIAN QVolatileImage img = pm.pixmapData()->toVolatileImage(); if (!img.isNull()) { img.beginDataAccess(); // imageRef() would detach and since we received the QVolatileImage from // toVolatileImage() by value, it would cause a copy which would ruin // our goal. So use constImageRef() instead. QRasterPaintEngine::drawImage(p, img.constImageRef()); img.endDataAccess(true); } else { QRasterPaintEngine::drawPixmap(p, pm); } #else QRasterPaintEngine::drawPixmap(p, pm); #endif }
void tst_QVolatileImage::create() { QVolatileImage nullImg; QVERIFY(nullImg.isNull()); QVolatileImage img(100, 200, QImage::Format_ARGB32); QVERIFY(!img.isNull()); QCOMPARE(img.width(), 100); QCOMPARE(img.height(), 200); QCOMPARE(img.format(), QImage::Format_ARGB32); QCOMPARE(img.byteCount(), img.bytesPerLine() * img.height()); QCOMPARE(img.hasAlphaChannel(), true); QCOMPARE(img.depth(), 32); QImage source(12, 23, QImage::Format_ARGB32_Premultiplied); img = QVolatileImage(source); QVERIFY(!img.isNull()); QCOMPARE(img.width(), 12); QCOMPARE(img.height(), 23); QCOMPARE(img.format(), source.format()); QCOMPARE(img.byteCount(), img.bytesPerLine() * img.height()); QVERIFY(img.imageRef() == source); QVERIFY(img.toImage() == source); QCOMPARE(img.hasAlphaChannel(), true); QCOMPARE(img.hasAlphaChannel(), img.imageRef().hasAlphaChannel()); QCOMPARE(img.hasAlphaChannel(), img.toImage().hasAlphaChannel()); QCOMPARE(img.depth(), 32); #ifdef Q_OS_SYMBIAN CFbsBitmap *bmp = new CFbsBitmap; QVERIFY(bmp->Create(TSize(100, 50), EColor16MAP) == KErrNone); QVolatileImage bmpimg(bmp); QVERIFY(!bmpimg.isNull()); QCOMPARE(bmpimg.width(), 100); QCOMPARE(bmpimg.height(), 50); // Verify that we only did handle duplication, not pixel data copying. QCOMPARE(bmpimg.constBits(), (const uchar *) bmp->DataAddress()); delete bmp; // Check if content is still valid. QImage copyimg = bmpimg.toImage(); QCOMPARE(copyimg.format(), QImage::Format_ARGB32_Premultiplied); #endif }