eGPUFamily GPUFamilyDescriptor::GetGPUForPathname(const FilePath &pathname)
{
    const String filename = pathname.GetFilename();
    
    for(int32 i = 0; i < GPU_FAMILY_COUNT; ++i)
    {
        eGPUFamily gpu = (eGPUFamily)i;
        
        String strForFind(Format(".%s.", gpuData[gpu].name.c_str()));
        if(String::npos != filename.rfind(strForFind))
        {
            return gpu;
        }
    }

    
    return GPU_UNKNOWN;
}
Пример #2
0
String FilePath::AbsoluteToRelative(const FilePath &directoryPathname, const FilePath &absolutePathname)
{
    if(absolutePathname.IsEmpty())
        return String();

    DVASSERT(directoryPathname.IsDirectoryPathname());

    Vector<String> folders;
	Vector<String> fileFolders;

	if(directoryPathname.GetType() == PATH_IN_RESOURCES &&	absolutePathname.GetType() == PATH_IN_RESOURCES)
	{
		Split(directoryPathname.absolutePathname, "/", folders);
		Split(absolutePathname.GetDirectory().absolutePathname, "/", fileFolders);
	}
	else
	{
		Split(directoryPathname.GetAbsolutePathname(), "/", folders);
		Split(absolutePathname.GetDirectory().GetAbsolutePathname(), "/", fileFolders);
	}
    
    Vector<String>::size_type equalCount = 0;
    for(; equalCount < folders.size() && equalCount < fileFolders.size(); ++equalCount)
    {
        if(folders[equalCount] != fileFolders[equalCount])
        {
            break;
        }
    }
    
    String retPath = "";
    for(Vector<String>::size_type i = equalCount; i < folders.size(); ++i)
    {
        retPath += "../";
    }
    
    for(Vector<String>::size_type i = equalCount; i < fileFolders.size(); ++i)
    {
        retPath += fileFolders[i] + "/";
    }
    
    return (retPath + absolutePathname.GetFilename());
}
Пример #3
0
void TextureConverterCell::SetTexture(const FilePath &texturePath)
{
    textureFormat->SetText(L"");
    textureSize->SetText(L"");
    textureName->SetText(StringToWString(texturePath.GetFilename()));
    
    Texture *texture = Texture::CreateFromFile(texturePath);
    Sprite *s = Sprite::CreateFromTexture(texture, 0, 0, (float32)texture->width, (float32)texture->height);
    preview->SetSprite(s, 0);
    
    if(texturePath.IsEqualToExtension(".png"))
    {
        String pngFormat = Texture::GetPixelFormatString(texture->format);
        
        FilePath pvrPath = FilePath::CreateWithNewExtension(texturePath, ".pvr");
        Texture *pvrTex = Texture::CreateFromFile(pvrPath);
        if(pvrTex)
        {
            PixelFormat format = LibPVRHelper::GetPixelFormat(pvrPath);
            uint32 pvrDataSize = LibPVRHelper::GetDataSize(pvrPath);

            String pvrFormat = Texture::GetPixelFormatString(format);
            textureFormat->SetText(StringToWString(pngFormat + "/" + pvrFormat));
            
            textureSize->SetText(SizeInBytesToWideString(pvrDataSize));
            
            SafeRelease(pvrTex);
        }
        else 
        {
            textureFormat->SetText(StringToWString(pngFormat));
        }
    }
    else if(texturePath.IsEqualToExtension(".pvr"))
    {
        PixelFormat format = LibPVRHelper::GetPixelFormat(texturePath);
        uint32 pvrDataSize = LibPVRHelper::GetDataSize(texturePath);

        String pvrFormat = Texture::GetPixelFormatString(format);
        textureSize->SetText(SizeInBytesToWideString(pvrDataSize));

        FilePath pngPath = FilePath::CreateWithNewExtension(texturePath, ".png");
        Texture *pngTex = Texture::CreateFromFile(pngPath);
        if(pngTex)
        {
            String pngFormat = Texture::GetPixelFormatString(pngTex->format);
            textureFormat->SetText(StringToWString(pngFormat + "/" + pvrFormat));
            
            SafeRelease(pngTex);
        }
        else 
        {
            textureFormat->SetText(StringToWString(pvrFormat));
        }
    }

    textureDimensions->SetText(Format(L"%d x %d", texture->width, texture->height));
    
    SafeRelease(texture);
    SafeRelease(s);
}
Пример #4
0
bool GraphicsFontDefinition::LoadFontDefinition(const FilePath & fontDefName)
{
    File * file = 0;

//    size_t pos = fontDefName.rfind("/");
//    String fileName = fontDefName.substr(pos + 1);
//    String pathName = fontDefName.substr(0, pos + 1) + LocalizationSystem::Instance()->GetCurrentLocale() + "/" + fileName;

    FilePath pathName = fontDefName.GetDirectory() + (LocalizationSystem::Instance()->GetCurrentLocale() + "/" + fontDefName.GetFilename());

    file = File::Create(pathName, File::READ|File::OPEN);

    if (!file)
    {
        file = File::Create(fontDefName, File::READ|File::OPEN);
        if (!file)
        {
            return false;
        }
    }

    char header[4];
    DVVERIFY(file->Read(header, 4) == 4);
    if ((header[0] != 'F') || (header[1] != 'D') || (header[2] != 'E') || (header[3] != 'F'))
    {
        SafeRelease(file);
        return false;
    }
    uint32 version = 0;
    DVVERIFY(file->Read(&version, 4) == 4);
    if (version != 1)
    {
        SafeRelease(file);
        return false;
    }

    DVVERIFY(file->Read(&fontAscent, 4) == 4);
    DVVERIFY(file->Read(&fontDescent, 4) == 4);
    DVVERIFY(file->Read(&fontLeading, 4) == 4);
    DVVERIFY(file->Read(&fontXHeight, 4) == 4);
    DVVERIFY(file->Read(&charLeftRightPadding, 4) == 4);
    DVVERIFY(file->Read(&charTopBottomPadding, 4) == 4);

    fontHeight = (uint32)(fontAscent + fontDescent + fontLeading + 0.5f);

    DVVERIFY(file->Read(&tableLenght, 4) == 4);
    characterTable = new char16[tableLenght];
    characterPreShift = new float32[tableLenght];
    characterWidthTable = new float32[tableLenght];
    kerningBaseShift = new float32[tableLenght];
    kerningTable = new KerningPair*[tableLenght];

    for (int32 t = 0; t < tableLenght; ++t)
    {
        // BORODA: THIS IS FIX BECAUSE CHAR16 isn't char16 on MacOS and iPhone
        unsigned short c = 0;
        DVVERIFY(file->Read(&c, 2) == 2);
        characterTable[t] = c;
        DVVERIFY(file->Read(&characterPreShift[t], 4) == 4);
        DVVERIFY(file->Read(&characterWidthTable[t], 4) == 4);
        //Logger::Debug("char: %c idx: %d",  characterTable[t], t);
    }

    DVVERIFY(file->Read(&defaultShiftValue, 4) == 4);

    for (int t = 0; t < tableLenght; ++t)
    {
        DVVERIFY(file->Read(&kerningBaseShift[t], 4) == 4);
        //Logger::Debug("base: %c baseshift:%f preshift:%f", characterTable[t], kerningBaseShift[t], characterPreShift[t]);
    }

    DVVERIFY(file->Read(&kerningPairCount, 4) == 4);
    for (int32 k = 0; k < tableLenght; ++k)
        kerningTable[k] = 0;

    for (int32 kp = 0; kp < kerningPairCount; ++kp)
    {
        unsigned short s1short;
        DVVERIFY(file->Read(&s1short, 2) == 2);
        unsigned short s2short;
        DVVERIFY(file->Read(&s2short, 2) == 2);
        float32 shift;
        DVVERIFY(file->Read(&shift, 4) == 4);

        KerningPair * p = new KerningPair();
        p->ch1Index = s1short;
        p->ch2Index = s2short;
        p->shift = shift;
        AddKerningPair(p);
        //file->Read(&kerningTable[s1][s2], 4, 1, fontFP);
    }

//	for (int32 t = 0; t < tableLenght; ++t)
//	{
//		//Logger::Debug("char check: %c idx: %d",  characterTable[t], t);
//	}


    SafeRelease(file);
    return true;
}