summaryrefslogtreecommitdiffstats
path: root/src/gui/image/qimagepixmapcleanuphooks.cpp
diff options
context:
space:
mode:
authorTom Cooksey <thomas.cooksey@nokia.com>2009-10-12 13:39:52 (GMT)
committerTom Cooksey <thomas.cooksey@nokia.com>2009-10-19 12:56:38 (GMT)
commit22b9079040ae0d4f35781509fa6aea7e38ac47bb (patch)
treeeca3b24f135eb74d63b7dde57124baedbfdeed3e /src/gui/image/qimagepixmapcleanuphooks.cpp
parente2296ba010100d007a081e0faac8066adbeb7137 (diff)
downloadQt-22b9079040ae0d4f35781509fa6aea7e38ac47bb.zip
Qt-22b9079040ae0d4f35781509fa6aea7e38ac47bb.tar.gz
Qt-22b9079040ae0d4f35781509fa6aea7e38ac47bb.tar.bz2
Separate modification & destruction pixmap cleanup hooks
Before the QExplicitlySharedDataPointer change, the ref-count was 0 when calling the cleanup hooks from ~QPixmap. That enabled the hook to figure out if the pixmap is being modified or deleted. As the ref count is now 1 when calling the cleanup hooks in ~QPixmap, we need to seperate the hooks. This change should make using textre-from-pixmap faster as the EGL/glX surface wont get re-created everytime the pixmap is modified. Reviewed-By: Gunnar
Diffstat (limited to 'src/gui/image/qimagepixmapcleanuphooks.cpp')
-rw-r--r--src/gui/image/qimagepixmapcleanuphooks.cpp35
1 files changed, 28 insertions, 7 deletions
diff --git a/src/gui/image/qimagepixmapcleanuphooks.cpp b/src/gui/image/qimagepixmapcleanuphooks.cpp
index d08d3ef..138eb0d 100644
--- a/src/gui/image/qimagepixmapcleanuphooks.cpp
+++ b/src/gui/image/qimagepixmapcleanuphooks.cpp
@@ -70,19 +70,30 @@ QImagePixmapCleanupHooks *QImagePixmapCleanupHooks::instance()
return qt_image_and_pixmap_cleanup_hooks;
}
-void QImagePixmapCleanupHooks::addPixmapHook(_qt_pixmap_cleanup_hook_pm hook)
+void QImagePixmapCleanupHooks::addPixmapModificationHook(_qt_pixmap_cleanup_hook_pm hook)
{
- pixmapHooks.append(hook);
+ pixmapModificationHooks.append(hook);
}
+void QImagePixmapCleanupHooks::addPixmapDestructionHook(_qt_pixmap_cleanup_hook_pm hook)
+{
+ pixmapDestructionHooks.append(hook);
+}
+
+
void QImagePixmapCleanupHooks::addImageHook(_qt_image_cleanup_hook_64 hook)
{
imageHooks.append(hook);
}
-void QImagePixmapCleanupHooks::removePixmapHook(_qt_pixmap_cleanup_hook_pm hook)
+void QImagePixmapCleanupHooks::removePixmapModificationHook(_qt_pixmap_cleanup_hook_pm hook)
+{
+ pixmapModificationHooks.removeAll(hook);
+}
+
+void QImagePixmapCleanupHooks::removePixmapDestructionHook(_qt_pixmap_cleanup_hook_pm hook)
{
- pixmapHooks.removeAll(hook);
+ pixmapDestructionHooks.removeAll(hook);
}
void QImagePixmapCleanupHooks::removeImageHook(_qt_image_cleanup_hook_64 hook)
@@ -91,15 +102,25 @@ void QImagePixmapCleanupHooks::removeImageHook(_qt_image_cleanup_hook_64 hook)
}
-void QImagePixmapCleanupHooks::executePixmapHooks(QPixmap* pm)
+void QImagePixmapCleanupHooks::executePixmapModificationHooks(QPixmap* pm)
{
- for (int i = 0; i < qt_image_and_pixmap_cleanup_hooks->pixmapHooks.count(); ++i)
- qt_image_and_pixmap_cleanup_hooks->pixmapHooks[i](pm);
+ Q_ASSERT(qt_image_and_pixmap_cleanup_hooks);
+ for (int i = 0; i < qt_image_and_pixmap_cleanup_hooks->pixmapModificationHooks.count(); ++i)
+ qt_image_and_pixmap_cleanup_hooks->pixmapModificationHooks[i](pm);
if (qt_pixmap_cleanup_hook_64)
qt_pixmap_cleanup_hook_64(pm->cacheKey());
}
+void QImagePixmapCleanupHooks::executePixmapDestructionHooks(QPixmap* pm)
+{
+ Q_ASSERT(qt_image_and_pixmap_cleanup_hooks);
+ for (int i = 0; i < qt_image_and_pixmap_cleanup_hooks->pixmapDestructionHooks.count(); ++i)
+ qt_image_and_pixmap_cleanup_hooks->pixmapDestructionHooks[i](pm);
+
+ if (qt_pixmap_cleanup_hook_64)
+ qt_pixmap_cleanup_hook_64(pm->cacheKey());
+}
void QImagePixmapCleanupHooks::executeImageHooks(qint64 key)
{