| Absolute File Name: | /home/qt/qt5_coco/qt5/qtbase/src/gui/image/qimagepixmapcleanuphooks.cpp |
| Source code | Switch to Preprocessed file |
| Line | Source | Count | ||||||
|---|---|---|---|---|---|---|---|---|
| 1 | /**************************************************************************** | - | ||||||
| 2 | ** | - | ||||||
| 3 | ** Copyright (C) 2015 The Qt Company Ltd. | - | ||||||
| 4 | ** Contact: http://www.qt.io/licensing/ | - | ||||||
| 5 | ** | - | ||||||
| 6 | ** This file is part of the QtGui module of the Qt Toolkit. | - | ||||||
| 7 | ** | - | ||||||
| 8 | ** $QT_BEGIN_LICENSE:LGPL21$ | - | ||||||
| 9 | ** Commercial License Usage | - | ||||||
| 10 | ** Licensees holding valid commercial Qt licenses may use this file in | - | ||||||
| 11 | ** accordance with the commercial license agreement provided with the | - | ||||||
| 12 | ** Software or, alternatively, in accordance with the terms contained in | - | ||||||
| 13 | ** a written agreement between you and The Qt Company. For licensing terms | - | ||||||
| 14 | ** and conditions see http://www.qt.io/terms-conditions. For further | - | ||||||
| 15 | ** information use the contact form at http://www.qt.io/contact-us. | - | ||||||
| 16 | ** | - | ||||||
| 17 | ** GNU Lesser General Public License Usage | - | ||||||
| 18 | ** Alternatively, this file may be used under the terms of the GNU Lesser | - | ||||||
| 19 | ** General Public License version 2.1 or version 3 as published by the Free | - | ||||||
| 20 | ** Software Foundation and appearing in the file LICENSE.LGPLv21 and | - | ||||||
| 21 | ** LICENSE.LGPLv3 included in the packaging of this file. Please review the | - | ||||||
| 22 | ** following information to ensure the GNU Lesser General Public License | - | ||||||
| 23 | ** requirements will be met: https://www.gnu.org/licenses/lgpl.html and | - | ||||||
| 24 | ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. | - | ||||||
| 25 | ** | - | ||||||
| 26 | ** As a special exception, The Qt Company gives you certain additional | - | ||||||
| 27 | ** rights. These rights are described in The Qt Company LGPL Exception | - | ||||||
| 28 | ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. | - | ||||||
| 29 | ** | - | ||||||
| 30 | ** $QT_END_LICENSE$ | - | ||||||
| 31 | ** | - | ||||||
| 32 | ****************************************************************************/ | - | ||||||
| 33 | - | |||||||
| 34 | #include "qimagepixmapcleanuphooks_p.h" | - | ||||||
| 35 | #include <qpa/qplatformpixmap.h> | - | ||||||
| 36 | #include "private/qimage_p.h" | - | ||||||
| 37 | - | |||||||
| 38 | - | |||||||
| 39 | QT_BEGIN_NAMESPACE | - | ||||||
| 40 | - | |||||||
| 41 | Q_GLOBAL_STATIC(QImagePixmapCleanupHooks, qt_image_and_pixmap_cleanup_hooks) never executed: end of blocknever executed: guard.store(QtGlobalStatic::Destroyed);never executed: return &holder.value;
| 0 | ||||||
| 42 | - | |||||||
| 43 | QImagePixmapCleanupHooks *QImagePixmapCleanupHooks::instance() | - | ||||||
| 44 | { | - | ||||||
| 45 | return qt_image_and_pixmap_cleanup_hooks(); never executed: return qt_image_and_pixmap_cleanup_hooks(); | 0 | ||||||
| 46 | } | - | ||||||
| 47 | - | |||||||
| 48 | void QImagePixmapCleanupHooks::addPlatformPixmapModificationHook(_qt_pixmap_cleanup_hook_pmd hook) | - | ||||||
| 49 | { | - | ||||||
| 50 | pixmapModificationHooks.append(hook); | - | ||||||
| 51 | } never executed: end of block | 0 | ||||||
| 52 | - | |||||||
| 53 | void QImagePixmapCleanupHooks::addPlatformPixmapDestructionHook(_qt_pixmap_cleanup_hook_pmd hook) | - | ||||||
| 54 | { | - | ||||||
| 55 | pixmapDestructionHooks.append(hook); | - | ||||||
| 56 | } never executed: end of block | 0 | ||||||
| 57 | - | |||||||
| 58 | - | |||||||
| 59 | void QImagePixmapCleanupHooks::addImageHook(_qt_image_cleanup_hook_64 hook) | - | ||||||
| 60 | { | - | ||||||
| 61 | imageHooks.append(hook); | - | ||||||
| 62 | } never executed: end of block | 0 | ||||||
| 63 | - | |||||||
| 64 | void QImagePixmapCleanupHooks::removePlatformPixmapModificationHook(_qt_pixmap_cleanup_hook_pmd hook) | - | ||||||
| 65 | { | - | ||||||
| 66 | pixmapModificationHooks.removeAll(hook); | - | ||||||
| 67 | } never executed: end of block | 0 | ||||||
| 68 | - | |||||||
| 69 | void QImagePixmapCleanupHooks::removePlatformPixmapDestructionHook(_qt_pixmap_cleanup_hook_pmd hook) | - | ||||||
| 70 | { | - | ||||||
| 71 | pixmapDestructionHooks.removeAll(hook); | - | ||||||
| 72 | } never executed: end of block | 0 | ||||||
| 73 | - | |||||||
| 74 | void QImagePixmapCleanupHooks::removeImageHook(_qt_image_cleanup_hook_64 hook) | - | ||||||
| 75 | { | - | ||||||
| 76 | imageHooks.removeAll(hook); | - | ||||||
| 77 | } never executed: end of block | 0 | ||||||
| 78 | - | |||||||
| 79 | void QImagePixmapCleanupHooks::executePlatformPixmapModificationHooks(QPlatformPixmap* pmd) | - | ||||||
| 80 | { | - | ||||||
| 81 | QImagePixmapCleanupHooks *h = qt_image_and_pixmap_cleanup_hooks(); | - | ||||||
| 82 | // the global destructor for the pixmap and image hooks might have | - | ||||||
| 83 | // been called already if the app is "leaking" global | - | ||||||
| 84 | // pixmaps/images | - | ||||||
| 85 | if (!h)
| 0 | ||||||
| 86 | return; never executed: return; | 0 | ||||||
| 87 | for (int i = 0; i < h->pixmapModificationHooks.count(); ++i)
| 0 | ||||||
| 88 | h->pixmapModificationHooks[i](pmd); never executed: h->pixmapModificationHooks[i](pmd); | 0 | ||||||
| 89 | } never executed: end of block | 0 | ||||||
| 90 | - | |||||||
| 91 | void QImagePixmapCleanupHooks::executePlatformPixmapDestructionHooks(QPlatformPixmap* pmd) | - | ||||||
| 92 | { | - | ||||||
| 93 | QImagePixmapCleanupHooks *h = qt_image_and_pixmap_cleanup_hooks(); | - | ||||||
| 94 | // the global destructor for the pixmap and image hooks might have | - | ||||||
| 95 | // been called already if the app is "leaking" global | - | ||||||
| 96 | // pixmaps/images | - | ||||||
| 97 | if (!h)
| 0 | ||||||
| 98 | return; never executed: return; | 0 | ||||||
| 99 | for (int i = 0; i < h->pixmapDestructionHooks.count(); ++i)
| 0 | ||||||
| 100 | h->pixmapDestructionHooks[i](pmd); never executed: h->pixmapDestructionHooks[i](pmd); | 0 | ||||||
| 101 | } never executed: end of block | 0 | ||||||
| 102 | - | |||||||
| 103 | void QImagePixmapCleanupHooks::executeImageHooks(qint64 key) | - | ||||||
| 104 | { | - | ||||||
| 105 | QImagePixmapCleanupHooks *h = qt_image_and_pixmap_cleanup_hooks(); | - | ||||||
| 106 | // the global destructor for the pixmap and image hooks might have | - | ||||||
| 107 | // been called already if the app is "leaking" global | - | ||||||
| 108 | // pixmaps/images | - | ||||||
| 109 | if (!h)
| 0 | ||||||
| 110 | return; never executed: return; | 0 | ||||||
| 111 | for (int i = 0; i < h->imageHooks.count(); ++i)
| 0 | ||||||
| 112 | h->imageHooks[i](key); never executed: h->imageHooks[i](key); | 0 | ||||||
| 113 | } never executed: end of block | 0 | ||||||
| 114 | - | |||||||
| 115 | - | |||||||
| 116 | void QImagePixmapCleanupHooks::enableCleanupHooks(QPlatformPixmap *handle) | - | ||||||
| 117 | { | - | ||||||
| 118 | handle->is_cached = true; | - | ||||||
| 119 | } never executed: end of block | 0 | ||||||
| 120 | - | |||||||
| 121 | void QImagePixmapCleanupHooks::enableCleanupHooks(const QPixmap &pixmap) | - | ||||||
| 122 | { | - | ||||||
| 123 | enableCleanupHooks(const_cast<QPixmap &>(pixmap).data_ptr().data()); | - | ||||||
| 124 | } never executed: end of block | 0 | ||||||
| 125 | - | |||||||
| 126 | void QImagePixmapCleanupHooks::enableCleanupHooks(const QImage &image) | - | ||||||
| 127 | { | - | ||||||
| 128 | const_cast<QImage &>(image).data_ptr()->is_cached = true; | - | ||||||
| 129 | } never executed: end of block | 0 | ||||||
| 130 | - | |||||||
| 131 | bool QImagePixmapCleanupHooks::isImageCached(const QImage &image) | - | ||||||
| 132 | { | - | ||||||
| 133 | return const_cast<QImage &>(image).data_ptr()->is_cached; never executed: return const_cast<QImage &>(image).data_ptr()->is_cached; | 0 | ||||||
| 134 | } | - | ||||||
| 135 | - | |||||||
| 136 | bool QImagePixmapCleanupHooks::isPixmapCached(const QPixmap &pixmap) | - | ||||||
| 137 | { | - | ||||||
| 138 | return const_cast<QPixmap&>(pixmap).data_ptr().data()->is_cached; never executed: return const_cast<QPixmap&>(pixmap).data_ptr().data()->is_cached; | 0 | ||||||
| 139 | } | - | ||||||
| 140 | - | |||||||
| 141 | - | |||||||
| 142 | - | |||||||
| 143 | QT_END_NAMESPACE | - | ||||||
| Source code | Switch to Preprocessed file |