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
7QT_BEGIN_NAMESPACE
8
9class QBlittablePrivate
10{
11public:
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
22QBlittable::QBlittable(const QSize &size, Capabilities caps)
23 : d_ptr(new QBlittablePrivate(size,caps))
24{
25}
26
27QBlittable::~QBlittable()
28{
29 delete d_ptr;
30}
31
32
33QBlittable::Capabilities QBlittable::capabilities() const
34{
35 Q_D(const QBlittable);
36 return d->caps;
37}
38
39QSize QBlittable::size() const
40{
41 Q_D(const QBlittable);
42 return d->m_size;
43}
44
45QImage *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
56void QBlittable::unlock()
57{
58 Q_D(QBlittable);
59 if (d->locked) {
60 doUnlock();
61 d->locked = false;
62 }
63}
64
65bool QBlittable::isLocked() const
66{
67 Q_D(const QBlittable);
68 return d->locked;
69}
70
71QT_END_NAMESPACE
72#endif //QT_NO_BLITTABLE
73
74

source code of qtbase/src/gui/painting/qblittable.cpp