summaryrefslogtreecommitdiffstats
path: root/src/openvg/qpaintengine_vg.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/openvg/qpaintengine_vg.cpp')
-rw-r--r--src/openvg/qpaintengine_vg.cpp69
1 files changed, 33 insertions, 36 deletions
diff --git a/src/openvg/qpaintengine_vg.cpp b/src/openvg/qpaintengine_vg.cpp
index 94e0793..8a485a0 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)