summaryrefslogtreecommitdiffstats
path: root/src/openvg
diff options
context:
space:
mode:
authorRhys Weatherley <rhys.weatherley@nokia.com>2009-10-30 15:08:36 +1000
committerRhys Weatherley <rhys.weatherley@nokia.com>2009-10-30 15:08:36 +1000
commit2833d72c3d0e67317b9aba3de59f0e90317ecb12 (patch)
treec92ba8b9b910f04a9239e1b82dd39577a11fb675 /src/openvg
parentf5589e3b4d352b9b8d9fd54e974d548713e7b640 (diff)
Remove drawCursorImage() from the OpenVG composition helper
The drawCursorPixmap() function is more efficient and can render the QImage form of the QPixmap directly if necessary. Reviewed-by: trustme
Diffstat (limited to 'src/openvg')
-rw-r--r--src/openvg/qpaintengine_vg.cpp69
-rw-r--r--src/openvg/qvgcompositionhelper_p.h1
2 files changed, 33 insertions, 37 deletions
diff --git a/src/openvg/qpaintengine_vg.cpp b/src/openvg/qpaintengine_vg.cpp
index 94e0793de4..8a485a088c 100644
--- a/src/openvg/qpaintengine_vg.cpp
+++ b/src/openvg/qpaintengine_vg.cpp
@@ -3574,51 +3574,48 @@ void QVGCompositionHelper::fillBackground
}
}
-void QVGCompositionHelper::drawCursorImage
- (const QImage& image, const QPoint& offset)
+void QVGCompositionHelper::drawCursorPixmap
+ (const QPixmap& pixmap, const QPoint& offset)
{
- QImage img = image.convertToFormat(QImage::Format_ARGB32_Premultiplied);
+ VGImage vgImage = VG_INVALID_HANDLE;
- VGImage vgImg = vgCreateImage
- (VG_sARGB_8888_PRE, img.width(), img.height(),
- VG_IMAGE_QUALITY_FASTER);
- vgImageSubData
- (vgImg, img.bits() + img.bytesPerLine() * (img.height() - 1),
- -(img.bytesPerLine()), VG_sARGB_8888_PRE, 0, 0,
- img.width(), img.height());
+ // Fetch the VGImage from the pixmap if possible.
+ QPixmapData *pd = pixmap.pixmapData();
+ if (pd->classId() == QPixmapData::OpenVGClass) {
+ QVGPixmapData *vgpd = static_cast<QVGPixmapData *>(pd);
+ if (vgpd->isValid())
+ vgImage = vgpd->toVGImage();
+ }
- QTransform transform;
- int y = screenSize.height() - (offset.y() + img.height());
- transform.translate(offset.x() + 0.5f, y + 0.5f);
+ // Set the image transformation and modes.
+ VGfloat devh = screenSize.height() - 1;
+ QTransform transform(1.0f, 0.0f, 0.0f,
+ 0.0f, -1.0f, 0.0f,
+ -0.5f, devh + 0.5f, 1.0f);
+ transform.translate(offset.x(), offset.y());
d->setTransform(VG_MATRIX_IMAGE_USER_TO_SURFACE, transform);
-
d->setImageMode(VG_DRAW_IMAGE_NORMAL);
- vgDrawImage(vgImg);
- vgDestroyImage(vgImg);
-}
+ // Draw the VGImage.
+ if (vgImage != VG_INVALID_HANDLE) {
+ vgDrawImage(vgImage);
+ } else {
+ QImage img = pixmap.toImage().convertToFormat
+ (QImage::Format_ARGB32_Premultiplied);
-void QVGCompositionHelper::drawCursorPixmap
- (const QPixmap& pixmap, const QPoint& offset)
-{
- QPixmapData *pd = pixmap.pixmapData();
- if (pd->classId() == QPixmapData::OpenVGClass) {
- QVGPixmapData *vgpd = static_cast<QVGPixmapData *>(pd);
- if (vgpd->isValid()) {
- VGfloat devh = screenSize.height() - 1;
- QTransform transform(1.0f, 0.0f, 0.0f,
- 0.0f, -1.0f, 0.0f,
- -0.5f, devh + 0.5f, 1.0f);
- transform.translate(offset.x(), offset.y());
- d->setTransform(VG_MATRIX_IMAGE_USER_TO_SURFACE, transform);
-
- d->setImageMode(VG_DRAW_IMAGE_NORMAL);
- vgDrawImage(vgpd->toVGImage());
+ vgImage = vgCreateImage
+ (VG_sARGB_8888_PRE, img.width(), img.height(),
+ VG_IMAGE_QUALITY_FASTER);
+ if (vgImage == VG_INVALID_HANDLE)
return;
- }
- }
+ vgImageSubData
+ (vgImage, img.bits() + img.bytesPerLine() * (img.height() - 1),
+ -(img.bytesPerLine()), VG_sARGB_8888_PRE, 0, 0,
+ img.width(), img.height());
- drawCursorImage(pixmap.toImage(), offset);
+ vgDrawImage(vgImage);
+ vgDestroyImage(vgImage);
+ }
}
void QVGCompositionHelper::setScissor(const QRegion& region)
diff --git a/src/openvg/qvgcompositionhelper_p.h b/src/openvg/qvgcompositionhelper_p.h
index 6317c3f6dc..3afe31e5ee 100644
--- a/src/openvg/qvgcompositionhelper_p.h
+++ b/src/openvg/qvgcompositionhelper_p.h
@@ -74,7 +74,6 @@ public:
void blitWindow(QVGEGLWindowSurfacePrivate *surface, const QRect& rect,
const QPoint& topLeft, int opacity);
void fillBackground(const QRegion& region, const QBrush& brush);
- void drawCursorImage(const QImage& image, const QPoint& offset);
void drawCursorPixmap(const QPixmap& pixmap, const QPoint& offset);
void setScissor(const QRegion& region);
void clearScissor();