| 1 | // Copyright (C) 2016 The Qt Company Ltd. |
| 2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only |
| 3 | |
| 4 | #ifndef QIMAGEPIXMAP_CLEANUPHOOKS_P_H |
| 5 | #define QIMAGEPIXMAP_CLEANUPHOOKS_P_H |
| 6 | |
| 7 | // |
| 8 | // W A R N I N G |
| 9 | // ------------- |
| 10 | // |
| 11 | // This file is not part of the Qt API. It exists purely as an |
| 12 | // implementation detail. This header file may change from version to |
| 13 | // version without notice, or even be removed. |
| 14 | // |
| 15 | // We mean it. |
| 16 | // |
| 17 | |
| 18 | #include <QtGui/private/qtguiglobal_p.h> |
| 19 | #include <QtGui/qpixmap.h> |
| 20 | |
| 21 | QT_BEGIN_NAMESPACE |
| 22 | |
| 23 | typedef void (*_qt_image_cleanup_hook_64)(qint64); |
| 24 | typedef void (*_qt_pixmap_cleanup_hook_pmd)(QPlatformPixmap*); |
| 25 | |
| 26 | |
| 27 | class QImagePixmapCleanupHooks; |
| 28 | |
| 29 | class Q_GUI_EXPORT QImagePixmapCleanupHooks |
| 30 | { |
| 31 | public: |
| 32 | static QImagePixmapCleanupHooks *instance(); |
| 33 | |
| 34 | static void enableCleanupHooks(const QImage &image); |
| 35 | static void enableCleanupHooks(const QPixmap &pixmap); |
| 36 | static void enableCleanupHooks(QPlatformPixmap *handle); |
| 37 | |
| 38 | static bool isImageCached(const QImage &image); |
| 39 | static bool isPixmapCached(const QPixmap &pixmap); |
| 40 | |
| 41 | // Gets called when a pixmap data is about to be modified: |
| 42 | void addPlatformPixmapModificationHook(_qt_pixmap_cleanup_hook_pmd); |
| 43 | |
| 44 | // Gets called when a pixmap data is about to be destroyed: |
| 45 | void addPlatformPixmapDestructionHook(_qt_pixmap_cleanup_hook_pmd); |
| 46 | |
| 47 | // Gets called when an image is about to be modified or destroyed: |
| 48 | void addImageHook(_qt_image_cleanup_hook_64); |
| 49 | |
| 50 | void removePlatformPixmapModificationHook(_qt_pixmap_cleanup_hook_pmd); |
| 51 | void removePlatformPixmapDestructionHook(_qt_pixmap_cleanup_hook_pmd); |
| 52 | void removeImageHook(_qt_image_cleanup_hook_64); |
| 53 | |
| 54 | static void executePlatformPixmapModificationHooks(QPlatformPixmap*); |
| 55 | static void executePlatformPixmapDestructionHooks(QPlatformPixmap*); |
| 56 | static void executeImageHooks(qint64 key); |
| 57 | |
| 58 | private: |
| 59 | QList<_qt_image_cleanup_hook_64> imageHooks; |
| 60 | QList<_qt_pixmap_cleanup_hook_pmd> pixmapModificationHooks; |
| 61 | QList<_qt_pixmap_cleanup_hook_pmd> pixmapDestructionHooks; |
| 62 | }; |
| 63 | |
| 64 | QT_END_NAMESPACE |
| 65 | |
| 66 | #endif // QIMAGEPIXMAP_CLEANUPHOOKS_P_H |
| 67 | |