diff options
Diffstat (limited to 'src/gui/util/qastchandler.cpp')
-rw-r--r-- | src/gui/util/qastchandler.cpp | 51 |
1 files changed, 9 insertions, 42 deletions
diff --git a/src/gui/util/qastchandler.cpp b/src/gui/util/qastchandler.cpp index e91ae3e0f5..ec8b92f557 100644 --- a/src/gui/util/qastchandler.cpp +++ b/src/gui/util/qastchandler.cpp @@ -1,41 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2019 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtGui 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$ -** -****************************************************************************/ +// Copyright (C) 2019 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only #include "qastchandler_p.h" #include "qtexturefiledata_p.h" @@ -59,6 +23,8 @@ struct AstcHeader quint8 zSize[3]; }; +QAstcHandler::~QAstcHandler() = default; + bool QAstcHandler::canRead(const QByteArray &suffix, const QByteArray &block) { Q_UNUSED(suffix); @@ -71,7 +37,7 @@ quint32 QAstcHandler::astcGLFormat(quint8 xBlockDim, quint8 yBlockDim) const static const quint32 glFormatRGBABase = 0x93B0; // GL_COMPRESSED_RGBA_ASTC_4x4_KHR static const quint32 glFormatSRGBBase = 0x93D0; // GL_COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR - static QSize dims[14] = { + Q_CONSTINIT static QSize dims[14] = { { 4, 4 }, // GL_COMPRESSED_xxx_ASTC_4x4_KHR { 5, 4 }, // GL_COMPRESSED_xxx_ASTC_5x4_KHR { 5, 5 }, // GL_COMPRESSED_xxx_ASTC_5x5_KHR @@ -143,13 +109,14 @@ QTextureFileData QAstcHandler::read() int zBlocks = (zSz + header->blockDimZ - 1) / header->blockDimZ; int byteCount = 0; - bool oob = mul_overflow(xBlocks, yBlocks, &byteCount) - || mul_overflow(byteCount, zBlocks, &byteCount) - || mul_overflow(byteCount, 16, &byteCount); + bool oob = qMulOverflow(xBlocks, yBlocks, &byteCount) + || qMulOverflow(byteCount, zBlocks, &byteCount) + || qMulOverflow(byteCount, 16, &byteCount); res.setDataOffset(sizeof(AstcHeader)); res.setNumLevels(1); + res.setNumFaces(1); res.setDataLength(byteCount); if (oob || !res.isValid()) { |