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 QPLATFORMGRAPHICSBUFFER_H |
5 | #define QPLATFORMGRAPHICSBUFFER_H |
6 | |
7 | // |
8 | // W A R N I N G |
9 | // ------------- |
10 | // |
11 | // This file is part of the QPA API and is not meant to be used |
12 | // in applications. Usage of this API may make your code |
13 | // source and binary incompatible with future versions of Qt. |
14 | // |
15 | |
16 | |
17 | #include <QtGui/qtguiglobal.h> |
18 | #include <QtCore/QSize> |
19 | #include <QtCore/QRect> |
20 | #include <QtGui/QPixelFormat> |
21 | #include <QtCore/qflags.h> |
22 | #include <QtCore/QObject> |
23 | |
24 | QT_BEGIN_NAMESPACE |
25 | |
26 | class Q_GUI_EXPORT QPlatformGraphicsBuffer : public QObject |
27 | { |
28 | Q_OBJECT |
29 | public: |
30 | enum AccessType |
31 | { |
32 | None = 0x00, |
33 | SWReadAccess = 0x01, |
34 | SWWriteAccess = 0x02, |
35 | TextureAccess = 0x04, |
36 | HWCompositor = 0x08 |
37 | }; |
38 | Q_ENUM(AccessType); |
39 | Q_DECLARE_FLAGS(AccessTypes, AccessType); |
40 | |
41 | enum Origin { |
42 | OriginBottomLeft, |
43 | OriginTopLeft |
44 | }; |
45 | Q_ENUM(Origin); |
46 | |
47 | ~QPlatformGraphicsBuffer(); |
48 | |
49 | AccessTypes isLocked() const { return m_lock_access; } |
50 | bool lock(AccessTypes access, const QRect &rect = QRect()); |
51 | void unlock(); |
52 | |
53 | virtual bool bindToTexture(const QRect &rect = QRect()) const; |
54 | |
55 | virtual const uchar *data() const; |
56 | virtual uchar *data(); |
57 | virtual int bytesPerLine() const; |
58 | int byteCount() const; |
59 | |
60 | virtual Origin origin() const; |
61 | |
62 | QSize size() const { return m_size; } |
63 | QPixelFormat format() const { return m_format; } |
64 | |
65 | Q_SIGNALS: |
66 | void unlocked(AccessTypes previousAccessTypes); |
67 | |
68 | protected: |
69 | QPlatformGraphicsBuffer(const QSize &size, const QPixelFormat &format); |
70 | |
71 | virtual bool doLock(AccessTypes access, const QRect &rect = QRect()) = 0; |
72 | virtual void doUnlock() = 0; |
73 | |
74 | private: |
75 | QSize m_size; |
76 | QPixelFormat m_format; |
77 | AccessTypes m_lock_access; |
78 | }; |
79 | |
80 | QT_END_NAMESPACE |
81 | |
82 | #endif //QPLATFORMGRAPHICSBUFFER_H |
83 |