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

Function getOrCreateFromCacheInternal

Engine/EffectInstance.cpp:1473–1516  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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

Calls 10

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

Tested by

no test coverage detected