From: Sunghyun kim Date: Mon, 13 Jan 2020 07:05:19 +0000 (+0900) Subject: Change not to use the mask if it is set to an empty path X-Git-Tag: dali_1.9.18~1^2 X-Git-Url: http://review.tizen.org/git/?p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git;a=commitdiff_plain;h=a288a8710de15241b287c9b12211459b9dc9cd21 Change not to use the mask if it is set to an empty path If an application sets an empty path to the alpha mask, unload the alpha mask. Change-Id: Id70bf53f5fc631c9d82a59472f4d05d5d276f6b9 --- diff --git a/automated-tests/src/dali-toolkit-internal/utc-Dali-TextureManager.cpp b/automated-tests/src/dali-toolkit-internal/utc-Dali-TextureManager.cpp index f2b032d..a6b7460 100644 --- a/automated-tests/src/dali-toolkit-internal/utc-Dali-TextureManager.cpp +++ b/automated-tests/src/dali-toolkit-internal/utc-Dali-TextureManager.cpp @@ -25,6 +25,7 @@ #include #include #include +#include using namespace Dali::Toolkit::Internal; @@ -204,3 +205,70 @@ int UtcTextureManagerCachingForDifferentLoadingType(void) END_TEST; } + +int UtcTextureManagerUseInvalidMask(void) +{ + ToolkitTestApplication application; + tet_infoline( "UtcTextureManagerUseInvalidMask" ); + + TextureManager textureManager; // Create new texture manager + + TestObserver observer; + std::string filename( TEST_IMAGE_FILE_NAME ); + std::string maskname(""); + TextureManager::MaskingDataPointer maskInfo = nullptr; + maskInfo.reset(new TextureManager::MaskingData()); + maskInfo->mAlphaMaskUrl = maskname; + maskInfo->mAlphaMaskId = TextureManager::INVALID_TEXTURE_ID; + maskInfo->mCropToMask = true; + maskInfo->mContentScaleFactor = 1.0f; + + auto textureId( TextureManager::INVALID_TEXTURE_ID ); + Vector4 atlasRect( 0.f, 0.f, 1.f, 1.f ); + Dali::ImageDimensions atlasRectSize( 0,0 ); + bool synchronousLoading(false); + bool atlasingStatus(false); + bool loadingStatus(false); + auto preMultiply = TextureManager::MultiplyOnLoad::LOAD_WITHOUT_MULTIPLY; + ImageAtlasManagerPtr atlasManager = nullptr; + Toolkit::AtlasUploadObserver* atlasUploadObserver = nullptr; + + textureManager.LoadTexture( + filename, + ImageDimensions(), + FittingMode::SCALE_TO_FILL, + SamplingMode::BOX_THEN_LINEAR, + maskInfo, + synchronousLoading, + textureId, + atlasRect, + atlasRectSize, + atlasingStatus, + loadingStatus, + WrapMode::DEFAULT, + WrapMode::DEFAULT, + &observer, + atlasUploadObserver, + atlasManager, + true, + TextureManager::ReloadPolicy::CACHED, + preMultiply + ); + + DALI_TEST_EQUALS( observer.mLoaded, false, TEST_LOCATION ); + DALI_TEST_EQUALS( observer.mObserverCalled, false, TEST_LOCATION ); + + application.SendNotification(); + application.Render(); + + DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1 ), true, TEST_LOCATION ); + + application.SendNotification(); + application.Render(); + + DALI_TEST_EQUALS( observer.mLoaded, true, TEST_LOCATION ); + DALI_TEST_EQUALS( observer.mObserverCalled, true, TEST_LOCATION ); + DALI_TEST_EQUALS( observer.mCompleteType, TestObserver::CompleteType::UPLOAD_COMPLETE, TEST_LOCATION ); + + END_TEST; +} diff --git a/dali-toolkit/internal/visuals/texture-manager-impl.cpp b/dali-toolkit/internal/visuals/texture-manager-impl.cpp index 0af86b3..5c694d0 100644 --- a/dali-toolkit/internal/visuals/texture-manager-impl.cpp +++ b/dali-toolkit/internal/visuals/texture-manager-impl.cpp @@ -207,7 +207,7 @@ TextureSet TextureManager::LoadTexture( { Devel::PixelBuffer pixelBuffer = LoadImageFromFile( url.GetUrl(), desiredSize, fittingMode, samplingMode, orientationCorrection ); - if( maskInfo ) + if( maskInfo && maskInfo->mAlphaMaskUrl.IsValid() ) { Devel::PixelBuffer maskPixelBuffer = LoadImageFromFile( maskInfo->mAlphaMaskUrl.GetUrl(), ImageDimensions(), FittingMode::SCALE_TO_FILL, SamplingMode::NO_FILTER, true ); @@ -269,7 +269,7 @@ TextureSet TextureManager::LoadTexture( if( !textureSet ) // big image, no atlasing or atlasing failed { atlasingStatus = false; - if( !maskInfo ) + if( !maskInfo || !maskInfo->mAlphaMaskUrl.IsValid() ) { textureId = RequestLoad( url, desiredSize, fittingMode, samplingMode, TextureManager::NO_ATLAS, textureObserver, orientationCorrection, reloadPolicy, preMultiplyOnLoad );