diff options
Diffstat (limited to 'src/runtimerender/resourcemanager/Qt3DSRenderImageBatchLoader.cpp')
-rw-r--r-- | src/runtimerender/resourcemanager/Qt3DSRenderImageBatchLoader.cpp | 52 |
1 files changed, 24 insertions, 28 deletions
diff --git a/src/runtimerender/resourcemanager/Qt3DSRenderImageBatchLoader.cpp b/src/runtimerender/resourcemanager/Qt3DSRenderImageBatchLoader.cpp index 01ec9d4..253f481 100644 --- a/src/runtimerender/resourcemanager/Qt3DSRenderImageBatchLoader.cpp +++ b/src/runtimerender/resourcemanager/Qt3DSRenderImageBatchLoader.cpp @@ -54,12 +54,12 @@ typedef Mutex::ScopedLock TScopedLock; struct SLoadingImage { SImageLoaderBatch *m_Batch; - CRegisteredString m_SourcePath; + QString m_SourcePath; QT3DSU64 m_TaskId; SLoadingImage *m_Tail; // Called from main thread - SLoadingImage(CRegisteredString inSourcePath) + SLoadingImage(const QString &inSourcePath) : m_Batch(NULL) , m_SourcePath(inSourcePath) , m_TaskId(0) @@ -113,8 +113,8 @@ struct SImageLoaderBatch // Called from main thread static SImageLoaderBatch *CreateLoaderBatch(SBatchLoader &inLoader, TImageBatchId inBatchId, - NVConstDataRef<CRegisteredString> inSourcePaths, - CRegisteredString inImageTillLoaded, + const QVector<QString> &inSourcePaths, + const QString &inImageTillLoaded, IImageLoadListener *inListener, NVRenderContextType contextType, bool iblImage, @@ -154,12 +154,12 @@ struct SImageLoaderBatch } // Called from main thread void Cancel(); - void Cancel(CRegisteredString inSourcePath); + void Cancel(const QString &inSourcePath); }; struct SBatchLoadedImage { - CRegisteredString m_SourcePath; + QString m_SourcePath; SLoadedTexture *m_Texture; SImageLoaderBatch *m_Batch; SBatchLoadedImage() @@ -169,7 +169,7 @@ struct SBatchLoadedImage } // Called from loading thread - SBatchLoadedImage(CRegisteredString inSourcePath, SLoadedTexture *inTexture, + SBatchLoadedImage(QString inSourcePath, SLoadedTexture *inTexture, SImageLoaderBatch &inBatch) : m_SourcePath(inSourcePath) , m_Texture(inTexture) @@ -184,7 +184,7 @@ struct SBatchLoadedImage struct SBatchLoader : public IImageBatchLoader { typedef nvhash_map<TImageBatchId, SImageLoaderBatch *> TImageLoaderBatchMap; - typedef nvhash_map<CRegisteredString, TImageBatchId> TSourcePathToBatchMap; + typedef QMap<QString, TImageBatchId> TSourcePathToBatchMap; typedef Pool<SLoadingImage, ForwardingAllocator> TLoadingImagePool; typedef Pool<SImageLoaderBatch, ForwardingAllocator> TBatchPool; @@ -230,7 +230,6 @@ struct SBatchLoader : public IImageBatchLoader , m_LoaderMutex(inFoundation.getAllocator()) , m_LoadedImages(inFoundation.getAllocator(), "SBatchLoader::m_LoadedImages") , m_FinishedBatches(inFoundation.getAllocator(), "SBatchLoader::m_FinishedBatches") - , m_SourcePathToBatches(inFoundation.getAllocator(), "SBatchLoader::m_SourcePathToBatches") , m_LoaderBuilderWorkspace(inFoundation.getAllocator(), "SBatchLoader::m_LoaderBuilderWorkspace") , m_LoadingImagePool( @@ -260,8 +259,8 @@ struct SBatchLoader : public IImageBatchLoader // paths // until said path is loaded. // An optional listener can be passed in to get callbacks about the batch. - TImageBatchId LoadImageBatch(NVConstDataRef<CRegisteredString> inSourcePaths, - CRegisteredString inImageTillLoaded, + TImageBatchId LoadImageBatch(const QVector<QString> &inSourcePaths, + const QString &inImageTillLoaded, IImageLoadListener *inListener, NVRenderContextType contextType, bool iblImages, @@ -297,12 +296,12 @@ struct SBatchLoader : public IImageBatchLoader } // Blocks if the image is currently in-flight - void CancelImageLoading(CRegisteredString inSourcePath) override + void CancelImageLoading(const QString &inSourcePath) override { TScopedLock __loaderLock(m_LoaderMutex); TSourcePathToBatchMap::iterator theIter = m_SourcePathToBatches.find(inSourcePath); if (theIter != m_SourcePathToBatches.end()) { - TImageBatchId theBatchId = theIter->second; + const TImageBatchId &theBatchId = theIter.value(); TImageLoaderBatchMap::iterator theBatchIter = m_Batches.find(theBatchId); if (theBatchIter != m_Batches.end()) theBatchIter->second->Cancel(inSourcePath); @@ -334,7 +333,7 @@ struct SBatchLoader : public IImageBatchLoader { TScopedLock __loaderLock(m_LoaderMutex); if (inTexture == nullptr) - qCWarning(WARNING, "Failed to load image: %s", inImage.m_SourcePath.c_str()); + qCWarning(WARNING) << "Failed to load image: " << inImage.m_SourcePath; m_LoadedImages.push_back( SBatchLoadedImage(inImage.m_SourcePath, inTexture, *inImage.m_Batch)); inImage.m_Batch->IncrementLoadedImageCount(); @@ -347,7 +346,7 @@ struct SBatchLoader : public IImageBatchLoader // Pass 1 - send out all image loaded signals for (QT3DSU32 idx = 0, end = m_LoadedImages.size(); idx < end; ++idx) { - m_SourcePathToBatches.erase(m_LoadedImages[idx].m_SourcePath); + m_SourcePathToBatches.remove(m_LoadedImages[idx].m_SourcePath); m_LoadedImages[idx].Finalize(m_BufferManager); m_LoadedImages[idx].m_Batch->IncrementFinalizedImageCount(); if (m_LoadedImages[idx].m_Batch->IsFinalizedFinished()) @@ -389,7 +388,7 @@ void SLoadingImage::LoadImage(void *inImg) QT3DS_PERF_SCOPED_TIMER(theThis->m_Batch->m_Loader.m_PerfTimer, "BatchLoader: Image Decompression") if (theThis->m_Batch->m_Loader.m_BufferManager.IsImageLoaded(theThis->m_SourcePath) == false) { SLoadedTexture *theTexture = SLoadedTexture::Load( - theThis->m_SourcePath.c_str(), theThis->m_Batch->m_Loader.m_Foundation, + theThis->m_SourcePath, theThis->m_Batch->m_Loader.m_Foundation, theThis->m_Batch->m_Loader.m_InputStreamFactory, true, theThis->m_Batch->m_flipCompressedTextures, theThis->m_Batch->m_contextType, @@ -413,7 +412,6 @@ void SLoadingImage::TaskCancelled(void *inImg) bool SBatchLoadedImage::Finalize(IBufferManager &inMgr) { if (m_Texture) { - eastl::string thepath(m_SourcePath); bool isIBL = this->m_Batch->m_ibl; inMgr.LoadRenderImage(m_SourcePath, *m_Texture, false, isIBL); inMgr.UnaliasImagePath(m_SourcePath); @@ -432,8 +430,8 @@ bool SBatchLoadedImage::Finalize(IBufferManager &inMgr) SImageLoaderBatch * SImageLoaderBatch::CreateLoaderBatch(SBatchLoader &inLoader, TImageBatchId inBatchId, - NVConstDataRef<CRegisteredString> inSourcePaths, - CRegisteredString inImageTillLoaded, + const QVector<QString> &inSourcePaths, + const QString &inImageTillLoaded, IImageLoadListener *inListener, NVRenderContextType contextType, bool iblImages, bool flipCompressedTextures) @@ -441,22 +439,20 @@ SImageLoaderBatch::CreateLoaderBatch(SBatchLoader &inLoader, TImageBatchId inBat TLoadingImageList theImages; QT3DSU32 theLoadingImageCount = 0; for (QT3DSU32 idx = 0, end = inSourcePaths.size(); idx < end; ++idx) { - CRegisteredString theSourcePath(inSourcePaths[idx]); + const QString theSourcePath(inSourcePaths[idx]); - if (theSourcePath.IsValid() == false) + if (theSourcePath.isEmpty()) continue; if (inLoader.m_BufferManager.IsImageLoaded(theSourcePath)) continue; - eastl::pair<SBatchLoader::TSourcePathToBatchMap::iterator, bool> theInserter = - inLoader.m_SourcePathToBatches.insert(eastl::make_pair(inSourcePaths[idx], inBatchId)); - - // If the loader has already seen this image. - if (theInserter.second == false) + if (inLoader.m_SourcePathToBatches.contains(inSourcePaths[idx])) continue; - if (inImageTillLoaded.IsValid()) { + inLoader.m_SourcePathToBatches.insert(inSourcePaths[idx], inBatchId); + + if (!inImageTillLoaded.isEmpty()) { // Alias the image so any further requests for this source path will result in // the default images (image till loaded). bool aliasSuccess = @@ -520,7 +516,7 @@ void SImageLoaderBatch::Cancel() m_Loader.m_ThreadPool.CancelTask(iter->m_TaskId); } -void SImageLoaderBatch::Cancel(CRegisteredString inSourcePath) +void SImageLoaderBatch::Cancel(const QString &inSourcePath) { for (TLoadingImageList::iterator iter = m_Images.begin(), end = m_Images.end(); iter != end; ++iter) { |