From ba6b7fffbec4f18fffd6a78aa4cb86006e4a3c4b Mon Sep 17 00:00:00 2001 From: Eirik Aavitsland Date: Mon, 26 Feb 2018 15:31:58 +0100 Subject: Fix: do data size check of pkm format compressed texture files Reintroduce reading - and sanity checking - the data size from the file header of pkm files. This was commented out during the refactoring, since it lacked the fix for ETC2_EAC format (ref. 16cd1f8 on 5.10 branch). This commit also includes that fix. Change-Id: Id85547fb6bee254d58e49ddff4593704f7ab83ed Reviewed-by: Michael Brasser --- src/quick/scenegraph/compressedtexture/qsgpkmhandler.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'src/quick/scenegraph') diff --git a/src/quick/scenegraph/compressedtexture/qsgpkmhandler.cpp b/src/quick/scenegraph/compressedtexture/qsgpkmhandler.cpp index daec23d478..618c0db045 100644 --- a/src/quick/scenegraph/compressedtexture/qsgpkmhandler.cpp +++ b/src/quick/scenegraph/compressedtexture/qsgpkmhandler.cpp @@ -95,10 +95,9 @@ QQuickTextureFactory *QSGPkmHandler::read() texData->hasAlpha = !QSGCompressedTexture::formatIsOpaque(texData->format); // texture size - /* Actual data length depends on format; for now just use 0, i.e. rest-of-file + const int bpb = (texData->format == QOpenGLTexture::RGBA8_ETC2_EAC) ? 16 : 8; QSize paddedSize(qFromBigEndian(rawData + 8), qFromBigEndian(rawData + 10)); - texData->dataLength = (paddedSize.width() / 4) * (paddedSize.height() / 4) * 8; - */ + texData->dataLength = (paddedSize.width() / 4) * (paddedSize.height() / 4) * bpb; QSize texSize(qFromBigEndian(rawData + 12), qFromBigEndian(rawData + 14)); texData->size = texSize; -- cgit v1.2.3