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
24QT_BEGIN_NAMESPACE
25
26size_t qHash(const QPixmapCache::Key &k, size_t seed = 0);
27
28class QPixmapCache::KeyData
29{
30public:
31 KeyData() : isValid(true), key(0), ref(1) {}
32 KeyData(const KeyData &other)
33 : isValid(other.isValid), key(other.key), ref(1) {}
34 ~KeyData() {}
35
36 bool isValid;
37 int key;
38 int ref;
39};
40
41// XXX: hw: is this a general concept we need to abstract?
42class QPixmapCacheEntry : public QPixmap
43{
44public:
45 QPixmapCacheEntry(const QPixmapCache::Key &key, const QPixmap &pix) : QPixmap(pix), key(key)
46 {
47 QPlatformPixmap *pd = handle();
48 if (pd && pd->classId() == QPlatformPixmap::RasterClass) {
49 QRasterPlatformPixmap *d = static_cast<QRasterPlatformPixmap*>(pd);
50 if (!d->image.isNull() && d->image.d->paintEngine
51 && !d->image.d->paintEngine->isActive())
52 {
53 delete d->image.d->paintEngine;
54 d->image.d->paintEngine = nullptr;
55 }
56 }
57 }
58 ~QPixmapCacheEntry();
59 QPixmapCache::Key key;
60};
61
62QT_END_NAMESPACE
63
64#endif // QPIXMAPCACHE_P_H
65

source code of qtbase/src/gui/image/qpixmapcache_p.h