1 /**************************************************************************** 2 ** 3 ** Copyright (C) 2008-2012 NVIDIA Corporation. 4 ** Copyright (C) 2019 The Qt Company Ltd. 5 ** Contact: https://www.qt.io/licensing/ 6 ** 7 ** This file is part of Qt Quick 3D. 8 ** 9 ** $QT_BEGIN_LICENSE:GPL$ 10 ** Commercial License Usage 11 ** Licensees holding valid commercial Qt licenses may use this file in 12 ** accordance with the commercial license agreement provided with the 13 ** Software or, alternatively, in accordance with the terms contained in 14 ** a written agreement between you and The Qt Company. For licensing terms 15 ** and conditions see https://www.qt.io/terms-conditions. For further 16 ** information use the contact form at https://www.qt.io/contact-us. 17 ** 18 ** GNU General Public License Usage 19 ** Alternatively, this file may be used under the terms of the GNU 20 ** General Public License version 3 or (at your option) any later version 21 ** approved by the KDE Free Qt Foundation. The licenses are as published by 22 ** the Free Software Foundation and appearing in the file LICENSE.GPL3 23 ** included in the packaging of this file. Please review the following 24 ** information to ensure the GNU General Public License requirements will 25 ** be met: https://www.gnu.org/licenses/gpl-3.0.html. 26 ** 27 ** $QT_END_LICENSE$ 28 ** 29 ****************************************************************************/ 30 31 #ifndef QSSG_RENDER_IMAGE_H 32 #define QSSG_RENDER_IMAGE_H 33 34 // 35 // W A R N I N G 36 // ------------- 37 // 38 // This file is not part of the Qt API. It exists purely as an 39 // implementation detail. This header file may change from version to 40 // version without notice, or even be removed. 41 // 42 // We mean it. 43 // 44 45 #include <QtQuick3DRuntimeRender/private/qssgrendergraphobject_p.h> 46 #include <QtQuick3DRuntimeRender/private/qssgrendernode_p.h> 47 #include <QtQuick3DRuntimeRender/private/qssgrenderimagetexturedata_p.h> 48 #include <QtQuick3DRuntimeRender/private/qtquick3druntimerenderglobal_p.h> 49 #include <QtQuick3DRender/private/qssgrendertexture2d_p.h> 50 51 #include <QtGui/QVector2D> 52 53 QT_BEGIN_NAMESPACE 54 class QSSGRenderContextInterface; 55 class QSGTexture; 56 57 struct Q_QUICK3DRUNTIMERENDER_EXPORT QSSGRenderImage : public QSSGRenderGraphObject 58 { 59 enum class Flag 60 { 61 Dirty = 1, 62 TransformDirty = 1 << 1, 63 Active = 1 << 2, ///< Is this exact object active 64 ItemSizeDirty = 1 << 3 65 }; 66 Q_DECLARE_FLAGS(Flags, Flag) 67 68 enum class MappingModes : quint8 69 { 70 Normal = 0, // UV mapping 71 Environment = 1, 72 LightProbe = 2, 73 }; 74 75 Q_DISABLE_COPY(QSSGRenderImage) 76 // Complete path to the file; 77 //*not* relative to the presentation directory 78 QString m_imagePath; 79 QString m_imageShaderName; ///< for custom materials we don't generate the name 80 81 QSSGRenderGraphObject *m_parent = nullptr; 82 83 QSSGRenderImageTextureData m_textureData; 84 85 QSGTexture *m_qsgTexture = nullptr; // overrides source if available 86 87 Flags m_flags; // only dirty, transform dirty, and active apply 88 89 QVector2D m_scale { 1.0f, 1.0f }; 90 QVector2D m_pivot { 0.0f, 0.0f }; 91 QVector2D m_position { 0.0f, 0.0f }; 92 float m_rotation = 0.0f; // Radians. 93 bool m_flipV = false; 94 MappingModes m_mappingMode = MappingModes::Normal; 95 QSSGRenderTextureCoordOp m_horizontalTilingMode = QSSGRenderTextureCoordOp::ClampToEdge; 96 QSSGRenderTextureCoordOp m_verticalTilingMode = QSSGRenderTextureCoordOp::ClampToEdge; 97 QSSGRenderTextureFormat m_format = QSSGRenderTextureFormat::Unknown; 98 99 // Setting any of the above variables means this object is dirty. 100 // Setting any of the vec2 properties means this object's transform is dirty 101 QMatrix4x4 m_textureTransform; 102 103 QSSGRenderImage(); 104 ~QSSGRenderImage(); 105 // Renders the sub presentation 106 // Or finds the image. 107 // and sets up the texture transform 108 bool clearDirty(const QSSGRef<QSSGBufferManager> &inBufferManager, bool forIbl = false); 109 110 void calculateTextureTransform(); 111 112 bool isImageTransformIdentity() const; 113 }; 114 115 Q_DECLARE_OPERATORS_FOR_FLAGS(QSSGRenderImage::Flags) 116 117 QT_END_NAMESPACE 118 119 #endif 120