X-Git-Url: http://review.tizen.org/git/?p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git;a=blobdiff_plain;f=dali-toolkit%2Finternal%2Fatlas-manager%2Fatlas-manager-impl.cpp;h=9ef43a9d67a9a7a8e2d4fb13e1ae8194f7035f56;hp=4a55e5937f9afacf4bc43faf33ae6221a0dd1ad0;hb=5823a096131e0d581ca2a070f5da23bd7fc47337;hpb=5f6befa398f1c68fcc8edff409a086f54af4d5f9 diff --git a/dali-toolkit/internal/atlas-manager/atlas-manager-impl.cpp b/dali-toolkit/internal/atlas-manager/atlas-manager-impl.cpp index 4a55e59..9ef43a9 100644 --- a/dali-toolkit/internal/atlas-manager/atlas-manager-impl.cpp +++ b/dali-toolkit/internal/atlas-manager/atlas-manager-impl.cpp @@ -20,8 +20,8 @@ // EXTERNAL INCLUDE #include #include -#include -#include +#include +#include #include namespace Dali @@ -104,10 +104,30 @@ AtlasManagerPtr AtlasManager::New() AtlasManager::~AtlasManager() { - for ( uint32_t i = 0; i < mAtlasList.size(); ++i ) + for ( SizeType i = 0; i < mAtlasList.size(); ++i ) { + mAtlasList[ i ].mAtlas.UploadedSignal().Disconnect( this, &AtlasManager::OnUpload ); delete[] mAtlasList[ i ].mStripBuffer; } + + // Are there any upload signals pending? Free up those buffer images now. + for ( SizeType i = 0; i < mUploadedImages.Size(); ++i ) + { + delete[] mUploadedImages[ i ]; + } +} + +void AtlasManager::OnUpload( Image image ) +{ + if ( mUploadedImages.Size() ) + { + delete[] mUploadedImages[ 0 ]; + mUploadedImages.Erase( mUploadedImages.Begin() ); + } + else + { + DALI_LOG_ERROR("Atlas Image Upload List should not be empty\n"); + } } Toolkit::AtlasManager::AtlasId AtlasManager::CreateAtlas( const Toolkit::AtlasManager::AtlasSize& size, Pixel::Format pixelformat ) @@ -131,9 +151,10 @@ Toolkit::AtlasManager::AtlasId AtlasManager::CreateAtlas( const Toolkit::AtlasMa atlasDescriptor.mSize = size; atlasDescriptor.mPixelFormat = pixelformat; atlasDescriptor.mNextFreeBlock = 1u; // indicate next free block will be the first ( +1 ) + atlas.UploadedSignal().Connect( this, &AtlasManager::OnUpload ); // What size do we need for this atlas' strip buffer ( assume 32bit pixel format )? - uint32_t neededStripSize =( blockWidth > blockHeight - DOUBLE_PIXEL_PADDING ? blockWidth : blockHeight - DOUBLE_PIXEL_PADDING ) << 2; + SizeType neededStripSize =( blockWidth > blockHeight - DOUBLE_PIXEL_PADDING ? blockWidth : blockHeight - DOUBLE_PIXEL_PADDING ) << 2; atlasDescriptor.mStripBuffer = new PixelBuffer[ neededStripSize ]; memset( atlasDescriptor.mStripBuffer, 0, neededStripSize ); @@ -146,11 +167,11 @@ Toolkit::AtlasManager::AtlasId AtlasManager::CreateAtlas( const Toolkit::AtlasMa SINGLE_PIXEL_PADDING, blockHeight - DOUBLE_PIXEL_PADDING, pixelformat ); + mUploadedImages.PushBack( NULL ); atlasDescriptor.mFilledPixelImage = BufferImage::New( reinterpret_cast< PixelBuffer* >( &mFilledPixel ), 1, 1, pixelformat ); atlas.Upload( atlasDescriptor.mFilledPixelImage, 0, 0 ); Sampler sampler = Sampler::New( atlas, "sTexture" ); - sampler.SetFilterMode( Sampler::NEAREST, Sampler::NEAREST ); sampler.SetProperty( Sampler::Property::AFFECTS_TRANSPARENCY, true ); Shader shader; if ( pixelformat == Pixel::BGRA8888 ) @@ -163,6 +184,7 @@ Toolkit::AtlasManager::AtlasId AtlasManager::CreateAtlas( const Toolkit::AtlasMa } atlasDescriptor.mMaterial = Material::New( shader ); atlasDescriptor.mMaterial.AddSampler( sampler ); + atlasDescriptor.mSampler = sampler; atlasDescriptor.mMaterial.SetBlendMode( BlendingMode::ON ); mAtlasList.push_back( atlasDescriptor ); return mAtlasList.size(); @@ -608,6 +630,10 @@ void AtlasManager::UploadImage( const BufferImage& image, { DALI_LOG_ERROR("Uploading image to Atlas Failed!.\n"); } + else + { + mUploadedImages.PushBack( const_cast< BufferImage& >( image ).GetBuffer() ); + } // If this is the first block then we need to keep the first pixel free for underline texture if ( block ) @@ -620,6 +646,10 @@ void AtlasManager::UploadImage( const BufferImage& image, { DALI_LOG_ERROR("Uploading top strip to Atlas Failed!\n"); } + else + { + mUploadedImages.PushBack( NULL ); + } // Blit left strip if ( !mAtlasList[ atlas ].mAtlas.Upload( mAtlasList[ atlas ].mVerticalStrip, @@ -628,6 +658,10 @@ void AtlasManager::UploadImage( const BufferImage& image, { DALI_LOG_ERROR("Uploading left strip to Atlas Failed!\n"); } + else + { + mUploadedImages.PushBack( NULL ); + } } // Blit bottom strip @@ -639,6 +673,10 @@ void AtlasManager::UploadImage( const BufferImage& image, { DALI_LOG_ERROR("Uploading bottom strip to Atlas Failed!.\n"); } + else + { + mUploadedImages.PushBack( NULL ); + } } // Blit right strip @@ -650,6 +688,10 @@ void AtlasManager::UploadImage( const BufferImage& image, { DALI_LOG_ERROR("Uploading right strip to Atlas Failed!.\n"); } + else + { + mUploadedImages.PushBack( NULL ); + } } } @@ -840,6 +882,16 @@ Material AtlasManager::GetMaterial( AtlasId atlas ) const return null; } +Sampler AtlasManager::GetSampler( AtlasId atlas ) const +{ + if ( atlas && atlas <= mAtlasList.size() ) + { + return mAtlasList[ atlas -1u ].mSampler; + } + Sampler null; + return null; +} + } // namespace Internal } // namespace Toolkit