diff options
author | Eirik Aavitsland <eirik.aavitsland@qt.io> | 2017-11-27 19:03:16 +0100 |
---|---|---|
committer | Michael Brasser <michael.brasser@live.com> | 2018-01-27 02:42:16 +0000 |
commit | ae7c66b8f50103c212789805efccba208a55ea4b (patch) | |
tree | 8640661ae688829d03d1f3d77bda3a1fc0888865 /src/quick/util | |
parent | 0f8e0310b7ad874a1fbdb3def4cf8d7da7f943e5 (diff) |
Refactor compressed texture file reading
This commit expands on the basic support for compressed texture files
that was added in 432e27a. It prepares for adding support for other
file types than pkm by declaring a common QSGTextureFileHandler
interface, and by factoring out reusable code parts in a new
QSGCompressedTexture class.
It also adds some more systematic logging and checking for error
conditions.
Change-Id: Ie5070d0a6df757fee0753f53adbe23a33d51a634
Reviewed-by: Michael Brasser <michael.brasser@live.com>
Diffstat (limited to 'src/quick/util')
-rw-r--r-- | src/quick/util/qquickpixmapcache.cpp | 17 |
1 files changed, 7 insertions, 10 deletions
diff --git a/src/quick/util/qquickpixmapcache.cpp b/src/quick/util/qquickpixmapcache.cpp index e218b84fff..6712b01476 100644 --- a/src/quick/util/qquickpixmapcache.cpp +++ b/src/quick/util/qquickpixmapcache.cpp @@ -772,11 +772,9 @@ void QQuickPixmapReader::processJob(QQuickPixmapReply *runningJob, const QUrl &u QFile f(localFile); QSize readSize; if (f.open(QIODevice::ReadOnly)) { - - // for now, purely use suffix information to determine whether we are working with a compressed texture - QByteArray suffix = QFileInfo(f).suffix().toLower().toLatin1(); - if (QSGTextureReader::isTexture(&f, suffix)) { - QQuickTextureFactory *factory = QSGTextureReader::read(&f, suffix); + QSGTextureReader texReader(&f, localFile); + if (texReader.isTexture()) { + QQuickTextureFactory *factory = texReader.read(); if (factory) { readSize = factory->textureSize(); } else { @@ -1252,13 +1250,12 @@ static QQuickPixmapData* createPixmapDataSync(QQuickPixmap *declarativePixmap, Q QString errorString; if (f.open(QIODevice::ReadOnly)) { - // for now, purely use suffix information to determine whether we are working with a compressed texture - QByteArray suffix = QFileInfo(f).suffix().toLower().toLatin1(); - if (QSGTextureReader::isTexture(&f, suffix)) { - QQuickTextureFactory *factory = QSGTextureReader::read(&f, suffix); + QSGTextureReader texReader(&f, localFile); + if (texReader.isTexture()) { + QQuickTextureFactory *factory = texReader.read(); if (factory) { *ok = true; - return new QQuickPixmapData(declarativePixmap, factory); + return new QQuickPixmapData(declarativePixmap, url, factory, factory->textureSize(), requestSize, providerOptions, QQuickImageProviderOptions::UsePluginDefaultTransform); } else { errorString = QQuickPixmap::tr("Error decoding: %1").arg(url.toString()); } |