7#include <private/qnumeric_p.h>
37 static const quint32 glFormatRGBABase = 0x93B0;
38 static const quint32 glFormatSRGBBase = 0x93D0;
40 Q_CONSTINIT
static QSize dims[14] = {
57 const QSize dim(xBlockDim, yBlockDim);
59 for (
int i = 0;
i < 14;
i++) {
71 return useSrgb ? (glFormatSRGBBase +
index) : (glFormatRGBABase +
index);
84 qCDebug(lcQtGuiTextureIO,
"Not an ASTC file: %s",
logName().constData());
91 int xSz = int(
header->xSize[0]) | int(
header->xSize[1]) << 8 | int(
header->xSize[2]) << 16;
92 int ySz = int(
header->ySize[0]) | int(
header->ySize[1]) << 8 | int(
header->ySize[2]) << 16;
93 int zSz = int(
header->zSize[0]) | int(
header->zSize[1]) << 8 | int(
header->zSize[2]) << 16;
97 if (!xSz || !ySz || !zSz || !glFmt ||
header->blockDimZ != 1) {
98 qCDebug(lcQtGuiTextureIO,
"Invalid ASTC header data in file %s",
logName().constData());
104 res.setGLInternalFormat(glFmt);
107 int xBlocks = (xSz +
header->blockDimX - 1) /
header->blockDimX;
108 int yBlocks = (ySz +
header->blockDimY - 1) /
header->blockDimY;
109 int zBlocks = (zSz +
header->blockDimZ - 1) /
header->blockDimZ;
120 res.setDataLength(byteCount);
122 if (oob || !
res.isValid()) {
123 qCDebug(lcQtGuiTextureIO,
"Invalid ASTC file %s",
logName().constData());
130 qDebug() <<
"ASTC file handler read" <<
res <<
res.dataOffset() <<
res.dataLength();
static bool canRead(const QByteArray &suffix, const QByteArray &block)
QTextureFileData read() override
qsizetype size() const noexcept
Returns the number of bytes in this byte array.
const char * constData() const noexcept
Returns a pointer to the const data stored in the byte array.
bool startsWith(QByteArrayView bv) const
bool contains(char c) const
This is an overloaded member function, provided for convenience. It differs from the above function o...
QByteArray toLower() const &
QByteArray readAll()
Reads all remaining data from the device, and returns it as a byte array.
void setSize(const QSize &size)
void setData(const QByteArray &data)
void setLogName(const QByteArray &name)
QIODevice * device() const
QByteArray logName() const
Combined button and popup list for selecting options.
static QString header(const QString &name)
#define qCDebug(category,...)
std::enable_if_t< std::is_unsigned_v< T >||std::is_signed_v< T >, bool > qMulOverflow(T v1, T v2, T *r)
Q_CORE_EXPORT bool qEnvironmentVariableIsSet(const char *varName) noexcept