summaryrefslogtreecommitdiffstats
path: root/src/openvg/qpixmapdata_vg.cpp
diff options
context:
space:
mode:
authorRhys Weatherley <rhys.weatherley@nokia.com>2009-12-06 22:32:53 (GMT)
committerRhys Weatherley <rhys.weatherley@nokia.com>2009-12-06 22:32:53 (GMT)
commit8f27913d0558c96a781b81834396374318b70fd6 (patch)
treef148c4ee794096de5e4c9dc69a160ca731dfb511 /src/openvg/qpixmapdata_vg.cpp
parent28206b2ec077396bc1fafffa4d85cab505f4409a (diff)
downloadQt-8f27913d0558c96a781b81834396374318b70fd6.zip
Qt-8f27913d0558c96a781b81834396374318b70fd6.tar.gz
Qt-8f27913d0558c96a781b81834396374318b70fd6.tar.bz2
Automatically destroy VG pixmaps when the last window surface goes away
Under S60, Qt will destroy the window surfaces of an application that goes into the background, which frees up EGL surface objects. But the VGImage's for pixmaps, and the EGLContext, were still using GPU memory. This change keeps track of the number of widgets / window surfaces that are in use and then calls hibernate() on all QVGPixmapData objects when it goes to zero. Once all the VGImage's are destroyed, the EGLContext should also be destroyed. Task-number: QT-2555 Reviewed-by: Sarah Smith
Diffstat (limited to 'src/openvg/qpixmapdata_vg.cpp')
-rw-r--r--src/openvg/qpixmapdata_vg.cpp33
1 files changed, 29 insertions, 4 deletions
diff --git a/src/openvg/qpixmapdata_vg.cpp b/src/openvg/qpixmapdata_vg.cpp
index 19c90ed..5d5fcbf 100644
--- a/src/openvg/qpixmapdata_vg.cpp
+++ b/src/openvg/qpixmapdata_vg.cpp
@@ -65,12 +65,21 @@ QVGPixmapData::QVGPixmapData(PixelType type)
recreate = true;
#if !defined(QT_NO_EGL)
context = 0;
+ qt_vg_register_pixmap(this);
#endif
setSerialNumber(++qt_vg_pixmap_serial);
}
QVGPixmapData::~QVGPixmapData()
{
+ destroyImageAndContext();
+#if !defined(QT_NO_EGL)
+ qt_vg_unregister_pixmap(this);
+#endif
+}
+
+void QVGPixmapData::destroyImageAndContext()
+{
if (vgImage != VG_INVALID_HANDLE) {
// We need to have a context current to destroy the image.
#if !defined(QT_NO_EGL)
@@ -93,11 +102,16 @@ QVGPixmapData::~QVGPixmapData()
if (vgImageOpacity != VG_INVALID_HANDLE)
vgDestroyImage(vgImageOpacity);
#endif
+ vgImage = VG_INVALID_HANDLE;
+ vgImageOpacity = VG_INVALID_HANDLE;
}
#if !defined(QT_NO_EGL)
- if (context)
- qt_vg_destroy_context(context);
+ if (context) {
+ qt_vg_destroy_context(context, QInternal::Pixmap);
+ context = 0;
+ }
#endif
+ recreate = true;
}
QPixmapData *QVGPixmapData::createCompatiblePixmapData() const
@@ -217,7 +231,7 @@ VGImage QVGPixmapData::toVGImage()
#if !defined(QT_NO_EGL)
// Increase the reference count on the shared context.
if (!context)
- context = qt_vg_create_context(0);
+ context = qt_vg_create_context(0, QInternal::Pixmap);
#endif
if (recreate && prevSize != QSize(w, h)) {
@@ -286,6 +300,17 @@ VGImage QVGPixmapData::toVGImage(qreal opacity)
#endif
}
+void QVGPixmapData::hibernate()
+{
+ // If the image was imported (e.g, from an SgImage under Symbian),
+ // then we cannot copy it back to main memory for storage.
+ if (vgImage != VG_INVALID_HANDLE && source.isNull())
+ return;
+
+ forceToImage();
+ destroyImageAndContext();
+}
+
extern int qt_defaultDpiX();
extern int qt_defaultDpiY();
@@ -376,7 +401,7 @@ void QVGPixmapData::fromNativeType(void* pixmap, NativeType type)
// when "0" used as argument then
// default display, context are used
if (!context)
- context = qt_vg_create_context(0);
+ context = qt_vg_create_context(0, QInternal::Pixmap);
if (vgImage != VG_INVALID_HANDLE) {
vgDestroyImage(vgImage);