fix skybox loading I think and pull in sabrina's ktx caching fix

This commit is contained in:
SamGondelman 2019-02-09 16:42:34 -08:00
parent 9193704173
commit 20841a0eea

View file

@ -335,12 +335,8 @@ int networkTexturePointerMetaTypeId = qRegisterMetaType<QWeakPointer<NetworkText
NetworkTexture::NetworkTexture(const QUrl& url) :
Resource(url),
_type(),
_maxNumPixels(100)
{
_textureSource = std::make_shared<gpu::TextureSource>(url);
_lowestRequestedMipLevel = 0;
_loaded = true;
}
NetworkTexture::NetworkTexture(const NetworkTexture& other) :
@ -425,7 +421,7 @@ gpu::TexturePointer NetworkTexture::getFallbackTexture() const {
class ImageReader : public QRunnable {
public:
ImageReader(const QWeakPointer<Resource>& resource, const QUrl& url,
const QByteArray& data, int maxNumPixels);
const QByteArray& data, size_t extraHash, int maxNumPixels);
void run() override final;
void read();
@ -435,6 +431,7 @@ private:
QWeakPointer<Resource> _resource;
QUrl _url;
QByteArray _content;
size_t _extraHash;
int _maxNumPixels;
};
@ -1068,7 +1065,7 @@ void NetworkTexture::loadTextureContent(const QByteArray& content) {
return;
}
QThreadPool::globalInstance()->start(new ImageReader(_self, _url, content, _maxNumPixels));
QThreadPool::globalInstance()->start(new ImageReader(_self, _url, content, _extraHash, _maxNumPixels));
}
void NetworkTexture::refresh() {
@ -1093,10 +1090,11 @@ void NetworkTexture::refresh() {
Resource::refresh();
}
ImageReader::ImageReader(const QWeakPointer<Resource>& resource, const QUrl& url, const QByteArray& data, int maxNumPixels) :
ImageReader::ImageReader(const QWeakPointer<Resource>& resource, const QUrl& url, const QByteArray& data, size_t extraHash, int maxNumPixels) :
_resource(resource),
_url(url),
_content(data),
_extraHash(extraHash),
_maxNumPixels(maxNumPixels)
{
DependencyManager::get<StatTracker>()->incrementStat("PendingProcessing");
@ -1152,11 +1150,12 @@ void ImageReader::read() {
}
auto networkTexture = resource.staticCast<NetworkTexture>();
// Hash the source image to for KTX caching
// Hash the source image and extraHash for KTX caching
std::string hash;
{
QCryptographicHash hasher(QCryptographicHash::Md5);
hasher.addData(_content);
hasher.addData(std::to_string(_extraHash).c_str());
hash = hasher.result().toHex().toStdString();
}