//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//
MLRTexture*
MLRTexturePool::Add(GOSImage* image)
{
    MString textureName;
    textureName = image->GetName();
    int32_t i, j, textureNameHashValue = textureName.GetHashValue();
    for(i = 0; i < lastHandle; i++)
    {
        int32_t first = i << instanceDepth;
        for(j = first; j < first + instanceMax; j++)
        {
            if(textureArray[j] &&
                    textureArray[j]->textureNameHashValue == textureNameHashValue)
            {
                Verify(image == textureArray[j]->GetImage());
                return textureArray[j];
//				STOP(("Image allready in texture pool !"));
            }
        }
    }
    int32_t newHandle;
    gos_PushCurrentHeap(Heap);
    if(firstFreeHandle < lastFreeHandle)
    {
        newHandle = (freeHandle[firstFreeHandle & (handleMax - 1)]) << instanceDepth;
        textureArray[newHandle] =
            new MLRTexture(
            this,
            image,
            newHandle + 1
        );
        storedTextures++;
        firstFreeHandle++;
    }
    else
    {
        Verify(((lastHandle << instanceDepth) + 1) < MLRState::TextureMask);
        newHandle = lastHandle << instanceDepth;
        textureArray[newHandle] =
            new MLRTexture(
            this,
            image,
            newHandle + 1
        );
        storedTextures++;
        lastHandle++;
    }
    Register_Object(textureArray[newHandle]);
    gos_PopCurrentHeap();
    return textureArray[newHandle];
}
Example #2
0
IteratorPosition
GetHashFunctions::GetHashValue(const MString& value)
{
	return value.GetHashValue();
}