| 1617 | } // convertRAMImageToOpenGLTexture |
| 1618 | |
| 1619 | void |
| 1620 | EffectInstance::getImageFromCacheAndConvertIfNeeded(bool /*useCache*/, |
| 1621 | StorageModeEnum storage, |
| 1622 | StorageModeEnum returnStorage, |
| 1623 | const ImageKey & key, |
| 1624 | unsigned int mipMapLevel, |
| 1625 | const RectI* boundsParam, |
| 1626 | const RectD* rodParam, |
| 1627 | const RectI& roi, |
| 1628 | ImageBitDepthEnum bitdepth, |
| 1629 | const ImagePlaneDesc & components, |
| 1630 | const EffectInstance::InputImagesMap & inputImages, |
| 1631 | const boost::shared_ptr<RenderStats> & stats, |
| 1632 | const boost::shared_ptr<OSGLContextAttacher>& glContextAttacher, |
| 1633 | boost::shared_ptr<Image>* image) |
| 1634 | { |
| 1635 | ImageList cachedImages; |
| 1636 | bool isCached = false; |
| 1637 | |
| 1638 | ///Find first something in the input images list |
| 1639 | if ( !inputImages.empty() ) { |
| 1640 | for (InputImagesMap::const_iterator it = inputImages.begin(); it != inputImages.end(); ++it) { |
| 1641 | for (ImageList::const_iterator it2 = it->second.begin(); it2 != it->second.end(); ++it2) { |
| 1642 | if ( !it2->get() ) { |
| 1643 | continue; |
| 1644 | } |
| 1645 | const ImageKey & imgKey = (*it2)->getKey(); |
| 1646 | if (imgKey == key) { |
| 1647 | cachedImages.push_back(*it2); |
| 1648 | isCached = true; |
| 1649 | } |
| 1650 | } |
| 1651 | } |
| 1652 | } |
| 1653 | |
| 1654 | if (!isCached) { |
| 1655 | // For textures, we lookup for a RAM image, if found we convert it to a texture |
| 1656 | if ( (storage == eStorageModeRAM) || (storage == eStorageModeGLTex) ) { |
| 1657 | isCached = appPTR->getImage(key, &cachedImages); |
| 1658 | } else if (storage == eStorageModeDisk) { |
| 1659 | isCached = appPTR->getImage_diskCache(key, &cachedImages); |
| 1660 | } |
| 1661 | } |
| 1662 | |
| 1663 | if (stats && stats->isInDepthProfilingEnabled() && !isCached) { |
| 1664 | stats->addCacheInfosForNode(getNode(), true, false); |
| 1665 | } |
| 1666 | |
| 1667 | if (isCached) { |
| 1668 | ///A ptr to a higher resolution of the image or an image with different comps/bitdepth |
| 1669 | ImagePtr imageToConvert; |
| 1670 | |
| 1671 | for (ImageList::iterator it = cachedImages.begin(); it != cachedImages.end(); ++it) { |
| 1672 | unsigned int imgMMlevel = (*it)->getMipMapLevel(); |
| 1673 | const ImagePlaneDesc & imgComps = (*it)->getComponents(); |
| 1674 | ImageBitDepthEnum imgDepth = (*it)->getBitDepth(); |
| 1675 | |
| 1676 | if ( (*it)->getParams()->isRodProjectFormat() ) { |
no test coverage detected