diff options
author | Franck Arrecot <franck.arrecot@kdab.com> | 2016-05-02 16:37:40 +0200 |
---|---|---|
committer | Sean Harmer <sean.harmer@kdab.com> | 2016-05-03 09:48:55 +0000 |
commit | 23b668235c9b902a2577b3ac6e369b77974382b4 (patch) | |
tree | 2c401bf4be62989259059eb14f8774da43cc7ab4 | |
parent | 98ad5dc4b8a98bcd0950dd2af7949121e80c8546 (diff) |
QTexImageData to QTextureImageData
Adding unit testing to QTextureImageData
Task-number: QTBUG-51478
Change-Id: Icacdf8e5ba953eb2e637e46b16845745d06bd3ae
Reviewed-by: Sean Harmer <sean.harmer@kdab.com>
21 files changed, 226 insertions, 135 deletions
diff --git a/src/plugins/sceneparsers/assimp/assimpio.cpp b/src/plugins/sceneparsers/assimp/assimpio.cpp index cbb94e347..01e247ca0 100644 --- a/src/plugins/sceneparsers/assimp/assimpio.cpp +++ b/src/plugins/sceneparsers/assimp/assimpio.cpp @@ -318,7 +318,7 @@ private: public: explicit AssimpRawTextureImageFunctor(const QByteArray &data); - QTexImageDataPtr operator()() Q_DECL_FINAL; + QTextureImageDataPtr operator()() Q_DECL_FINAL; bool operator ==(const QTextureImageDataGenerator &other) const Q_DECL_FINAL; QT3D_FUNCTOR(AssimpRawTextureImageFunctor) @@ -948,9 +948,9 @@ AssimpRawTextureImage::AssimpRawTextureImageFunctor::AssimpRawTextureImageFuncto { } -QTexImageDataPtr AssimpRawTextureImage::AssimpRawTextureImageFunctor::operator()() +QTextureImageDataPtr AssimpRawTextureImage::AssimpRawTextureImageFunctor::operator()() { - QTexImageDataPtr dataPtr; + QTextureImageDataPtr dataPtr; dataPtr->setData(m_data, QOpenGLTexture::RGBA, QOpenGLTexture::UInt8); return dataPtr; } diff --git a/src/render/backend/handle_types_p.h b/src/render/backend/handle_types_p.h index 5a81900b7..d22ef1d90 100644 --- a/src/render/backend/handle_types_p.h +++ b/src/render/backend/handle_types_p.h @@ -60,7 +60,7 @@ class QMatrix4x4; namespace Qt3DRender { -class QTexImageData; +class QTextureImageData; namespace Render { @@ -109,7 +109,7 @@ typedef Qt3DCore::QHandle<Texture, 16> HTexture; typedef Qt3DCore::QHandle<Transform, 16> HTransform; typedef Qt3DCore::QHandle<RenderTarget, 8> HTarget; typedef Qt3DCore::QHandle<RenderPass, 16> HRenderPass; -typedef Qt3DCore::QHandle<QTexImageData, 16> HTextureData; +typedef Qt3DCore::QHandle<QTextureImageData, 16> HTextureData; typedef Qt3DCore::QHandle<Parameter, 16> HParameter; typedef Qt3DCore::QHandle<ShaderData, 16> HShaderData; typedef Qt3DCore::QHandle<TextureImage, 16> HTextureImage; diff --git a/src/render/backend/nodemanagers.cpp b/src/render/backend/nodemanagers.cpp index a09268b25..2a0ef7151 100644 --- a/src/render/backend/nodemanagers.cpp +++ b/src/render/backend/nodemanagers.cpp @@ -149,7 +149,7 @@ TextureManager *NodeManagers::manager<Texture>() const Q_DECL_NOEXCEPT } template<> -TextureDataManager *NodeManagers::manager<QTexImageData>() const Q_DECL_NOEXCEPT +TextureDataManager *NodeManagers::manager<QTextureImageData>() const Q_DECL_NOEXCEPT { return m_textureDataManager; } diff --git a/src/render/backend/nodemanagers_p.h b/src/render/backend/nodemanagers_p.h index 7c02216fc..e4e80ede3 100644 --- a/src/render/backend/nodemanagers_p.h +++ b/src/render/backend/nodemanagers_p.h @@ -61,7 +61,7 @@ class QOpenGLVertexArrayObject; namespace Qt3DRender { -class QTexImageData; +class QTextureImageData; namespace Render { @@ -265,7 +265,7 @@ template<> QT3DRENDERSHARED_PRIVATE_EXPORT TextureManager *NodeManagers::manager<Texture>() const Q_DECL_NOEXCEPT; template<> -QT3DRENDERSHARED_PRIVATE_EXPORT TextureDataManager *NodeManagers::manager<QTexImageData>() const Q_DECL_NOEXCEPT; +QT3DRENDERSHARED_PRIVATE_EXPORT TextureDataManager *NodeManagers::manager<QTextureImageData>() const Q_DECL_NOEXCEPT; template<> QT3DRENDERSHARED_PRIVATE_EXPORT LayerManager *NodeManagers::manager<Layer>() const Q_DECL_NOEXCEPT; diff --git a/src/render/jobs/loadtexturedatajob.cpp b/src/render/jobs/loadtexturedatajob.cpp index 174007c80..2d61bfded 100644 --- a/src/render/jobs/loadtexturedatajob.cpp +++ b/src/render/jobs/loadtexturedatajob.cpp @@ -42,7 +42,7 @@ #include <Qt3DRender/private/managers_p.h> #include <Qt3DRender/private/texturedatamanager_p.h> #include <Qt3DRender/private/qtextureimage_p.h> -#include <Qt3DRender/qtexturedata.h> +#include <Qt3DRender/qtextureimagedata.h> #include <QThread> #include <Qt3DRender/private/job_common_p.h> @@ -61,11 +61,11 @@ LoadTextureDataJob::~LoadTextureDataJob() { } -static QPair<HTextureData, QTexImageData *> textureDataFromGenerator(TextureDataManager *textureDataManager, - QTextureImageDataGeneratorPtr generator) +static QPair<HTextureData, QTextureImageData *> textureDataFromGenerator(TextureDataManager *textureDataManager, + QTextureImageDataGeneratorPtr generator) { HTextureData textureDataHandle; - QTexImageData *data = nullptr; + QTextureImageData *data = nullptr; QMutexLocker locker(textureDataManager->mutex()); // We don't want to take the chance of having two jobs uploading the same functor @@ -77,11 +77,11 @@ static QPair<HTextureData, QTexImageData *> textureDataFromGenerator(TextureData if (!textureDataHandle.isNull()) { data = textureDataManager->data(textureDataHandle); } else { - QTexImageDataPtr dataPtr = generator->operator ()(); + QTextureImageDataPtr dataPtr = generator->operator ()(); if (dataPtr.isNull()) { qCDebug(Jobs) << Q_FUNC_INFO << "Texture has no raw data"; } else { - // Save the QTexImageDataPtr with it's functor as a key + // Save the QTextureImageDataPtr with it's functor as a key textureDataHandle = textureDataManager->acquire(); data = textureDataManager->data(textureDataHandle); *data = *(dataPtr.data()); @@ -97,16 +97,16 @@ void LoadTextureDataJob::run() qCDebug(Jobs) << "Entering" << Q_FUNC_INFO << QThread::currentThread(); Texture *txt = m_manager->textureManager()->lookupResource(m_textureId); - TextureDataManager *textureDataManager = m_manager->manager<QTexImageData, TextureDataManager>(); + TextureDataManager *textureDataManager = m_manager->manager<QTextureImageData, TextureDataManager>(); if (txt != nullptr) { if (txt->dataGenerator()) { QTextureImageDataGeneratorPtr generator = txt->dataGenerator(); - QPair<HTextureData, QTexImageData *> handleData = textureDataFromGenerator(textureDataManager, generator); + QPair<HTextureData, QTextureImageData *> handleData = textureDataFromGenerator(textureDataManager, generator); HTextureData textureDataHandle = handleData.first; - QTexImageData *data = handleData.second; + QTextureImageData *data = handleData.second; if (!data) return; @@ -129,7 +129,7 @@ void LoadTextureDataJob::run() if (texImg != nullptr && texImg->isDirty() && !texImg->dataGenerator().isNull()) { QTextureImageDataGeneratorPtr generator = texImg->dataGenerator(); - QPair<HTextureData, QTexImageData *> handleData = textureDataFromGenerator(textureDataManager, generator); + QPair<HTextureData, QTextureImageData *> handleData = textureDataFromGenerator(textureDataManager, generator); // If using QTextureImage, notify the frontend of the change in status const QImageTextureDataFunctor *imageGenerator = functor_cast<QImageTextureDataFunctor>(generator.data()); @@ -137,12 +137,12 @@ void LoadTextureDataJob::run() texImg->setStatus(imageGenerator->status()); HTextureData textureDataHandle = handleData.first; - QTexImageData *data = handleData.second; + QTextureImageData *data = handleData.second; // XXX released textureDataManager mutex, do we have a race here? // Update HTextureImage Functor to release TextureData when needed - TextureDataManager *textureDataManager = m_manager->manager<QTexImageData, TextureDataManager>(); + TextureDataManager *textureDataManager = m_manager->manager<QTextureImageData, TextureDataManager>(); textureDataManager->assignFunctorToTextureImage(generator, texImgHandle); // Set texture size of texture if the first layer / level / face has a valid size diff --git a/src/render/texture/qabstracttexture.h b/src/render/texture/qabstracttexture.h index 5a76a2267..1bc3559c6 100644 --- a/src/render/texture/qabstracttexture.h +++ b/src/render/texture/qabstracttexture.h @@ -40,7 +40,7 @@ #ifndef QT3DRENDER_QABSTRACTTEXTURE_H #define QT3DRENDER_QABSTRACTTEXTURE_H -#include <Qt3DRender/qtexturedata.h> +#include <Qt3DRender/qtextureimagedata.h> #include <Qt3DRender/qt3drender_global.h> #include <Qt3DCore/qnode.h> diff --git a/src/render/texture/qabstracttexture_p.h b/src/render/texture/qabstracttexture_p.h index 81fdd133d..3bc895e57 100644 --- a/src/render/texture/qabstracttexture_p.h +++ b/src/render/texture/qabstracttexture_p.h @@ -72,7 +72,7 @@ public : int m_width, m_height, m_depth; bool m_autoMipMap; - QVector<QTexImageDataPtr> m_data; + QVector<QTextureImageDataPtr> m_data; QAbstractTexture::Filter m_minFilter, m_magFilter; // FIXME, store per direction diff --git a/src/render/texture/qabstracttextureimage.h b/src/render/texture/qabstracttextureimage.h index d80fa95d9..6b003661f 100644 --- a/src/render/texture/qabstracttextureimage.h +++ b/src/render/texture/qabstracttextureimage.h @@ -59,7 +59,7 @@ class QT3DRENDERSHARED_EXPORT QTextureImageDataGenerator : public QAbstractFunct { public: virtual ~QTextureImageDataGenerator() {} - virtual QTexImageDataPtr operator()() = 0; + virtual QTextureImageDataPtr operator()() = 0; virtual bool operator ==(const QTextureImageDataGenerator &other) const = 0; }; diff --git a/src/render/texture/qtexture.h b/src/render/texture/qtexture.h index db74761e5..4d687dc6d 100644 --- a/src/render/texture/qtexture.h +++ b/src/render/texture/qtexture.h @@ -40,7 +40,7 @@ #ifndef QT3DRENDER_QTEXTURE_H #define QT3DRENDER_QTEXTURE_H -#include <Qt3DRender/qtexturedata.h> +#include <Qt3DRender/qtextureimagedata.h> #include <Qt3DRender/qtexturewrapmode.h> #include <Qt3DRender/qtextureimage.h> #include <Qt3DRender/qabstracttexture.h> diff --git a/src/render/texture/qtextureimage_p.h b/src/render/texture/qtextureimage_p.h index e61747a52..3dd7e152f 100644 --- a/src/render/texture/qtextureimage_p.h +++ b/src/render/texture/qtextureimage_p.h @@ -83,12 +83,12 @@ public: {} // Will be executed from within a QAspectJob - QTexImageDataPtr operator ()() Q_DECL_FINAL + QTextureImageDataPtr operator ()() Q_DECL_FINAL { - QTexImageDataPtr dataPtr; + QTextureImageDataPtr dataPtr; if (m_url.isLocalFile() || m_url.scheme() == QStringLiteral("qrc")) { QString source = Qt3DRender::QUrlHelper::urlToLocalFileOrQrc(m_url); - dataPtr.reset(new QTexImageData()); + dataPtr.reset(new QTextureImageData()); if (dataPtr->setCompressedFile(source)) return dataPtr; QImage img; diff --git a/src/render/texture/qtexturedata.cpp b/src/render/texture/qtextureimagedata.cpp index 7cf97b433..bbf37232b 100644 --- a/src/render/texture/qtexturedata.cpp +++ b/src/render/texture/qtextureimagedata.cpp @@ -37,7 +37,7 @@ ** ****************************************************************************/ -#include "qtexturedata_p.h" +#include "qtextureimagedata_p.h" #include <QFileInfo> #include <QFile> #include <qendian.h> @@ -404,7 +404,7 @@ const struct DX10Format { } // namespace -QTexImageDataPrivate::QTexImageDataPrivate() +QTextureImageDataPrivate::QTextureImageDataPrivate() : m_width(-1) , m_height(-1) , m_depth(-1) @@ -420,7 +420,7 @@ QTexImageDataPrivate::QTexImageDataPrivate() { } -QByteArray QTexImageDataPrivate::data(int layer, int face, int mipmapLevel) const +QByteArray QTextureImageDataPrivate::data(int layer, int face, int mipmapLevel) const { if (layer < 0 || layer >= m_layers || face < 0 || face >= m_faces || @@ -435,7 +435,7 @@ QByteArray QTexImageDataPrivate::data(int layer, int face, int mipmapLevel) cons return QByteArray::fromRawData(m_data.constData() + offset, mipmapLevelSize(mipmapLevel)); } -void QTexImageDataPrivate::setData(const QByteArray &data, QOpenGLTexture::PixelFormat fmt, +void QTextureImageDataPrivate::setData(const QByteArray &data, QOpenGLTexture::PixelFormat fmt, QOpenGLTexture::PixelType ptype) { m_isCompressed = false; @@ -448,7 +448,7 @@ void QTexImageDataPrivate::setData(const QByteArray &data, QOpenGLTexture::Pixel m_pixelType = ptype; } -bool QTexImageDataPrivate::setCompressedFile(const QString &source) +bool QTextureImageDataPrivate::setCompressedFile(const QString &source) { QString suffix = QFileInfo(source).suffix(); @@ -460,7 +460,7 @@ bool QTexImageDataPrivate::setCompressedFile(const QString &source) return false; } -bool QTexImageDataPrivate::setPkmFile(const QString &source) +bool QTextureImageDataPrivate::setPkmFile(const QString &source) { QFile f(source); if (!f.open(QIODevice::ReadOnly)) { @@ -500,7 +500,7 @@ static int bitCount(quint32 n) return r; } -bool QTexImageDataPrivate::setDdsFile(const QString &source) +bool QTextureImageDataPrivate::setDdsFile(const QString &source) { QFile f(source); if (!f.open(QIODevice::ReadOnly)) { @@ -630,12 +630,12 @@ bool QTexImageDataPrivate::setDdsFile(const QString &source) return true; } -int QTexImageDataPrivate::layerSize() const +int QTextureImageDataPrivate::layerSize() const { return m_faces*faceSize(); } -int QTexImageDataPrivate::faceSize() const +int QTextureImageDataPrivate::faceSize() const { int size = 0; @@ -646,7 +646,7 @@ int QTexImageDataPrivate::faceSize() const } // XXX check if this works for ETC1 compression -int QTexImageDataPrivate::mipmapLevelSize(int level) const +int QTextureImageDataPrivate::mipmapLevelSize(int level) const { int w = qMax(m_width >> level, 1); int h = qMax(m_height >> level, 1); @@ -658,32 +658,32 @@ int QTexImageDataPrivate::mipmapLevelSize(int level) const return w * h * m_blockSize * d; } -QTexImageData::QTexImageData() - : d_ptr(new QTexImageDataPrivate()) +QTextureImageData::QTextureImageData() Q_DECL_NOEXCEPT + : d_ptr(new QTextureImageDataPrivate()) { } -QTexImageData::QTexImageData(QTexImageDataPrivate &dd) +QTextureImageData::QTextureImageData(QTextureImageDataPrivate &dd) Q_DECL_NOEXCEPT : d_ptr(&dd) { } -QTexImageData::~QTexImageData() +QTextureImageData::~QTextureImageData() Q_DECL_NOEXCEPT { cleanup(); delete d_ptr; } -QTexImageData &QTexImageData::operator=(const QTexImageData &other) +QTextureImageData &QTextureImageData::operator=(const QTextureImageData &other) Q_DECL_NOEXCEPT { - Q_D(QTexImageData); + Q_D(QTextureImageData); *d = *other.d_ptr; return *this; } -void QTexImageData::cleanup() +void QTextureImageData::cleanup() Q_DECL_NOEXCEPT { - Q_D(QTexImageData); + Q_D(QTextureImageData); d->m_width = -1; d->m_height = -1; d->m_depth = -1; @@ -695,104 +695,104 @@ void QTexImageData::cleanup() d->m_data.clear(); } -bool QTexImageData::isCompressed() const +bool QTextureImageData::isCompressed() const Q_DECL_NOEXCEPT { - Q_D(const QTexImageData); + Q_D(const QTextureImageData); return d->m_isCompressed; } -int QTexImageData::width() const +int QTextureImageData::width() const Q_DECL_NOEXCEPT { - Q_D(const QTexImageData); + Q_D(const QTextureImageData); return d->m_width; } -int QTexImageData::height() const +int QTextureImageData::height() const Q_DECL_NOEXCEPT { - Q_D(const QTexImageData); + Q_D(const QTextureImageData); return d->m_height; } -int QTexImageData::depth() const +int QTextureImageData::depth() const Q_DECL_NOEXCEPT { - Q_D(const QTexImageData); + Q_D(const QTextureImageData); return d->m_depth; } -int QTexImageData::layers() const +int QTextureImageData::layers() const Q_DECL_NOEXCEPT { - Q_D(const QTexImageData); + Q_D(const QTextureImageData); return d->m_layers; } -int QTexImageData::mipLevels() const +int QTextureImageData::mipLevels() const Q_DECL_NOEXCEPT { - Q_D(const QTexImageData); + Q_D(const QTextureImageData); return d->m_mipLevels; } -int QTexImageData::faces() const +int QTextureImageData::faces() const Q_DECL_NOEXCEPT { - Q_D(const QTexImageData); + Q_D(const QTextureImageData); return d->m_faces;; } -QOpenGLTexture::Target QTexImageData::target() const +QOpenGLTexture::Target QTextureImageData::target() const Q_DECL_NOEXCEPT { - Q_D(const QTexImageData); + Q_D(const QTextureImageData); return d->m_target; } -QOpenGLTexture::TextureFormat QTexImageData::format() const +QOpenGLTexture::TextureFormat QTextureImageData::format() const Q_DECL_NOEXCEPT { - Q_D(const QTexImageData); + Q_D(const QTextureImageData); return d->m_format; } -void QTexImageData::setImage(const QImage &image) +void QTextureImageData::setImage(const QImage &image) Q_DECL_NOEXCEPT { - Q_D(QTexImageData); + Q_D(QTextureImageData); d->m_width = image.width(); d->m_height = image.height(); d->m_depth = 1; QImage glImage = image.convertToFormat(QImage::Format_RGBA8888); Q_ASSERT_X(glImage.bytesPerLine() == (glImage.width() * glImage.depth() + 7) / 8, - "QTexImageData::setImage", "glImage is not packed"); // QTBUG-48330 + "QTextureImageData::setImage", "glImage is not packed"); // QTBUG-48330 QByteArray imageBytes((const char*) glImage.constBits(), glImage.byteCount()); setData(imageBytes, QOpenGLTexture::RGBA, QOpenGLTexture::UInt8); d->m_format = QOpenGLTexture::RGBA8_UNorm; d->m_blockSize = 4; } -void QTexImageData::setData(const QByteArray &data, QOpenGLTexture::PixelFormat fmt, - QOpenGLTexture::PixelType ptype) +void QTextureImageData::setData(const QByteArray &data, QOpenGLTexture::PixelFormat fmt, + QOpenGLTexture::PixelType ptype) Q_DECL_NOEXCEPT { - Q_D(QTexImageData); + Q_D(QTextureImageData); d->setData(data, fmt, ptype); } -bool QTexImageData::setCompressedFile(const QString &source) +bool QTextureImageData::setCompressedFile(const QString &source) Q_DECL_NOEXCEPT { - Q_D(QTexImageData); + Q_D(QTextureImageData); return d->setCompressedFile(source); } -QByteArray QTexImageData::data(int layer, int face, int mipmapLevel) const +QByteArray QTextureImageData::data(int layer, int face, int mipmapLevel) const Q_DECL_NOEXCEPT { - Q_D(const QTexImageData); + Q_D(const QTextureImageData); return d->data(layer, face, mipmapLevel); } -QOpenGLTexture::PixelFormat QTexImageData::pixelFormat() const +QOpenGLTexture::PixelFormat QTextureImageData::pixelFormat() const Q_DECL_NOEXCEPT { - Q_D(const QTexImageData); + Q_D(const QTextureImageData); return d->m_pixelFormat; } -QOpenGLTexture::PixelType QTexImageData::pixelType() const +QOpenGLTexture::PixelType QTextureImageData::pixelType() const Q_DECL_NOEXCEPT { - Q_D(const QTexImageData); + Q_D(const QTextureImageData); return d->m_pixelType; } diff --git a/src/render/texture/qtexturedata.h b/src/render/texture/qtextureimagedata.h index 7907b1827..7796e4205 100644 --- a/src/render/texture/qtexturedata.h +++ b/src/render/texture/qtextureimagedata.h @@ -37,8 +37,8 @@ ** ****************************************************************************/ -#ifndef QT3DRENDER_TEXTUREDATA_H -#define QT3DRENDER_TEXTUREDATA_H +#ifndef QT3DRENDER_TEXTUREIMAGEDATA_H +#define QT3DRENDER_TEXTUREIMAGEDATA_H #include <QtGui/QOpenGLTexture> #include <QtGui/QImage> @@ -49,68 +49,59 @@ QT_BEGIN_NAMESPACE namespace Qt3DRender { -class QTexImageDataPrivate; +class QTextureImageDataPrivate; -class QT3DRENDERSHARED_EXPORT QTexImageData +class QT3DRENDERSHARED_EXPORT QTextureImageData { public: - QTexImageData(); - virtual ~QTexImageData(); + QTextureImageData() Q_DECL_NOEXCEPT; + ~QTextureImageData() Q_DECL_NOEXCEPT; - QTexImageData &operator=(const QTexImageData &other); + QTextureImageData &operator=(const QTextureImageData &other) Q_DECL_NOEXCEPT; - void cleanup(); + void cleanup() Q_DECL_NOEXCEPT; - bool isCompressed() const; + bool isCompressed() const Q_DECL_NOEXCEPT; - int width() const; - int height() const; - int depth() const; + int width() const Q_DECL_NOEXCEPT; + int height() const Q_DECL_NOEXCEPT; + int depth() const Q_DECL_NOEXCEPT; - int layers() const; - int mipLevels() const; - int faces() const; + int layers() const Q_DECL_NOEXCEPT; + int mipLevels() const Q_DECL_NOEXCEPT; + int faces() const Q_DECL_NOEXCEPT; - QOpenGLTexture::Target target() const; + QOpenGLTexture::Target target() const Q_DECL_NOEXCEPT; - QOpenGLTexture::TextureFormat format() const; + QOpenGLTexture::TextureFormat format() const Q_DECL_NOEXCEPT; - void setImage(const QImage &); + void setImage(const QImage &) Q_DECL_NOEXCEPT; void setData(const QByteArray &data, QOpenGLTexture::PixelFormat fmt, - QOpenGLTexture::PixelType ptype); + QOpenGLTexture::PixelType ptype) Q_DECL_NOEXCEPT; - bool setCompressedFile(const QString &source); + bool setCompressedFile(const QString &source) Q_DECL_NOEXCEPT; - QByteArray data(int layer = 0, int face = 0, int mipmapLevel = 0) const; + QByteArray data(int layer = 0, int face = 0, int mipmapLevel = 0) const Q_DECL_NOEXCEPT; - QOpenGLTexture::PixelFormat pixelFormat() const; + QOpenGLTexture::PixelFormat pixelFormat() const Q_DECL_NOEXCEPT; - QOpenGLTexture::PixelType pixelType() const; + QOpenGLTexture::PixelType pixelType() const Q_DECL_NOEXCEPT; protected: - QTexImageData(QTexImageDataPrivate &dd); + QTextureImageData(QTextureImageDataPrivate &dd) Q_DECL_NOEXCEPT; private: - Q_DECLARE_PRIVATE(QTexImageData) - QTexImageDataPrivate *d_ptr; - -// int m_width, m_height, m_depth; -// QOpenGLTexture::PixelFormat m_pixelFormat; -// QOpenGLTexture::PixelType m_pixelType; - -// bool m_isCompressed; -// QByteArray m_data; -// QOpenGLTexture::TextureFormat m_format; - + Q_DECLARE_PRIVATE(QTextureImageData) + QTextureImageDataPrivate *d_ptr; }; -typedef QSharedPointer<QTexImageData> QTexImageDataPtr; +typedef QSharedPointer<QTextureImageData> QTextureImageDataPtr; } // namespace Qt3DRender QT_END_NAMESPACE -#endif // QT3DRENDER_TEXTUREDATA_H +#endif // QT3DRENDER_TEXTUREIMAGEDATA_H diff --git a/src/render/texture/qtexturedata_p.h b/src/render/texture/qtextureimagedata_p.h index 0b4271442..6d46ae1b7 100644 --- a/src/render/texture/qtexturedata_p.h +++ b/src/render/texture/qtextureimagedata_p.h @@ -51,16 +51,16 @@ // We mean it. // -#include "qtexturedata.h" +#include "qtextureimagedata.h" QT_BEGIN_NAMESPACE namespace Qt3DRender { -class QTexImageDataPrivate +class QTextureImageDataPrivate { public: - QTexImageDataPrivate(); + QTextureImageDataPrivate(); void setData(const QByteArray &data, QOpenGLTexture::PixelFormat fmt, QOpenGLTexture::PixelType ptype); diff --git a/src/render/texture/texture.cpp b/src/render/texture/texture.cpp index 2b61d11ef..af1e2db7c 100644 --- a/src/render/texture/texture.cpp +++ b/src/render/texture/texture.cpp @@ -45,7 +45,7 @@ #include <QOpenGLTexture> #include <QOpenGLPixelTransferOptions> #include <Qt3DRender/qtexture.h> -#include <Qt3DRender/qtexturedata.h> +#include <Qt3DRender/qtextureimagedata.h> #include <Qt3DRender/private/managers_p.h> #include <Qt3DRender/private/texturedatamanager_p.h> #include <Qt3DRender/private/qabstracttexture_p.h> @@ -354,7 +354,7 @@ QOpenGLTexture *Texture::buildGLTexture() } // RenderThread -void Texture::setToGLTexture(QTexImageData *imgData) +void Texture::setToGLTexture(QTextureImageData *imgData) { Q_ASSERT(m_gl && m_gl->isCreated() && m_gl->isStorageAllocated()); @@ -402,7 +402,7 @@ void Texture::setToGLTexture(QTexImageData *imgData) } // RenderThread -void Texture::setToGLTexture(TextureImage *rImg, QTexImageData *imgData) +void Texture::setToGLTexture(TextureImage *rImg, QTextureImageData *imgData) { Q_ASSERT(m_gl && m_gl->isCreated() && m_gl->isStorageAllocated()); // ensure we don't accidently cause a detach / copy of the raw bytes @@ -664,7 +664,7 @@ void Texture::setTextureDataManager(TextureDataManager *manager) void Texture::updateAndLoadTextureImage() { if (!m_textureDataHandle.isNull()) { - QTexImageData *data = m_textureDataManager->data(m_textureDataHandle); + QTextureImageData *data = m_textureDataManager->data(m_textureDataHandle); if (data != nullptr) setToGLTexture(data); } @@ -677,7 +677,7 @@ void Texture::updateAndLoadTextureImage() img->unsetDirty(); continue; } - QTexImageData *data = m_textureDataManager->data(img->textureDataHandle()); + QTextureImageData *data = m_textureDataManager->data(img->textureDataHandle()); if (data != nullptr) { setToGLTexture(img, data); dnas.append(img->dna()); diff --git a/src/render/texture/texture.pri b/src/render/texture/texture.pri index b4eff5892..92545ddd3 100644 --- a/src/render/texture/texture.pri +++ b/src/render/texture/texture.pri @@ -9,10 +9,10 @@ HEADERS += \ $$PWD/texture_p.h \ $$PWD/texturedatamanager_p.h \ $$PWD/textureimage_p.h \ - $$PWD/qtexturedata_p.h \ - $$PWD/qtexturedata.h \ $$PWD/qabstracttexture.h \ - $$PWD/qabstracttexture_p.h + $$PWD/qabstracttexture_p.h \ + $$PWD/qtextureimagedata_p.h \ + $$PWD/qtextureimagedata.h SOURCES += \ $$PWD/qabstracttextureimage.cpp \ @@ -21,6 +21,6 @@ SOURCES += \ $$PWD/texture.cpp \ $$PWD/texturedatamanager.cpp \ $$PWD/textureimage.cpp \ - $$PWD/qtexturedata.cpp \ $$PWD/qabstracttexture.cpp \ - $$PWD/qtexture.cpp + $$PWD/qtexture.cpp \ + $$PWD/qtextureimagedata.cpp diff --git a/src/render/texture/texture_p.h b/src/render/texture/texture_p.h index 3bd7d2a0f..7ca6e3a08 100644 --- a/src/render/texture/texture_p.h +++ b/src/render/texture/texture_p.h @@ -54,7 +54,7 @@ #include <Qt3DRender/private/backendnode_p.h> #include <Qt3DRender/private/handle_types_p.h> #include <Qt3DRender/qtexture.h> -#include <Qt3DRender/qtexturedata.h> +#include <Qt3DRender/qtextureimagedata.h> #include <QOpenGLContext> #include <QMutex> @@ -124,8 +124,8 @@ private: QOpenGLTexture *m_gl; QOpenGLTexture *buildGLTexture(); - void setToGLTexture(QTexImageData *imgData); - void setToGLTexture(TextureImage *rImg, QTexImageData *imgData); + void setToGLTexture(QTextureImageData *imgData); + void setToGLTexture(TextureImage *rImg, QTextureImageData *imgData); void updateWrapAndFilters(); int m_width; diff --git a/src/render/texture/texturedatamanager_p.h b/src/render/texture/texturedatamanager_p.h index 27e294108..ebff9dc3a 100644 --- a/src/render/texture/texturedatamanager_p.h +++ b/src/render/texture/texturedatamanager_p.h @@ -53,7 +53,7 @@ #include <Qt3DCore/private/qresourcemanager_p.h> #include <Qt3DRender/qtexture.h> -#include <Qt3DRender/qtexturedata.h> +#include <Qt3DRender/qtextureimagedata.h> #include <Qt3DRender/private/handle_types_p.h> #include <QPair> @@ -68,7 +68,7 @@ namespace Render { typedef QPair<QTextureImageDataGeneratorPtr, QVector<HTextureImage> > FunctorImageHandlesPair; typedef QPair<QTextureImageDataGeneratorPtr, HTextureData> FunctorTextureDataPair; -class TextureDataManager : public Qt3DCore::QResourceManager<QTexImageData, +class TextureDataManager : public Qt3DCore::QResourceManager<QTextureImageData, Qt3DCore::QNodeId, 16, Qt3DCore::ArrayAllocatingPolicy, @@ -100,7 +100,7 @@ private: } // namespace Render } // namespace Qt3DRender -Q_DECLARE_RESOURCE_INFO(Qt3DRender::QTexImageData, Q_REQUIRES_CLEANUP) +Q_DECLARE_RESOURCE_INFO(Qt3DRender::QTextureImageData, Q_REQUIRES_CLEANUP) QT_END_NAMESPACE diff --git a/tests/auto/render/ddstextures/tst_ddstextures.cpp b/tests/auto/render/ddstextures/tst_ddstextures.cpp index f58f3072f..568c5e5d8 100644 --- a/tests/auto/render/ddstextures/tst_ddstextures.cpp +++ b/tests/auto/render/ddstextures/tst_ddstextures.cpp @@ -27,7 +27,7 @@ ****************************************************************************/ #include <QtTest/QTest> -#include <Qt3DRender/qtexturedata.h> +#include <Qt3DRender/qtextureimagedata.h> class tst_DdsTextures : public QObject { @@ -77,7 +77,7 @@ void tst_DdsTextures::ddsImageData() for (unsigned i = 0; i < sizeof(textures)/sizeof(*textures); i++) { const TextureInfo *texture = &textures[i]; - Qt3DRender::QTexImageData data; + Qt3DRender::QTextureImageData data; QVERIFY(data.setCompressedFile(QFINDTESTDATA(texture->source))); QCOMPARE(data.width(), texture->width); diff --git a/tests/auto/render/qtextureimagedata/qtextureimagedata.pro b/tests/auto/render/qtextureimagedata/qtextureimagedata.pro new file mode 100644 index 000000000..cfa1bdb51 --- /dev/null +++ b/tests/auto/render/qtextureimagedata/qtextureimagedata.pro @@ -0,0 +1,10 @@ +TEMPLATE = app + +TARGET = tst_qtextureimagedata +QT += core-private 3dcore 3dcore-private 3drender 3drender-private testlib + +CONFIG += testcase + +SOURCES += tst_qtextureimagedata.cpp + +include(../commons/commons.pri) diff --git a/tests/auto/render/qtextureimagedata/tst_qtextureimagedata.cpp b/tests/auto/render/qtextureimagedata/tst_qtextureimagedata.cpp new file mode 100644 index 000000000..dd931dabf --- /dev/null +++ b/tests/auto/render/qtextureimagedata/tst_qtextureimagedata.cpp @@ -0,0 +1,89 @@ +/**************************************************************************** +** +** Copyright (C) 2016 Klaralvdalens Datakonsult AB (KDAB). +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the Qt3D module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:GPL-EXCEPT$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3 as published by the Free Software +** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include <QtTest/QTest> + +#include <Qt3DRender/private/qtextureimagedata_p.h> +#include <Qt3DRender/qtextureimagedata.h> + +#include "testpostmanarbiter.h" + +// We need to call QNode::clone which is protected +// So we sublcass QNode instead of QObject +class tst_QTextureImageData : public QObject +{ + Q_OBJECT +public: + ~tst_QTextureImageData() + { + } + +private Q_SLOTS: + + void checkSaneDefaults() + { + Qt3DRender::QTextureImageData *tid = new Qt3DRender::QTextureImageData(); + + QCOMPARE(tid->width(), -1); + QCOMPARE(tid->height(), -1); + QCOMPARE(tid->depth(), -1); + QCOMPARE(tid->layers(), -1); + QCOMPARE(tid->mipLevels(), -1); + QCOMPARE(tid->target(), QOpenGLTexture::Target2D); + QCOMPARE(tid->format(), QOpenGLTexture::RGBA8_UNorm); + QCOMPARE(tid->pixelFormat(), QOpenGLTexture::RGBA); + QCOMPARE(tid->pixelType(), QOpenGLTexture::UInt8); + QCOMPARE(tid->isCompressed(), false); + } + + void checkCloning_data() + { + + } + + void checkCloning() + { + } + + void checkPropertyUpdates() + { + } +/* +protected: + + Qt3DCore::QNode *doClone() const Q_DECL_OVERRIDE + { + return Q_NULLPTR; + } + */ + +}; + +QTEST_MAIN(tst_QTextureImageData) + +#include "tst_qtextureimagedata.moc" diff --git a/tests/auto/render/render.pro b/tests/auto/render/render.pro index a429c77f0..8eca6452e 100644 --- a/tests/auto/render/render.pro +++ b/tests/auto/render/render.pro @@ -33,6 +33,7 @@ contains(QT_CONFIG, private_tests) { qsortpolicy \ qrenderstateset \ qtechniquefilter \ + qtextureimagedata \ qviewport \ framegraphnode \ qobjectpicker \ |