MCPcopy Create free account
hub / github.com/NatronGitHub/Natron / getOrCreateFromCacheInternal

Function getOrCreateFromCacheInternal

Engine/EffectInstance.cpp:1471–1514  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1469}
1470
1471static void
1472getOrCreateFromCacheInternal(const ImageKey & key,
1473 const ImageParamsPtr & params,
1474 bool useCache,
1475 ImagePtr* image)
1476{
1477 if (!useCache) {
1478 *image = std::make_shared<Image>(key, params);
1479 } else {
1480 assert(params->getStorageInfo().mode != eStorageModeGLTex);
1481
1482 if (params->getStorageInfo().mode == eStorageModeRAM) {
1483 appPTR->getImageOrCreate(key, params, image);
1484 } else if (params->getStorageInfo().mode == eStorageModeDisk) {
1485 appPTR->getImageOrCreate_diskCache(key, params, image);
1486 }
1487
1488 if (!*image) {
1489 std::stringstream ss;
1490 ss << "Failed to allocate an image of ";
1491 const CacheEntryStorageInfo& info = params->getStorageInfo();
1492 std::size_t size = info.dataTypeSize * info.numComponents * info.bounds.area();
1493 ss << printAsRAM(size).toStdString();
1494 Dialogs::errorDialog( QCoreApplication::translate("EffectInstance", "Out of memory").toStdString(), ss.str() );
1495
1496 return;
1497 }
1498
1499 /*
1500 * Note that at this point the image is already exposed to other threads and another one might already have allocated it.
1501 * This function does nothing if it has been reallocated already.
1502 */
1503 (*image)->allocateMemory();
1504
1505
1506 /*
1507 * Another thread might have allocated the same image in the cache but with another RoI, make sure
1508 * it is big enough for us, or resize it to our needs.
1509 */
1510
1511
1512 (*image)->ensureBounds( params->getBounds() );
1513 }
1514}
1515
1516ImagePtr
1517EffectInstance::convertOpenGLTextureToCachedRAMImage(const ImagePtr& image)

Calls 9

printAsRAMFunction · 0.85
getImageOrCreateMethod · 0.80
toStdStringMethod · 0.80
allocateMemoryMethod · 0.80
ensureBoundsMethod · 0.80
translateFunction · 0.50
areaMethod · 0.45
getBoundsMethod · 0.45

Tested by

no test coverage detected