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 QPIXMAPCACHE_P_H |
5 | #define QPIXMAPCACHE_P_H |
6 | |
7 | // |
8 | // W A R N I N G |
9 | // ------------- |
10 | // |
11 | // This file is not part of the Qt API. This header |
12 | // file may change from version to version without notice, or even be removed. |
13 | // |
14 | // We mean it. |
15 | // |
16 | |
17 | #include <QtGui/private/qtguiglobal_p.h> |
18 | #include "qpixmapcache.h" |
19 | #include "qpaintengine.h" |
20 | #include <private/qimage_p.h> |
21 | #include <private/qpixmap_raster_p.h> |
22 | #include "qcache.h" |
23 | |
24 | QT_BEGIN_NAMESPACE |
25 | |
26 | class QPixmapCache::KeyData |
27 | { |
28 | public: |
29 | KeyData() : isValid(true), key(0), ref(1) {} |
30 | KeyData(const KeyData &other) |
31 | : isValid(other.isValid), key(other.key), ref(1) {} |
32 | ~KeyData() {} |
33 | |
34 | QString stringKey; |
35 | bool isValid; |
36 | int key; |
37 | int ref; |
38 | }; |
39 | |
40 | // XXX: hw: is this a general concept we need to abstract? |
41 | class QPixmapCacheEntry : public QPixmap |
42 | { |
43 | public: |
44 | QPixmapCacheEntry(const QPixmapCache::Key &key, const QPixmap &pix) : QPixmap(pix), key(key) |
45 | { |
46 | QPlatformPixmap *pd = handle(); |
47 | if (pd && pd->classId() == QPlatformPixmap::RasterClass) { |
48 | QRasterPlatformPixmap *d = static_cast<QRasterPlatformPixmap*>(pd); |
49 | if (!d->image.isNull() && d->image.d->paintEngine |
50 | && !d->image.d->paintEngine->isActive()) |
51 | { |
52 | delete d->image.d->paintEngine; |
53 | d->image.d->paintEngine = nullptr; |
54 | } |
55 | } |
56 | } |
57 | ~QPixmapCacheEntry(); |
58 | QPixmapCache::Key key; |
59 | }; |
60 | |
61 | QT_END_NAMESPACE |
62 | |
63 | #endif // QPIXMAPCACHE_P_H |
64 |