| 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 | QSSGRenderExtension *m_extensionsSource = nullptr; |
| 61 | |
| 62 | Flags m_flags; |
| 63 | |
| 64 | QVector2D m_scale { 1.0f, 1.0f }; |
| 65 | QVector2D m_pivot { 0.0f, 0.0f }; |
| 66 | QVector2D m_position { 0.0f, 0.0f }; |
| 67 | float m_rotation = 0.0f; // degrees |
| 68 | bool m_flipU = false; |
| 69 | bool m_flipV = false; |
| 70 | int m_indexUV = 0; |
| 71 | MappingModes m_mappingMode = MappingModes::Normal; |
| 72 | QSSGRenderTextureCoordOp m_horizontalTilingMode = QSSGRenderTextureCoordOp::Repeat; |
| 73 | QSSGRenderTextureCoordOp m_verticalTilingMode = QSSGRenderTextureCoordOp::Repeat; |
| 74 | QSSGRenderTextureCoordOp m_depthTilingMode = QSSGRenderTextureCoordOp::Repeat; |
| 75 | QSSGRenderTextureFilterOp m_magFilterType = QSSGRenderTextureFilterOp::Linear; |
| 76 | QSSGRenderTextureFilterOp m_minFilterType = QSSGRenderTextureFilterOp::Linear; |
| 77 | QSSGRenderTextureFilterOp m_mipFilterType = QSSGRenderTextureFilterOp::Linear; |
| 78 | QSSGRenderTextureFormat m_format = QSSGRenderTextureFormat::Unknown; |
| 79 | bool m_generateMipmaps = false; |
| 80 | |
| 81 | // Changing any of the above variables is covered by the Dirty flag, while |
| 82 | // the texture transform is covered by TransformDirty. |
| 83 | QMatrix4x4 m_textureTransform; |
| 84 | |
| 85 | QSSGRenderImage(QSSGRenderGraphObject::Type type = QSSGRenderGraphObject::Type::Image2D); |
| 86 | ~QSSGRenderImage(); |
| 87 | |
| 88 | bool clearDirty(); |
| 89 | void calculateTextureTransform(); |
| 90 | bool isImageTransformIdentity() const; |
| 91 | }; |
| 92 | |
| 93 | Q_DECLARE_OPERATORS_FOR_FLAGS(QSSGRenderImage::Flags) |
| 94 | |
| 95 | QT_END_NAMESPACE |
| 96 | |
| 97 | #endif |
| 98 | |