MCPcopy Create free account
hub / github.com/axmolengine/axmol / loadImage

Method loadImage

core/renderer/TextureCache.cpp:255–299  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

253}
254
255void TextureCache::loadImage()
256{
257 AsyncStruct* asyncStruct = nullptr;
258 while (!_needQuit)
259 {
260 std::unique_lock<std::mutex> ul(_requestMutex);
261 // pop an AsyncStruct from request queue
262 if (_requestQueue.empty())
263 {
264 asyncStruct = nullptr;
265 }
266 else
267 {
268 asyncStruct = _requestQueue.front();
269 _requestQueue.pop_front();
270 }
271
272 if (nullptr == asyncStruct)
273 {
274 if (_needQuit)
275 {
276 break;
277 }
278 _sleepCondition.wait(ul);
279 continue;
280 }
281 ul.unlock();
282
283 // load image
284 asyncStruct->loadSuccess = asyncStruct->image.initWithImageFileThreadSafe(asyncStruct->filename);
285
286 // ETC1 ALPHA supports.
287 if (asyncStruct->loadSuccess && asyncStruct->image.getFileType() == Image::Format::ETC1 &&
288 !s_etc1AlphaFileSuffix.empty())
289 { // check whether alpha texture exists & load it
290 auto alphaFile = asyncStruct->filename + s_etc1AlphaFileSuffix;
291 if (FileUtils::getInstance()->isFileExist(alphaFile))
292 asyncStruct->imageAlpha.initWithImageFileThreadSafe(alphaFile);
293 }
294 // push the asyncStruct to response queue
295 _responseMutex.lock();
296 _responseQueue.emplace_back(asyncStruct);
297 _responseMutex.unlock();
298 }
299}
300
301void TextureCache::addImageAsyncCallBack(float /*dt*/)
302{

Callers

nothing calls this directly

Calls 10

getInstanceFunction · 0.85
emptyMethod · 0.45
frontMethod · 0.45
pop_frontMethod · 0.45
waitMethod · 0.45
unlockMethod · 0.45
isFileExistMethod · 0.45
lockMethod · 0.45
emplace_backMethod · 0.45

Tested by

no test coverage detected