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 | #include "qblittable_p.h" |
5 | |
6 | #ifndef QT_NO_BLITTABLE |
7 | QT_BEGIN_NAMESPACE |
8 | |
9 | class QBlittablePrivate |
10 | { |
11 | public: |
12 | QBlittablePrivate(const QSize &size, QBlittable::Capabilities caps) |
13 | : caps(caps), m_size(size), locked(false), cachedImg(nullptr) |
14 | {} |
15 | QBlittable::Capabilities caps; |
16 | QSize m_size; |
17 | bool locked; |
18 | QImage *cachedImg; |
19 | }; |
20 | |
21 | |
22 | QBlittable::QBlittable(const QSize &size, Capabilities caps) |
23 | : d_ptr(new QBlittablePrivate(size,caps)) |
24 | { |
25 | } |
26 | |
27 | QBlittable::~QBlittable() |
28 | { |
29 | delete d_ptr; |
30 | } |
31 | |
32 | |
33 | QBlittable::Capabilities QBlittable::capabilities() const |
34 | { |
35 | Q_D(const QBlittable); |
36 | return d->caps; |
37 | } |
38 | |
39 | QSize QBlittable::size() const |
40 | { |
41 | Q_D(const QBlittable); |
42 | return d->m_size; |
43 | } |
44 | |
45 | QImage *QBlittable::lock() |
46 | { |
47 | Q_D(QBlittable); |
48 | if (!d->locked) { |
49 | d->cachedImg = doLock(); |
50 | d->locked = true; |
51 | } |
52 | |
53 | return d->cachedImg; |
54 | } |
55 | |
56 | void QBlittable::unlock() |
57 | { |
58 | Q_D(QBlittable); |
59 | if (d->locked) { |
60 | doUnlock(); |
61 | d->locked = false; |
62 | } |
63 | } |
64 | |
65 | bool QBlittable::isLocked() const |
66 | { |
67 | Q_D(const QBlittable); |
68 | return d->locked; |
69 | } |
70 | |
71 | QT_END_NAMESPACE |
72 | #endif //QT_NO_BLITTABLE |
73 | |
74 |