summaryrefslogtreecommitdiffstats
path: root/src/openvg
diff options
context:
space:
mode:
authorQt Continuous Integration System <qt-info@nokia.com>2011-03-29 05:57:38 (GMT)
committerQt Continuous Integration System <qt-info@nokia.com>2011-03-29 05:57:38 (GMT)
commit7dc8b5e3361496064e99d1335232126788875179 (patch)
treeea79a39b9076a207fc0ca0508a907d95eb29b3d6 /src/openvg
parent07c367c2de9fb721cd4e0379acb705ebf1da997f (diff)
parent66a1938f34c9b50902e6c88b45fc063abb49830b (diff)
downloadQt-7dc8b5e3361496064e99d1335232126788875179.zip
Qt-7dc8b5e3361496064e99d1335232126788875179.tar.gz
Qt-7dc8b5e3361496064e99d1335232126788875179.tar.bz2
Merge branch 'master' of git://scm.dev.nokia.troll.no/qt/qt-qml-team
* 'master' of git://scm.dev.nokia.troll.no/qt/qt-qml-team: (93 commits) Designer: Fix tab order in action editor dialog. tst_qlocale: improve failure message in tst_QLocale::macDefaultLocale Add a once-over unrolled fromLatin1 conversion (32 characters) Add 16-byte loads of the Neon fromLatin1 functions Fix warning about unused parameter Make QtUiTools use the lib-infix passed to configure. Skip failing tests Removed old autotest references from Symbian build files Icon in QMessageBox::question is deformed on Symbian Prevent crash when connecting signal in splitview GraphicsViews: Focused widget is not visible after orientation change GraphicsViews: Focused widget is not visible after orientation change Add missing nullify for the s60 style's background pixmap pointer. Fixes QT-4753 sort out stdout vs. stderr usage Updated QtGUI DEF files for WINSCW Handle removal of setter for partialUpdateSupport Remove the use of the QtTest baseline feature I reverted Revert "Add a feature to QTestLib to correct benchmark results." Use the ARM version of UTF-8 detection in the Neon code ...
Diffstat (limited to 'src/openvg')
-rw-r--r--src/openvg/qpaintengine_vg.cpp105
-rw-r--r--src/openvg/qvg_symbian.cpp8
2 files changed, 106 insertions, 7 deletions
diff --git a/src/openvg/qpaintengine_vg.cpp b/src/openvg/qpaintengine_vg.cpp
index 3d50558..570adfd 100644
--- a/src/openvg/qpaintengine_vg.cpp
+++ b/src/openvg/qpaintengine_vg.cpp
@@ -3071,6 +3071,95 @@ static void drawVGImage(QVGPaintEnginePrivate *d,
vgDrawImage(vgImg);
}
+static void drawImageTiled(QVGPaintEnginePrivate *d,
+ const QRectF &r,
+ const QImage &image,
+ const QRectF &sr = QRectF())
+{
+ const int minTileSize = 16;
+ int tileWidth = 512;
+ int tileHeight = tileWidth;
+
+ VGImageFormat tileFormat = qt_vg_image_to_vg_format(image.format());
+ VGImage tile = VG_INVALID_HANDLE;
+ QVGImagePool *pool = QVGImagePool::instance();
+ while (tile == VG_INVALID_HANDLE && tileWidth >= minTileSize) {
+ tile = pool->createPermanentImage(tileFormat, tileWidth, tileHeight,
+ VG_IMAGE_QUALITY_FASTER);
+ if (tile == VG_INVALID_HANDLE) {
+ tileWidth /= 2;
+ tileHeight /= 2;
+ }
+ }
+ if (tile == VG_INVALID_HANDLE) {
+ qWarning("drawImageTiled: Failed to create %dx%d tile, giving up", tileWidth, tileHeight);
+ return;
+ }
+
+ VGfloat opacityMatrix[20] = {
+ 1.0f, 0.0f, 0.0f, 0.0f,
+ 0.0f, 1.0f, 0.0f, 0.0f,
+ 0.0f, 0.0f, 1.0f, 0.0f,
+ 0.0f, 0.0f, 0.0f, d->opacity,
+ 0.0f, 0.0f, 0.0f, 0.0f
+ };
+ VGImage tileWithOpacity = VG_INVALID_HANDLE;
+ if (d->opacity != 1) {
+ tileWithOpacity = pool->createPermanentImage(VG_sARGB_8888_PRE,
+ tileWidth, tileHeight, VG_IMAGE_QUALITY_FASTER);
+ if (tileWithOpacity == VG_INVALID_HANDLE)
+ qWarning("drawImageTiled: Failed to create extra tile, ignoring opacity");
+ }
+
+ QRect sourceRect = sr.toRect();
+ if (sourceRect.isNull())
+ sourceRect = QRect(0, 0, image.width(), image.height());
+
+ VGfloat scaleX = r.width() / sourceRect.width();
+ VGfloat scaleY = r.height() / sourceRect.height();
+
+ d->setImageOptions();
+
+ for (int y = sourceRect.y(); y < sourceRect.height(); y += tileHeight) {
+ int h = qMin(tileHeight, sourceRect.height() - y);
+ if (h < 1)
+ break;
+ for (int x = sourceRect.x(); x < sourceRect.width(); x += tileWidth) {
+ int w = qMin(tileWidth, sourceRect.width() - x);
+ if (w < 1)
+ break;
+
+ int bytesPerPixel = image.depth() / 8;
+ const uchar *sptr = image.constBits() + x * bytesPerPixel + y * image.bytesPerLine();
+ vgImageSubData(tile, sptr, image.bytesPerLine(), tileFormat, 0, 0, w, h);
+
+ QTransform transform(d->imageTransform);
+ transform.translate(r.x() + x, r.y() + y);
+ transform.scale(scaleX, scaleY);
+ d->setTransform(VG_MATRIX_IMAGE_USER_TO_SURFACE, transform);
+
+ VGImage actualTile = tile;
+ if (tileWithOpacity != VG_INVALID_HANDLE) {
+ vgColorMatrix(tileWithOpacity, actualTile, opacityMatrix);
+ if (w < tileWidth || h < tileHeight)
+ actualTile = vgChildImage(tileWithOpacity, 0, 0, w, h);
+ else
+ actualTile = tileWithOpacity;
+ } else if (w < tileWidth || h < tileHeight) {
+ actualTile = vgChildImage(tile, 0, 0, w, h);
+ }
+ vgDrawImage(actualTile);
+
+ if (actualTile != tile && actualTile != tileWithOpacity)
+ vgDestroyImage(actualTile);
+ }
+ }
+
+ vgDestroyImage(tile);
+ if (tileWithOpacity != VG_INVALID_HANDLE)
+ vgDestroyImage(tileWithOpacity);
+}
+
// Used by qpixmapfilter_vg.cpp to draw filtered VGImage's.
void qt_vg_drawVGImage(QPainter *painter, const QPointF& pos, VGImage vgImg)
{
@@ -3170,7 +3259,7 @@ void QVGPaintEngine::drawPixmap(const QPointF &pos, const QPixmap &pm)
vgpd->source.beginDataAccess();
drawImage(pos, vgpd->source.imageRef());
- vgpd->source.endDataAccess();
+ vgpd->source.endDataAccess(true);
} else {
drawImage(pos, *(pd->buffer()));
}
@@ -3181,6 +3270,8 @@ void QVGPaintEngine::drawImage
Qt::ImageConversionFlags flags)
{
Q_D(QVGPaintEngine);
+ if (image.isNull())
+ return;
VGImage vgImg;
if (d->simpleTransform || d->opacity == 1.0f)
vgImg = toVGImageSubRect(image, sr.toRect(), flags);
@@ -3217,7 +3308,10 @@ void QVGPaintEngine::drawImage
} else {
// Monochrome images need to use the vgChildImage() path.
vgImg = toVGImage(image, flags);
- drawVGImage(d, r, vgImg, image.size(), sr);
+ if (vgImg == VG_INVALID_HANDLE)
+ drawImageTiled(d, r, image, sr);
+ else
+ drawVGImage(d, r, vgImg, image.size(), sr);
}
}
vgDestroyImage(vgImg);
@@ -3226,6 +3320,8 @@ void QVGPaintEngine::drawImage
void QVGPaintEngine::drawImage(const QPointF &pos, const QImage &image)
{
Q_D(QVGPaintEngine);
+ if (image.isNull())
+ return;
VGImage vgImg;
if (canVgWritePixels(image)) {
// Optimization for straight blits, no blending
@@ -3242,7 +3338,10 @@ void QVGPaintEngine::drawImage(const QPointF &pos, const QImage &image)
} else {
vgImg = toVGImageWithOpacity(image, d->opacity);
}
- drawVGImage(d, pos, vgImg);
+ if (vgImg == VG_INVALID_HANDLE)
+ drawImageTiled(d, QRectF(pos, image.size()), image);
+ else
+ drawVGImage(d, pos, vgImg);
vgDestroyImage(vgImg);
}
diff --git a/src/openvg/qvg_symbian.cpp b/src/openvg/qvg_symbian.cpp
index 2924d41..0d2ed9e 100644
--- a/src/openvg/qvg_symbian.cpp
+++ b/src/openvg/qvg_symbian.cpp
@@ -195,14 +195,16 @@ void QVGPixmapData::fromNativeType(void* pixmap, NativeType type)
if (!conversionLessFormat(source.format())) {
// Here we may need to copy if the formats do not match.
// (e.g. for display modes other than EColor16MAP and EColor16MU)
- source.ensureFormat(idealFormat(&source.imageRef(), Qt::AutoColor));
+ source.beginDataAccess();
+ QImage::Format format = idealFormat(&source.imageRef(), Qt::AutoColor);
+ source.endDataAccess(true);
+ source.ensureFormat(format);
}
recreate = true;
} else if (type == QPixmapData::VolatileImage && pixmap) {
QVolatileImage *img = static_cast<QVolatileImage *>(pixmap);
resize(img->width(), img->height());
source = *img;
- source.ensureFormat(idealFormat(&source.imageRef(), Qt::AutoColor));
recreate = true;
} else if (type == QPixmapData::NativeImageHandleProvider && pixmap) {
destroyImages();
@@ -282,8 +284,6 @@ void* QVGPixmapData::toNativeType(NativeType type)
}
// Just duplicate the bitmap handle, no data copying happens.
return source.duplicateNativeImage();
- } else if (type == QPixmapData::VolatileImage) {
- return &source;
}
return 0;
}