Пример #1
0
uint32 TextureHelper::EnumerateSceneTextures(DAVA::Scene* scene)
{
	Map<String, Texture *> textureMap;
	EnumerateTextures(scene, textureMap);

	uint32 sceneTextureMemory = 0;
	for(Map<String, Texture *>::const_iterator it = textureMap.begin(); it != textureMap.end(); ++it)
	{
		Texture *t = it->second;
		//We need real info about textures size. In Editor on desktop pvr textures are decompressed to RGBA8888, so they have not real size.
        TextureDescriptor *descriptor = TextureDescriptor::CreateFromFile(t->GetPathname());
        if(descriptor)
        {
            FilePath imageFileName = GPUFamilyDescriptor::CreatePathnameForGPU(descriptor, (eGPUFamily)descriptor->exportedAsGpuFamily);
            if(imageFileName.IsEqualToExtension(".pvr"))
            {
                sceneTextureMemory += LibPVRHelper::GetDataSize(imageFileName);
            }
            else if(imageFileName.IsEqualToExtension(".dds"))
            {
                sceneTextureMemory += LibDxtHelper::GetDataSize(imageFileName);
            }
            else
            {
                sceneTextureMemory += t->GetDataSize();
            }
            
            delete descriptor;
        }
	}

	return sceneTextureMemory;
}
Пример #2
0
uint32 TextureHelper::EnumerateSceneTextures(DAVA::Scene* scene, const String& scenePath)
{
	Map<String, Texture *> textureMap;
	EnumerateTextures(scene, textureMap);

	String projectPath = scenePath;

	uint32 sceneTextureMemory = 0;
	for(Map<String, Texture *>::const_iterator it = textureMap.begin(); it != textureMap.end(); ++it)
	{
		Texture *t = it->second;
		if(String::npos == t->GetPathname().find(projectPath))
		{   // skip all textures that are not related the scene
			continue;
		}

		if(String::npos != t->GetPathname().find(projectPath))
		{   //We need real info about textures size. In Editor on desktop pvr textures are decompressed to RGBA8888, so they have not real size.
			String imageFileName = TextureDescriptor::GetPathnameForFormat(t->GetPathname(), t->GetSourceFileFormat());
			switch (t->GetSourceFileFormat())
			{
				case DAVA::PVR_FILE:
				{
					sceneTextureMemory += LibPVRHelper::GetDataLength(imageFileName);
					break;
				}

				case DAVA::DXT_FILE:
				{
					sceneTextureMemory += (int32)LibDxtHelper::GetDataSize(imageFileName);
					break;
				}

				default:
					sceneTextureMemory += t->GetDataSize();
					break;
			}
		}
	}

	return sceneTextureMemory;
}