1 | // Copyright (C) 2008-2012 NVIDIA Corporation. |
2 | // Copyright (C) 2019 The Qt Company Ltd. |
3 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only |
4 | |
5 | #ifndef QSSG_RENDER_IMAGE_H |
6 | #define QSSG_RENDER_IMAGE_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 <QtQuick3DRuntimeRender/private/qssgrendergraphobject_p.h> |
20 | #include <QtQuick3DRuntimeRender/private/qssgrenderimagetexture_p.h> |
21 | #include <QtQuick3DRuntimeRender/private/qssgrenderbuffermanager_p.h> |
22 | #include <QtQuick3DRuntimeRender/private/qtquick3druntimerenderglobal_p.h> |
23 | #include <QtQuick3DRuntimeRender/private/qssgrendererutil_p.h> |
24 | #include <QtQuick3DUtils/private/qssgrenderbasetypes_p.h> |
25 | |
26 | #include <QtGui/QVector2D> |
27 | |
28 | QT_BEGIN_NAMESPACE |
29 | class QSSGRenderContextInterface; |
30 | class QSGTexture; |
31 | class QSSGRenderTextureData; |
32 | |
33 | struct Q_QUICK3DRUNTIMERENDER_EXPORT QSSGRenderImage : public QSSGRenderGraphObject |
34 | { |
35 | enum class Flag |
36 | { |
37 | Dirty = 1 << 0, |
38 | TransformDirty = 1 << 1, |
39 | }; |
40 | Q_DECLARE_FLAGS(Flags, Flag) |
41 | |
42 | enum class MappingModes : quint8 |
43 | { |
44 | Normal = 0, // UV mapping |
45 | Environment = 1, |
46 | LightProbe = 2, |
47 | }; |
48 | |
49 | Q_DISABLE_COPY(QSSGRenderImage) |
50 | |
51 | QSSGRenderGraphObject *m_parent = nullptr; |
52 | |
53 | QSSGRenderPath m_imagePath; |
54 | // The QSGTexture (from sourceItem) is not sharable between Qt Quick render |
55 | // threads, when the threaded render loop is in use. That's why we allow |
56 | // this exception here; the (per-QQuickWindow, and so per-render-thread) |
57 | // BufferManager will refuse to use this if the threads don't match. |
58 | QSGTexture *m_qsgTexture = nullptr; // overrides m_imagePath and m_rawTextureData when non-null |
59 | QSSGRenderTextureData *m_rawTextureData = nullptr; // overrides m_imagePath and m_qsgTexture when non-null |
60 | |
61 | Flags m_flags; |
62 | |
63 | QVector2D m_scale { 1.0f, 1.0f }; |
64 | QVector2D m_pivot { 0.0f, 0.0f }; |
65 | QVector2D m_position { 0.0f, 0.0f }; |
66 | float m_rotation = 0.0f; // degrees |
67 | bool m_flipU = false; |
68 | bool m_flipV = false; |
69 | int m_indexUV = 0; |
70 | MappingModes m_mappingMode = MappingModes::Normal; |
71 | QSSGRenderTextureCoordOp m_horizontalTilingMode = QSSGRenderTextureCoordOp::Repeat; |
72 | QSSGRenderTextureCoordOp m_verticalTilingMode = QSSGRenderTextureCoordOp::Repeat; |
73 | QSSGRenderTextureFilterOp m_magFilterType = QSSGRenderTextureFilterOp::Linear; |
74 | QSSGRenderTextureFilterOp m_minFilterType = QSSGRenderTextureFilterOp::Linear; |
75 | QSSGRenderTextureFilterOp m_mipFilterType = QSSGRenderTextureFilterOp::Linear; |
76 | QSSGRenderTextureFormat m_format = QSSGRenderTextureFormat::Unknown; |
77 | bool m_generateMipmaps = false; |
78 | |
79 | // Changing any of the above variables is covered by the Dirty flag, while |
80 | // the texture transform is covered by TransformDirty. |
81 | QMatrix4x4 m_textureTransform; |
82 | |
83 | QSSGRenderImage(QSSGRenderGraphObject::Type type = QSSGRenderGraphObject::Type::Image2D); |
84 | ~QSSGRenderImage(); |
85 | |
86 | bool clearDirty(); |
87 | void calculateTextureTransform(); |
88 | bool isImageTransformIdentity() const; |
89 | }; |
90 | |
91 | Q_DECLARE_OPERATORS_FOR_FLAGS(QSSGRenderImage::Flags) |
92 | |
93 | QT_END_NAMESPACE |
94 | |
95 | #endif |
96 | |