Commit 967dca12 authored by mercury233's avatar mercury233

preformance

parent 8d8bd503
...@@ -366,22 +366,24 @@ irr::video::ITexture* ImageManager::GetTextureThumb(int code) { ...@@ -366,22 +366,24 @@ irr::video::ITexture* ImageManager::GetTextureThumb(int code) {
tThumb[code] = img; tThumb[code] = img;
return (img == NULL) ? tUnknownThumb : img; return (img == NULL) ? tUnknownThumb : img;
} }
imageManager.tThumbLoadingMutex.lock(); if(tit == tThumb.end() || tit->second == tLoading) {
auto lit = tThumbLoading.find(code); imageManager.tThumbLoadingMutex.lock();
if(lit != tThumbLoading.end()) { auto lit = tThumbLoading.find(code);
if(lit->second != nullptr) { if(lit != tThumbLoading.end()) {
char file[256]; if(lit->second != nullptr) {
std::snprintf(file, sizeof file, "pics/thumbnail/%d.jpg", code); char file[256];
irr::video::ITexture* texture = driver->addTexture(file, lit->second); // textures must be added in the main thread due to OpenGL std::snprintf(file, sizeof file, "pics/thumbnail/%d.jpg", code);
lit->second->drop(); irr::video::ITexture* texture = driver->addTexture(file, lit->second); // textures must be added in the main thread due to OpenGL
tThumb[code] = texture; lit->second->drop();
} else { tThumb[code] = texture;
tThumb[code] = nullptr; } else {
tThumb[code] = nullptr;
}
tThumbLoading.erase(lit);
} }
tThumbLoading.erase(lit); imageManager.tThumbLoadingMutex.unlock();
tit = tThumb.find(code);
} }
imageManager.tThumbLoadingMutex.unlock();
tit = tThumb.find(code);
if(tit == tThumb.end()) { if(tit == tThumb.end()) {
tThumb[code] = tLoading; tThumb[code] = tLoading;
imageManager.tThumbLoadingMutex.lock(); imageManager.tThumbLoadingMutex.lock();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment