summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorRhys Weatherley <rhys.weatherley@nokia.com>2009-11-20 06:32:35 (GMT)
committerJason McDonald <jason.mcdonald@nokia.com>2009-11-20 14:38:28 (GMT)
commit4d62d72256bd5d381930f198e7e89abaf4dead97 (patch)
treeb05895ec2cd2e9ab33ac3d0a66541fd1f64f9351 /src
parenta9dfb78fbe966cef2fac24baf26617aa74316b64 (diff)
downloadQt-4d62d72256bd5d381930f198e7e89abaf4dead97.zip
Qt-4d62d72256bd5d381930f198e7e89abaf4dead97.tar.gz
Qt-4d62d72256bd5d381930f198e7e89abaf4dead97.tar.bz2
Do not recreate the VGImage if the size is unchanged
When a pixmap's contents change in QVGPixmapData, only recreate the VGImage in the GPU if the size is different than before. This should help reduce GPU memory fragmentation. Task-number: QT-2504 Reviewed-by: Sarah Smith (cherry picked from commit a8c8c2274d2d0a708786adbb357013955f99c0af)
Diffstat (limited to 'src')
-rw-r--r--src/openvg/qpixmapdata_vg.cpp42
-rw-r--r--src/openvg/qpixmapdata_vg_p.h1
2 files changed, 10 insertions, 33 deletions
diff --git a/src/openvg/qpixmapdata_vg.cpp b/src/openvg/qpixmapdata_vg.cpp
index af75de3..8de5e4f 100644
--- a/src/openvg/qpixmapdata_vg.cpp
+++ b/src/openvg/qpixmapdata_vg.cpp
@@ -220,7 +220,7 @@ VGImage QVGPixmapData::toVGImage()
context = qt_vg_create_context(0);
#endif
- if (recreate) {
+ if (recreate && prevSize != QSize(w, h)) {
if (vgImage != VG_INVALID_HANDLE) {
vgDestroyImage(vgImage);
vgImage = VG_INVALID_HANDLE;
@@ -229,6 +229,8 @@ VGImage QVGPixmapData::toVGImage()
vgDestroyImage(vgImageOpacity);
vgImageOpacity = VG_INVALID_HANDLE;
}
+ } else if (recreate) {
+ cachedOpacity = -1.0f; // Force opacity image to be refreshed later.
}
if (vgImage == VG_INVALID_HANDLE) {
@@ -244,6 +246,7 @@ VGImage QVGPixmapData::toVGImage()
}
recreate = false;
+ prevSize = QSize(w, h);
return vgImage;
}
@@ -251,43 +254,14 @@ VGImage QVGPixmapData::toVGImage()
VGImage QVGPixmapData::toVGImage(qreal opacity)
{
#if !defined(QT_SHIVAVG)
- if (!isValid())
+ // Force the primary VG image to be recreated if necessary.
+ if (toVGImage() == VG_INVALID_HANDLE)
return VG_INVALID_HANDLE;
-#if !defined(QT_NO_EGL)
- // Increase the reference count on the shared context.
- if (!context)
- context = qt_vg_create_context(0);
-#endif
-
- if (recreate) {
- if (vgImage != VG_INVALID_HANDLE) {
- vgDestroyImage(vgImage);
- vgImage = VG_INVALID_HANDLE;
- }
- if (vgImageOpacity != VG_INVALID_HANDLE) {
- vgDestroyImage(vgImageOpacity);
- vgImageOpacity = VG_INVALID_HANDLE;
- }
- }
-
- if (vgImage == VG_INVALID_HANDLE) {
- vgImage = vgCreateImage
- (VG_sARGB_8888_PRE, w, h, VG_IMAGE_QUALITY_FASTER);
- }
-
- if (!source.isNull() && recreate) {
- vgImageSubData
- (vgImage,
- qt_vg_imageBits(source), source.bytesPerLine(),
- VG_sARGB_8888_PRE, 0, 0, w, h);
- }
-
- recreate = false;
-
if (opacity == 1.0f)
return vgImage;
+ // Create an alternative image for the selected opacity.
if (vgImageOpacity == VG_INVALID_HANDLE || cachedOpacity != opacity) {
if (vgImageOpacity == VG_INVALID_HANDLE) {
vgImageOpacity = vgCreateImage
@@ -412,6 +386,7 @@ void QVGPixmapData::fromNativeType(void* pixmap, NativeType type)
vgDestroyImage(vgImageOpacity);
vgImageOpacity = VG_INVALID_HANDLE;
}
+ prevSize = QSize();
TInt err = 0;
@@ -472,6 +447,7 @@ void QVGPixmapData::fromNativeType(void* pixmap, NativeType type)
is_null = (w <= 0 || h <= 0);
source = QImage();
recreate = false;
+ prevSize = QSize(w, h);
setSerialNumber(++qt_vg_pixmap_serial);
// release stuff
eglDestroyImageKHR(context->display(), eglImage);
diff --git a/src/openvg/qpixmapdata_vg_p.h b/src/openvg/qpixmapdata_vg_p.h
index eea0b7d..6bb0d23 100644
--- a/src/openvg/qpixmapdata_vg_p.h
+++ b/src/openvg/qpixmapdata_vg_p.h
@@ -109,6 +109,7 @@ protected:
#endif
protected:
+ QSize prevSize;
VGImage vgImage;
VGImage vgImageOpacity;
qreal cachedOpacity;