// Check to see if the atlas is large enough to hold a single block even ?
if ( blockWidth > width || blockHeight > height )
{
- DALI_LOG_ERROR("Atlas %i x %i too small. Dimensions need to be at least %i x %i\n",
+ DALI_LOG_ERROR("Atlas %i x %i too small. Dimensions need to be at least %ix%i\n",
width, height, blockWidth, blockHeight );
return 0;
}
}
}
-void AtlasManager::SetAtlasSize( const Vector2& size,
- const Vector2& blockSize )
+void AtlasManager::SetNewAtlasSize( const Vector2& size,
+ const Vector2& blockSize )
{
mNewAtlasSize = size;
mNewBlockSize = blockSize;
}
}
+Vector2 AtlasManager::GetAtlasSize( AtlasId atlas )
+{
+ if ( atlas && atlas <= mAtlasList.size() )
+ {
+ return Vector2( static_cast< float >( mAtlasList[ atlas - 1u ].mWidth ),
+ static_cast< float >( mAtlasList[ atlas - 1u ].mHeight ) );
+ }
+ else
+ {
+ return Vector2( 0.0f, 0.0f );
+ }
+}
+
AtlasManager::SizeType AtlasManager::GetFreeBlocks( AtlasId atlas ) const
{
if ( atlas && atlas <= mAtlasList.size() )
uint32_t blockWidth = mAtlasList[ index ].mBlockWidth;
uint32_t blockHeight = mAtlasList[ index ].mBlockHeight;
- //Work out how many blocks wide and high our bitmap is in the atlas' block size
SizeType widthInBlocks = width / blockWidth;
- if ( width % blockWidth )
- {
- widthInBlocks++;
- }
SizeType heightInBlocks = height / blockHeight;
- if ( height % blockHeight )
- {
- heightInBlocks++;
- }
-
uint32_t blockCount = widthInBlocks * heightInBlocks;
// Check free previously unallocated blocks and any free blocks
return mAtlasList[ atlas -1u ].mPixelFormat;
}
+void AtlasManager::GetMetrics( Toolkit::AtlasManager::Metrics& metrics )
+{
+ Toolkit::AtlasManager::AtlasMetricsEntry entry;
+ uint32_t textureMemoryUsed = 0;
+ uint32_t atlasCount = mAtlasList.size();
+ metrics.mAtlasCount = atlasCount;
+ metrics.mAtlasMetrics.Resize(0);
+
+ for ( uint32_t i = 0; i < atlasCount; ++i )
+ {
+ SizeType width = mAtlasList[ i ].mWidth;
+ SizeType height = mAtlasList[ i ].mHeight;
+ SizeType blockWidth = mAtlasList[ i ].mBlockWidth;
+ SizeType blockHeight = mAtlasList[ i ].mBlockHeight;
+
+ entry.mWidth = width;
+ entry.mHeight = height;
+ entry.mBlockWidth = blockWidth;
+ entry.mBlockHeight = blockHeight;
+ entry.mTotalBlocks = ( width / blockWidth ) * ( height / blockHeight );
+ entry.mBlocksUsed = mAtlasList[ i ].mNextFreeBlock ? mAtlasList[ i ].mNextFreeBlock : entry.mTotalBlocks - mAtlasList[ i ].mFreeBlocksList.Size();
+ entry.mPixelFormat = GetPixelFormat( i + 1 );
+
+ metrics.mAtlasMetrics.PushBack( entry );
+
+ uint32_t size = width * height;
+ if ( entry.mPixelFormat == Pixel::BGRA8888 )
+ {
+ size <<= 2;
+ }
+
+ textureMemoryUsed += size;
+
+ }
+ metrics.mTextureMemoryUsed = textureMemoryUsed;
+}
+
} // namespace Internal