diff options
author | Michael Brasser <michael.brasser@live.com> | 2017-04-18 09:07:07 -0500 |
---|---|---|
committer | Laszlo Agocs <laszlo.agocs@qt.io> | 2017-08-07 13:56:05 +0000 |
commit | 432e27ae092397cb2154f48103e729852c38cf2d (patch) | |
tree | 12c9b108a6e85082d029da994af0f9c7e5ca8d4f /src/quick/scenegraph/util | |
parent | 5a6887ae8536c0b751e7b870ab629ecbf8784d22 (diff) |
Add very basic compressed texture support
Allow direct loading of pkm texture files into Image. This can
be extended to additional texture types, and then eventually
turned into a full plugin architexture.
[ChangeLog][Qt Quick] Allow direct loading of pkm texture files
into Image. For example: Image { source: "myImage.pkm" }
Change-Id: I1baed6c3e85a15752da8adc675482d874c9355ab
Task-number: QTBUG-59872
Task-number: QTBUG-29451
Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
Diffstat (limited to 'src/quick/scenegraph/util')
-rw-r--r-- | src/quick/scenegraph/util/qsgtexturereader.cpp | 82 | ||||
-rw-r--r-- | src/quick/scenegraph/util/qsgtexturereader_p.h | 72 |
2 files changed, 154 insertions, 0 deletions
diff --git a/src/quick/scenegraph/util/qsgtexturereader.cpp b/src/quick/scenegraph/util/qsgtexturereader.cpp new file mode 100644 index 0000000000..61729ada18 --- /dev/null +++ b/src/quick/scenegraph/util/qsgtexturereader.cpp @@ -0,0 +1,82 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the QtQuick module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** 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 Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** 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-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qsgtexturereader_p.h" + +#include <private/qtquickglobal_p.h> + +#if QT_CONFIG(opengl) +#include <private/qsgpkmhandler_p.h> +#endif + +QT_BEGIN_NAMESPACE + +QSGTextureReader::QSGTextureReader() +{ + +} + +QQuickTextureFactory *QSGTextureReader::read(QIODevice *device, const QByteArray &format) +{ +#if QT_CONFIG(opengl) + if (format == QByteArrayLiteral("pkm")) { + QSGPkmHandler handler; + return handler.read(device); + } +#else + Q_UNUSED(device) + Q_UNUSED(format) +#endif + return nullptr; +} + +bool QSGTextureReader::isTexture(QIODevice *device, const QByteArray &format) +{ +#if QT_CONFIG(opengl) + if (format == QByteArrayLiteral("pkm")) { + return device->peek(4) == QByteArrayLiteral("PKM "); + } +#else + Q_UNUSED(device) + Q_UNUSED(format) +#endif + return false; +} + +QT_END_NAMESPACE diff --git a/src/quick/scenegraph/util/qsgtexturereader_p.h b/src/quick/scenegraph/util/qsgtexturereader_p.h new file mode 100644 index 0000000000..7d2fc314a6 --- /dev/null +++ b/src/quick/scenegraph/util/qsgtexturereader_p.h @@ -0,0 +1,72 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the QtQuick module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** 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 Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** 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-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QSGTEXTUREREADER_H +#define QSGTEXTUREREADER_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include <QString> + +QT_BEGIN_NAMESPACE + +class QIODevice; +class QQuickTextureFactory; + +class QSGTextureReader +{ +public: + QSGTextureReader(); + + static QQuickTextureFactory *read(QIODevice *device, const QByteArray &format); + static bool isTexture(QIODevice *device, const QByteArray &format); +}; + +QT_END_NAMESPACE + +#endif // QSGTEXTUREREADER_H |