const uint32_t MAX_ITEM_AREA( MAX_ITEM_SIZE*MAX_ITEM_SIZE );
}
-ImageAtlasManager::ImageAtlasManager( Shader shader, const std::string& textureUniformName )
-: mShader( shader ),
- mTextureUniformName( textureUniformName ),
- mBrokenImageUrl( "" )
+ImageAtlasManager::ImageAtlasManager()
+: mBrokenImageUrl( "" )
{
}
{
}
-Material ImageAtlasManager::Add( Vector4& textureRect,
+TextureSet ImageAtlasManager::Add( Vector4& textureRect,
const std::string& url,
ImageDimensions size,
FittingMode::Type fittingMode,
|| dimensions.GetWidth()>DEFAULT_ATLAS_SIZE
|| dimensions.GetHeight()>DEFAULT_ATLAS_SIZE)
{
- return Material();
+ return TextureSet();
}
unsigned int i = 0;
{
if( (*iter).Upload( textureRect, url, size, fittingMode, orientationCorrection ) )
{
- return mMaterialList[i];
+ return mTextureSetList[i];
}
i++;
}
- Toolkit::ImageAtlas newAtlas = Toolkit::ImageAtlas::New( DEFAULT_ATLAS_SIZE, DEFAULT_ATLAS_SIZE );
- if( !mBrokenImageUrl.empty() )
+ CreateNewAtlas();
+ mAtlasList.back().Upload( textureRect, url, size, fittingMode, orientationCorrection );
+ return mTextureSetList.back();
+}
+
+TextureSet ImageAtlasManager::Add( Vector4& textureRect,
+ PixelDataPtr pixelData )
+{
+
+ // big buffer, atlasing is not applied
+ if( static_cast<uint32_t>(pixelData->GetWidth()) * static_cast<uint32_t>(pixelData->GetHeight()) > MAX_ITEM_AREA
+ || pixelData->GetWidth()>DEFAULT_ATLAS_SIZE
+ || pixelData->GetHeight()>DEFAULT_ATLAS_SIZE )
{
- newAtlas.SetBrokenImage( mBrokenImageUrl );
+ return TextureSet();
}
- mAtlasList.push_back( newAtlas );
- Material newMaterial = Material::New( mShader );
- newMaterial.AddTexture( newAtlas.GetAtlas(), mTextureUniformName );
- mMaterialList.push_back( newMaterial );
- newAtlas.Upload( textureRect, url, size, fittingMode, orientationCorrection );
+ unsigned int i = 0;
+ for( AtlasContainer::iterator iter = mAtlasList.begin(); iter != mAtlasList.end(); ++iter)
+ {
+ if( (*iter).Upload( textureRect, pixelData ) )
+ {
+ return mTextureSetList[i];
+ }
+ i++;
+ }
+
+ CreateNewAtlas();
+ mAtlasList.back().Upload( textureRect, pixelData );
+ return mTextureSetList.back();
- return newMaterial;
}
-void ImageAtlasManager::Remove( Material material, const Vector4& textureRect )
+void ImageAtlasManager::Remove( TextureSet textureSet, const Vector4& textureRect )
{
unsigned int i = 0;
- for( MaterialContainer::iterator iter = mMaterialList.begin(); iter != mMaterialList.end(); ++iter)
+ for( TextureSetContainer::iterator iter = mTextureSetList.begin(); iter != mTextureSetList.end(); ++iter)
{
- if( (*iter) == material )
+ if( (*iter) == textureSet )
{
mAtlasList[i].Remove(textureRect);
return;
}
}
+void ImageAtlasManager::CreateNewAtlas()
+{
+ Toolkit::ImageAtlas newAtlas = Toolkit::ImageAtlas::New( DEFAULT_ATLAS_SIZE, DEFAULT_ATLAS_SIZE );
+ if( !mBrokenImageUrl.empty() )
+ {
+ newAtlas.SetBrokenImage( mBrokenImageUrl );
+ }
+ mAtlasList.push_back( newAtlas );
+ TextureSet textureSet = TextureSet::New();
+ textureSet.SetImage( 0u, newAtlas.GetAtlas() );
+ mTextureSetList.push_back( textureSet );
+}
+
} // namespace Internal
} // namespace Toolkit