本文整理汇总了C++中CTextureMap::GetMemoryUsage方法的典型用法代码示例。如果您正苦于以下问题:C++ CTextureMap::GetMemoryUsage方法的具体用法?C++ CTextureMap::GetMemoryUsage怎么用?C++ CTextureMap::GetMemoryUsage使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CTextureMap
的用法示例。
在下文中一共展示了CTextureMap::GetMemoryUsage方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: lock
//.........这里部分代码省略.........
}
else if (StringUtils::EndsWithNoCase(strPath, ".gif") ||
StringUtils::EndsWithNoCase(strPath, ".apng"))
{
CTextureMap* pMap = nullptr;
std::string mimeType;
if (StringUtils::EndsWithNoCase(strPath, ".gif"))
mimeType = "image/gif";
else if (StringUtils::EndsWithNoCase(strPath, ".apng"))
mimeType = "image/apng";
XFILE::CFile file;
XFILE::auto_buffer buf;
CFFmpegImage anim(mimeType);
pMap = new CTextureMap(strTextureName, 0, 0, 0);
if (file.LoadFile(strPath, buf) <= 0 ||
!anim.Initialize((uint8_t*)buf.get(), buf.size()) || !pMap)
{
CLog::Log(LOGERROR, "Texture manager unable to load file: %s", CURL::GetRedacted(strPath).c_str());
file.Close();
return emptyTexture;
}
unsigned int maxWidth = 0;
unsigned int maxHeight = 0;
uint64_t maxMemoryUsage = 91238400;// 1920*1080*4*11 bytes, i.e, a total of approx. 12 full hd frames
auto frame = anim.ReadFrame();
while (frame)
{
CTexture *glTexture = new CTexture();
if (glTexture)
{
glTexture->LoadFromMemory(anim.Width(), anim.Height(), frame->GetPitch(), XB_FMT_A8R8G8B8, true, frame->m_pImage);
pMap->Add(glTexture, frame->m_delay);
maxWidth = std::max(maxWidth, glTexture->GetWidth());
maxHeight = std::max(maxHeight, glTexture->GetHeight());
}
if (pMap->GetMemoryUsage() <= maxMemoryUsage)
{
frame = anim.ReadFrame();
}
else
{
CLog::Log(LOGDEBUG, "Memory limit (%" PRIu64 " bytes) exceeded, %i frames extracted from file : %s", (maxMemoryUsage/11)*12,pMap->GetTexture().size(), CURL::GetRedacted(strPath).c_str());
break;
}
}
pMap->SetWidth((int)maxWidth);
pMap->SetHeight((int)maxHeight);
file.Close();
if (pMap)
{
m_vecTextures.push_back(pMap);
return pMap->GetTexture();
}
}
CBaseTexture *pTexture = NULL;
int width = 0, height = 0;
if (bundle >= 0)
{
if (!m_TexBundle[bundle].LoadTexture(strTextureName, &pTexture, width, height))
{
CLog::Log(LOGERROR, "Texture manager unable to load bundled file: %s", strTextureName.c_str());
return emptyTexture;
}
}
else
{
pTexture = CBaseTexture::LoadFromFile(strPath);
if (!pTexture)
return emptyTexture;
width = pTexture->GetWidth();
height = pTexture->GetHeight();
}
if (!pTexture) return emptyTexture;
CTextureMap* pMap = new CTextureMap(strTextureName, width, height, 0);
pMap->Add(pTexture, 100);
m_vecTextures.push_back(pMap);
#ifdef _DEBUG_TEXTURES
int64_t end, freq;
end = CurrentHostCounter();
freq = CurrentHostFrequency();
char temp[200];
sprintf(temp, "Load %s: %.1fms%s\n", strPath.c_str(), 1000.f * (end - start) / freq, (bundle >= 0) ? " (bundled)" : "");
OutputDebugString(temp);
#endif
return pMap->GetTexture();
}