diff options
author | Rhys Weatherley <rhys.weatherley@nokia.com> | 2009-08-25 02:59:14 (GMT) |
---|---|---|
committer | Rhys Weatherley <rhys.weatherley@nokia.com> | 2009-08-25 02:59:14 (GMT) |
commit | 7c04a404e5ba63cd9c8bdf1e3c891e796adf2c39 (patch) | |
tree | 9baec16ae2e855fa04b66369638b01e010948be1 /src/openvg/qpaintengine_vg.cpp | |
parent | 81c094621d64b5a6547c232c7282582339b16045 (diff) | |
download | Qt-7c04a404e5ba63cd9c8bdf1e3c891e796adf2c39.zip Qt-7c04a404e5ba63cd9c8bdf1e3c891e796adf2c39.tar.gz Qt-7c04a404e5ba63cd9c8bdf1e3c891e796adf2c39.tar.bz2 |
Don't dereference VGImage's that come from QVGPixmapData
TexturePattern brushes were sometimes turning all black with OpenVG.
This was due to the vgDestroyImage() destroying the cached VGImage
in the QVGPixmapData. We only need to use vgDestroyImage() if the
QPixmap is not backed up by a QVGPixmapData (bitmaps and pixmaps
from other paint engines).
Reviewed-by: Sarah Smith
Diffstat (limited to 'src/openvg/qpaintengine_vg.cpp')
-rw-r--r-- | src/openvg/qpaintengine_vg.cpp | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/src/openvg/qpaintengine_vg.cpp b/src/openvg/qpaintengine_vg.cpp index 5669f45..d2c7b8b 100644 --- a/src/openvg/qpaintengine_vg.cpp +++ b/src/openvg/qpaintengine_vg.cpp @@ -1091,6 +1091,7 @@ VGPaintType QVGPaintEnginePrivate::setBrush // The brush is a texture specified by a QPixmap/QImage. QPixmapData *pd = brush.texture().pixmapData(); VGImage vgImg; + bool deref = false; if (pd->pixelType() == QPixmapData::BitmapType) { // Colorize bitmaps using the brush color and opacity. QColor color = brush.color(); @@ -1098,15 +1099,21 @@ VGPaintType QVGPaintEnginePrivate::setBrush color.setAlphaF(color.alphaF() * opacity); QImage image = colorizeBitmap(*(pd->buffer()), color); vgImg = toVGImage(image); + deref = true; } else if (opacity == 1.0) { if (pd->classId() == QPixmapData::OpenVGClass) { QVGPixmapData *vgpd = static_cast<QVGPixmapData *>(pd); vgImg = vgpd->toVGImage(); } else { vgImg = toVGImage(*(pd->buffer())); + deref = true; } + } else if (pd->classId() == QPixmapData::OpenVGClass) { + QVGPixmapData *vgpd = static_cast<QVGPixmapData *>(pd); + vgImg = vgpd->toVGImage(opacity); } else { vgImg = toVGImageWithOpacity(*(pd->buffer()), opacity); + deref = true; } if (vgImg == VG_INVALID_HANDLE) break; @@ -1114,7 +1121,8 @@ VGPaintType QVGPaintEnginePrivate::setBrush vgSetParameteri(paint, VG_PAINT_TYPE, VG_PAINT_TYPE_PATTERN); vgSetParameteri(paint, VG_PAINT_PATTERN_TILING_MODE, VG_TILE_REPEAT); vgPaintPattern(paint, vgImg); - vgDestroyImage(vgImg); // Will stay valid until pattern is destroyed. + if (deref) + vgDestroyImage(vgImg); // Will be valid until pattern is destroyed. return VG_PAINT_TYPE_PATTERN; } |