X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;ds=sidebyside;f=dali%2Finternal%2Fevent%2Fimages%2Fatlas-impl.cpp;h=97ab217c3d05e9e7ca83193b3cb4e0f9e816a4ff;hb=ff364987bf3c2ef5bb2b57348747eeb784d8ba90;hp=d84c3b5aa99ae50b8f353f2c8720b52af3bd747c;hpb=e840e65577af79cdd96b216dd738ff6b874bfa0b;p=platform%2Fcore%2Fuifw%2Fdali-core.git diff --git a/dali/internal/event/images/atlas-impl.cpp b/dali/internal/event/images/atlas-impl.cpp index d84c3b5..97ab217 100644 --- a/dali/internal/event/images/atlas-impl.cpp +++ b/dali/internal/event/images/atlas-impl.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015 Samsung Electronics Co., Ltd. + * Copyright (c) 2016 Samsung Electronics Co., Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -25,6 +25,7 @@ #include #include #include +#include #include #include #include @@ -61,9 +62,7 @@ bool Atlas::Upload( BufferImage& bufferImage, { bool uploadSuccess( false ); - if( Compatible(bufferImage.GetPixelFormat(), - xOffset + bufferImage.GetWidth(), - yOffset + bufferImage.GetHeight() ) ) + if( IsInside( xOffset + bufferImage.GetWidth(), yOffset + bufferImage.GetHeight() ) ) { AllocateAtlas(); ResourceId destId = GetResourceId(); @@ -86,7 +85,7 @@ bool Atlas::Upload( const std::string& url, Integration::BitmapPtr bitmap = LoadBitmap( url ); - if( bitmap && Compatible(bitmap->GetPixelFormat(), xOffset + bitmap->GetImageWidth(), yOffset + bitmap->GetImageHeight()) ) + if( bitmap && IsInside( xOffset + bitmap->GetImageWidth(), yOffset + bitmap->GetImageHeight()) ) { AllocateAtlas(); ResourceId destId = GetResourceId(); @@ -104,6 +103,26 @@ bool Atlas::Upload( const std::string& url, return uploadSuccess; } +bool Atlas::Upload( PixelDataPtr pixelData, + SizeType xOffset, + SizeType yOffset ) +{ + bool uploadSuccess( false ); + if( IsInside( xOffset + pixelData->GetWidth(), yOffset + pixelData->GetHeight() ) ) + { + AllocateAtlas(); + ResourceId destId = GetResourceId(); + + if( destId ) + { + mResourceClient.UploadBitmap( destId, pixelData, xOffset, yOffset ); + uploadSuccess = true; + } + } + + return uploadSuccess; +} + void Atlas::RecoverFromContextLoss() { ResourceId destId = GetResourceId(); @@ -163,37 +182,24 @@ void Atlas::Disconnect() { --mConnectionCount; - if ( Dali::Image::UNUSED == mReleasePolicy && - mConnectionCount == 0 ) - { - ReleaseAtlas(); - } + // Only release the atlas upon destruction } } -bool Atlas::Compatible( Pixel::Format pixelFormat, - SizeType x, - SizeType y ) +bool Atlas::IsInside( SizeType x, SizeType y ) { - bool Compatible(false); + bool fit(false); - if( mPixelFormat != pixelFormat ) + if( x <= mWidth && y <= mHeight ) { - DALI_LOG_ERROR( "Pixel format %d does not match Atlas format %d\n", pixelFormat, mPixelFormat ); + fit = true; } else { - if( x <= mWidth && y <= mHeight ) - { - Compatible = true; - } - else - { - DALI_LOG_ERROR( "image does not fit within the atlas \n" ); - } + DALI_LOG_ERROR( "image does not fit within the atlas \n" ); } - return Compatible; + return fit; } void Atlas::AllocateAtlas() @@ -256,12 +262,10 @@ void Atlas::ClearBackground(const Vector4& color ) } } - RectArea area; - imageData->Update(area); - mClearColor = color; mClear = true; - mResourceClient.UploadBitmap( destId, imageData->GetResourceId(), 0, 0 ); + + imageData->UploadBitmap( destId, 0, 0 ); } }