summaryrefslogtreecommitdiffstats
path: root/src/openvg/qpixmapdata_vg_p.h
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_p.h
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_p.h')
-rw-r--r--src/openvg/qpixmapdata_vg_p.h31
1 files changed, 29 insertions, 2 deletions
diff --git a/src/openvg/qpixmapdata_vg_p.h b/src/openvg/qpixmapdata_vg_p.h
index fe19f35..c0bb098 100644
--- a/src/openvg/qpixmapdata_vg_p.h
+++ b/src/openvg/qpixmapdata_vg_p.h
@@ -55,8 +55,6 @@
#include <QtGui/private/qpixmap_raster_p.h>
#include <private/qvg_p.h>
-#if !defined(QT_NO_EGL)
-#endif
#if defined(Q_OS_SYMBIAN)
class RSGImage;
@@ -66,6 +64,15 @@ QT_BEGIN_NAMESPACE
class QEglContext;
+#if !defined(QT_NO_EGL)
+class QVGPixmapData;
+class QVGSharedContext;
+
+void qt_vg_register_pixmap(QVGPixmapData *pd);
+void qt_vg_unregister_pixmap(QVGPixmapData *pd);
+void qt_vg_hibernate_pixmaps(QVGSharedContext *context);
+#endif
+
class Q_OPENVG_EXPORT QVGPixmapData : public QPixmapData
{
public:
@@ -94,6 +101,14 @@ public:
// Return the VGImage form for a specific opacity setting.
virtual VGImage toVGImage(qreal opacity);
+ // Release the VG resources associated with this pixmap and copy
+ // the pixmap's contents out of the GPU back into main memory.
+ // The VG resource will be automatically recreated the next time
+ // toVGImage() is called. Does nothing if the pixmap cannot be
+ // hibernated for some reason (e.g. VGImage is shared with another
+ // process via a SgImage).
+ virtual void hibernate();
+
QSize size() const { return QSize(w, h); }
#if defined(Q_OS_SYMBIAN)
@@ -108,6 +123,16 @@ protected:
void cleanup();
#endif
+#if !defined(QT_NO_EGL)
+private:
+ QVGPixmapData *next;
+ QVGPixmapData *prev;
+
+ friend void qt_vg_register_pixmap(QVGPixmapData *pd);
+ friend void qt_vg_unregister_pixmap(QVGPixmapData *pd);
+ friend void qt_vg_hibernate_pixmaps(QVGSharedContext *context);
+#endif
+
protected:
QSize prevSize;
VGImage vgImage;
@@ -121,6 +146,8 @@ protected:
void forceToImage();
QImage::Format sourceFormat() const;
+
+ void destroyImageAndContext();
};
QT_END_NAMESPACE