1// Copyright (C) 2019 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#include "qtexturedataupdate.h"
5#include "qtexturedataupdate_p.h"
6#include <iostream>
7
8QT_BEGIN_NAMESPACE
9
10namespace Qt3DRender
11{
12
13static bool operator==(const QTextureDataUpdatePrivate &lhs, const QTextureDataUpdatePrivate &rhs) noexcept
14{
15 return lhs.m_x == rhs.m_x &&
16 lhs.m_y == rhs.m_y &&
17 lhs.m_z == rhs.m_z &&
18 lhs.m_layer == rhs.m_layer &&
19 lhs.m_mipLevel == rhs.m_mipLevel &&
20 lhs.m_face == rhs.m_face &&
21 lhs.m_data == rhs.m_data;
22}
23
24/*!
25 \class Qt3DRender::QTextureDataUpdate
26 \inmodule Qt3DRender
27 \brief QTextureDataUpdate holds content and information required to perform
28 partial updates of a texture content.
29
30 The actual data content is contained in a QTextureImageDataPtr member.
31 Additional members allow to specify the x, y, z offset of the content update
32 as well as the eventual layer, mipLevel and face.
33
34 \sa QAbstractTexture
35 \since 5.14
36 */
37
38QTextureDataUpdate::QTextureDataUpdate()
39 : d_ptr(new QTextureDataUpdatePrivate())
40{
41}
42
43QTextureDataUpdate::QTextureDataUpdate(const QTextureDataUpdate &other)
44 = default;
45
46QTextureDataUpdate &QTextureDataUpdate::operator=(const QTextureDataUpdate &other)
47 = default;
48
49QTextureDataUpdate::~QTextureDataUpdate()
50 = default;
51
52bool operator==(const QTextureDataUpdate &lhs, const QTextureDataUpdate &rhs) noexcept
53{
54 return *lhs.d_func() == *rhs.d_func();
55}
56
57int QTextureDataUpdate::x() const
58{
59 Q_D(const QTextureDataUpdate);
60 return d->m_x;
61}
62
63int QTextureDataUpdate::y() const
64{
65 Q_D(const QTextureDataUpdate);
66 return d->m_y;
67}
68
69int QTextureDataUpdate::z() const
70{
71 Q_D(const QTextureDataUpdate);
72 return d->m_z;
73}
74
75int QTextureDataUpdate::layer() const
76{
77 Q_D(const QTextureDataUpdate);
78 return d->m_layer;
79}
80
81int QTextureDataUpdate::mipLevel() const
82{
83 Q_D(const QTextureDataUpdate);
84 return d->m_mipLevel;
85}
86
87QAbstractTexture::CubeMapFace QTextureDataUpdate::face() const
88{
89 Q_D(const QTextureDataUpdate);
90 return d->m_face;
91}
92
93QTextureImageDataPtr QTextureDataUpdate::data() const
94{
95 Q_D(const QTextureDataUpdate);
96 return d->m_data;
97}
98
99void QTextureDataUpdate::setX(int x)
100{
101 d_ptr.detach();
102 Q_D(QTextureDataUpdate);
103 d->m_x = x;
104}
105
106void QTextureDataUpdate::setY(int y)
107{
108 d_ptr.detach();
109 Q_D(QTextureDataUpdate);
110 d->m_y = y;
111}
112
113void QTextureDataUpdate::setZ(int z)
114{
115 d_ptr.detach();
116 Q_D(QTextureDataUpdate);
117 d->m_z = z;
118}
119
120void QTextureDataUpdate::setLayer(int layer)
121{
122 d_ptr.detach();
123 Q_D(QTextureDataUpdate);
124 d->m_layer = layer;
125}
126
127void QTextureDataUpdate::setMipLevel(int mipLevel)
128{
129 d_ptr.detach();
130 Q_D(QTextureDataUpdate);
131 d->m_mipLevel = mipLevel;
132}
133
134void QTextureDataUpdate::setFace(QAbstractTexture::CubeMapFace face)
135{
136 d_ptr.detach();
137 Q_D(QTextureDataUpdate);
138 d->m_face = face;
139}
140
141void QTextureDataUpdate::setData(const QTextureImageDataPtr &data)
142{
143 d_ptr.detach();
144 Q_D(QTextureDataUpdate);
145 d->m_data = data;
146}
147
148} // Qt3DRender
149
150QT_END_NAMESPACE
151

source code of qt3d/src/render/texture/qtexturedataupdate.cpp