Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Toggle main menu visibility
Loading...
Searching...
No Matches
qquickpixmapcache_p.h
Go to the documentation of this file.
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
// Qt-Security score:significant reason:default
4
5
#
ifndef
QQUICKPIXMAPCACHE_H
6
#
define
QQUICKPIXMAPCACHE_H
7
8
//
9
// W A R N I N G
10
// -------------
11
//
12
// This file is not part of the Qt API. It exists purely as an
13
// implementation detail. This header file may change from version to
14
// version without notice, or even be removed.
15
//
16
// We mean it.
17
//
18
19
#
include
<
QtCore
/
qmutex
.
h
>
20
#
include
<
QtCore
/
qurl
.
h
>
21
#
include
<
QtQuick
/
qquickimageprovider
.
h
>
22
#
include
<
private
/
qquickpixmap_p
.
h
>
23
24
QT_BEGIN_NAMESPACE
25
26
class
QQuickPixmapData;
27
28
/*! \internal
29
A composite key to identify a QQuickPixmapData instance in a QHash.
30
*/
31
struct
Q_AUTOTEST_EXPORT
QQuickPixmapKey
32
{
33
const
QUrl *url;
34
const
QRect *region;
35
const
QSize *size;
36
int
frame;
37
QQuickImageProviderOptions options;
38
};
39
40
/*! \internal
41
A singleton managing the storage and garbage collection of QQuickPixmapData
42
instances. It's exported only for the sake of autotests, and should not be
43
manipulated outside qquickpixmap.cpp and qquickpixmapcache.cpp.
44
*/
45
class
Q_AUTOTEST_EXPORT
QQuickPixmapCache
:
public
QObject
46
{
47
Q_OBJECT
48
49
public
:
50
static
QQuickPixmapCache *instance();
51
~QQuickPixmapCache() override;
52
53
void
unreferencePixmap(QQuickPixmapData *);
54
void
referencePixmap(QQuickPixmapData *);
55
56
void
purgeCache();
57
58
protected
:
59
void
timerEvent(QTimerEvent *) override;
60
61
private
:
62
QQuickPixmapCache();
63
Q_DISABLE_COPY(QQuickPixmapCache)
64
65
void
shrinkCache(
int
remove);
66
void
maybeStartExpiryTimer();
67
int
destroyCache();
68
qsizetype referencedCost()
const
;
69
70
private
:
71
QHash<QQuickPixmapKey, QQuickPixmapData *> m_cache;
72
mutable
QMutex m_cacheMutex;
// avoid simultaneous iteration and modification
73
74
QQuickPixmapData *m_unreferencedPixmaps =
nullptr
;
75
QQuickPixmapData *m_lastUnreferencedPixmap =
nullptr
;
76
77
int
m_unreferencedCost = 0;
78
int
m_timerId = -1;
79
bool
m_destroying =
false
;
80
81
friend
class
QQuickPixmap;
82
friend
class
QQuickPixmapData;
83
friend
class
tst_qquickpixmapcache;
84
friend
class
tst_qquicktext;
85
friend
class
tst_qquicktextedit;
86
};
87
88
QT_END_NAMESPACE
89
90
#
endif
// QQUICKPIXMAPCACHE_H
QQuickPixmapCache
Definition
qquickpixmapcache_p.h:46
QQuickPixmapKey
Definition
qquickpixmapcache_p.h:32
qtdeclarative
src
quick
util
qquickpixmapcache_p.h
Generated on
for Qt by
1.18.0