1 | // Copyright (C) 2016 Klaralvdalens Datakonsult AB (KDAB). |
---|---|
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 QT3DRENDER_QPAINTEDTEXTURE_P_H |
5 | #define QT3DRENDER_QPAINTEDTEXTURE_P_H |
6 | |
7 | // |
8 | // W A R N I N G |
9 | // ------------- |
10 | // |
11 | // This file is not part of the Qt API. It exists for the convenience |
12 | // of other Qt classes. This header file may change from version to |
13 | // version without notice, or even be removed. |
14 | // |
15 | // We mean it. |
16 | // |
17 | |
18 | #include <Qt3DRender/private/qabstracttextureimage_p.h> |
19 | #include <Qt3DRender/qtextureimagedatagenerator.h> |
20 | #include <Qt3DRender/qpaintedtextureimage.h> |
21 | #include <Qt3DRender/private/qt3drender_global_p.h> |
22 | |
23 | QT_BEGIN_NAMESPACE |
24 | |
25 | class QImage; |
26 | class QPainter; |
27 | |
28 | namespace Qt3DRender { |
29 | |
30 | class Q_3DRENDERSHARED_PRIVATE_EXPORT QPaintedTextureImagePrivate : public QAbstractTextureImagePrivate |
31 | { |
32 | public: |
33 | QPaintedTextureImagePrivate(); |
34 | ~QPaintedTextureImagePrivate(); |
35 | |
36 | Q_DECLARE_PUBLIC(QPaintedTextureImage) |
37 | |
38 | QSize m_imageSize; |
39 | qreal m_devicePixelRatio; |
40 | QScopedPointer<QImage> m_image; |
41 | QTextureImageDataGeneratorPtr m_currentGenerator; |
42 | |
43 | // gets increased each time the image is re-painted. |
44 | // used to distinguish between different generators |
45 | quint64 m_generation; |
46 | |
47 | void repaint(); |
48 | }; |
49 | |
50 | class QPaintedTextureImageDataGenerator : public QTextureImageDataGenerator |
51 | { |
52 | public: |
53 | QPaintedTextureImageDataGenerator(const QImage &image, int gen, Qt3DCore::QNodeId texId); |
54 | ~QPaintedTextureImageDataGenerator(); |
55 | |
56 | // Will be executed from within a QAspectJob |
57 | QTextureImageDataPtr operator ()() final; |
58 | bool operator ==(const QTextureImageDataGenerator &other) const final; |
59 | |
60 | QT3D_FUNCTOR(QPaintedTextureImageDataGenerator) |
61 | |
62 | private: |
63 | QImage m_image; |
64 | quint64 m_generation; |
65 | Qt3DCore::QNodeId m_paintedTextureImageId; |
66 | }; |
67 | |
68 | } // namespace Qt3DRender |
69 | |
70 | QT_END_NAMESPACE |
71 | |
72 | #endif // QT3DRENDER_QPAINTEDTEXTURE_P_H |
73 |