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_RENDER_TEXTUREIMAGE_H
5#define QT3DRENDER_RENDER_TEXTUREIMAGE_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/backendnode_p.h>
19#include <Qt3DRender/private/handle_types_p.h>
20#include <Qt3DRender/qabstracttexture.h>
21#include <Qt3DRender/qtextureimagedatagenerator.h>
22
23QT_BEGIN_NAMESPACE
24
25namespace Qt3DRender {
26
27namespace Render {
28
29class TextureManager;
30class TextureImageManager;
31class TextureImageDataManager;
32
33/**
34 * Backend class for QAbstractTextureImage.
35 * Will only hold the generator and some info values.
36 */
37class Q_3DRENDERSHARED_PRIVATE_EXPORT TextureImage : public BackendNode
38{
39public:
40 TextureImage();
41 ~TextureImage();
42
43 void cleanup();
44 void syncFromFrontEnd(const Qt3DCore::QNode *frontEnd, bool firstTime) override;
45
46 inline int layer() const { return m_layer; }
47 inline int mipLevel() const { return m_mipLevel; }
48 inline QAbstractTexture::CubeMapFace face() const { return m_face; }
49 inline QTextureImageDataGeneratorPtr dataGenerator() const { return m_generator; }
50 inline bool isDirty() const { return m_dirty; }
51 void unsetDirty();
52
53private:
54 bool m_dirty;
55 int m_layer;
56 int m_mipLevel;
57 QAbstractTexture::CubeMapFace m_face;
58 QTextureImageDataGeneratorPtr m_generator;
59};
60
61class TextureImageFunctor : public Qt3DCore::QBackendNodeMapper
62{
63public:
64 explicit TextureImageFunctor(AbstractRenderer *renderer,
65 TextureImageManager *textureImageManager);
66
67 Qt3DCore::QBackendNode *create(Qt3DCore::QNodeId id) const final;
68 Qt3DCore::QBackendNode *get(Qt3DCore::QNodeId id) const final;
69 void destroy(Qt3DCore::QNodeId id) const final;
70
71private:
72 AbstractRenderer *m_renderer;
73 TextureImageManager *m_textureImageManager;
74};
75
76#ifndef QT_NO_DEBUG_STREAM
77inline QDebug operator<<(QDebug dbg, const TextureImage &textureImage)
78{
79 QDebugStateSaver saver(dbg);
80 dbg << "QNodeId =" << textureImage.peerId()
81 << "mip level =" << textureImage.mipLevel()
82 << "layer =" << textureImage.layer()
83 << "cube face =" << textureImage.face()
84 << "dataGenerator =" << textureImage.dataGenerator() << Qt::endl;
85 return dbg;
86}
87#endif
88
89
90} // namespace Render
91
92} // namespace Qt3DRender
93
94QT_END_NAMESPACE
95
96#endif // QT3DRENDER_RENDER_TEXTUREIMAGE_H
97

source code of qt3d/src/render/texture/textureimage_p.h