X-Git-Url: http://review.tizen.org/git/?p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git;a=blobdiff_plain;f=dali-toolkit%2Finternal%2Fvisuals%2Ftexture-manager-impl.cpp;h=a2381e84e54761142eee055350554339219b9e28;hp=e55fd9047ae2311c6bd492e6eba7f30aa35ff51b;hb=787daa34be8ea18f1066045cf922254fe32777c8;hpb=7b3868bc2f2ecb7ecc030e92d47d64b3057ca8f8 diff --git a/dali-toolkit/internal/visuals/texture-manager-impl.cpp b/dali-toolkit/internal/visuals/texture-manager-impl.cpp index e55fd90..a2381e8 100644 --- a/dali-toolkit/internal/visuals/texture-manager-impl.cpp +++ b/dali-toolkit/internal/visuals/texture-manager-impl.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019 Samsung Electronics Co., Ltd. + * Copyright (c) 2020 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. @@ -146,7 +146,7 @@ TextureManager::~TextureManager() TextureSet TextureManager::LoadTexture( const VisualUrl& url, Dali::ImageDimensions desiredSize, Dali::FittingMode::Type fittingMode, - Dali::SamplingMode::Type samplingMode, const MaskingDataPointer& maskInfo, + Dali::SamplingMode::Type samplingMode, MaskingDataPointer& maskInfo, bool synchronousLoading, TextureManager::TextureId& textureId, Vector4& textureRect, Dali::ImageDimensions& textureRectSize, bool& atlasingStatus, bool& loadingStatus, Dali::WrapMode::Type wrapModeU, Dali::WrapMode::Type wrapModeV, TextureUploadObserver* textureObserver, @@ -182,6 +182,15 @@ TextureSet TextureManager::LoadTexture( { Devel::PixelBuffer pixelBuffer = LoadImageFromFile( url.GetUrl(), desiredSize, fittingMode, samplingMode, orientationCorrection ); + if( maskInfo ) + { + Devel::PixelBuffer maskPixelBuffer = LoadImageFromFile( maskInfo->mAlphaMaskUrl.GetUrl(), ImageDimensions(), + FittingMode::SCALE_TO_FILL, SamplingMode::NO_FILTER, true ); + if( maskPixelBuffer ) + { + pixelBuffer.ApplyMask( maskPixelBuffer, maskInfo->mContentScaleFactor, maskInfo->mCropToMask ); + } + } if( pixelBuffer ) { PreMultiply( pixelBuffer, preMultiplyOnLoad ); @@ -243,6 +252,7 @@ TextureSet TextureManager::LoadTexture( } else { + maskInfo->mAlphaMaskId = RequestMaskLoad( maskInfo->mAlphaMaskUrl ); textureId = RequestLoad( url, maskInfo->mAlphaMaskId, maskInfo->mContentScaleFactor, @@ -367,6 +377,10 @@ TextureManager::TextureId TextureManager::RequestLoadInternal( ++( mTextureInfoContainer[ cacheIndex ].referenceCount ); } textureId = mTextureInfoContainer[ cacheIndex ].textureId; + + // Update preMultiplyOnLoad value. It should be changed according to preMultiplied value of the cached info. + preMultiplyOnLoad = mTextureInfoContainer[ cacheIndex ].preMultiplied ? TextureManager::MultiplyOnLoad::MULTIPLY_ON_LOAD : TextureManager::MultiplyOnLoad::LOAD_WITHOUT_MULTIPLY; + DALI_LOG_INFO( gTextureManagerLogFilter, Debug::General, "TextureManager::RequestLoad( url=%s observer=%p ) Using cached texture id@%d, textureId=%d\n", url.GetUrl().c_str(), observer, cacheIndex, textureId ); } @@ -703,7 +717,8 @@ void TextureManager::LoadTexture( TextureInfo& textureInfo, TextureUploadObserve { auto& loadersContainer = textureInfo.url.IsLocalResource() ? mAsyncLocalLoaders : mAsyncRemoteLoaders; auto loadingHelperIt = loadersContainer.GetNext(); - auto premultiplyOnLoad = textureInfo.preMultiplyOnLoad? DevelAsyncImageLoader::PreMultiplyOnLoad::ON : DevelAsyncImageLoader::PreMultiplyOnLoad::OFF; + auto premultiplyOnLoad = ( textureInfo.preMultiplyOnLoad && textureInfo.maskTextureId == INVALID_TEXTURE_ID ) ? + DevelAsyncImageLoader::PreMultiplyOnLoad::ON : DevelAsyncImageLoader::PreMultiplyOnLoad::OFF; DALI_ASSERT_ALWAYS(loadingHelperIt != loadersContainer.End()); loadingHelperIt->Load(textureInfo.textureId, textureInfo.url, textureInfo.desiredSize, textureInfo.fittingMode, @@ -750,7 +765,7 @@ void TextureManager::ObserveTexture( TextureInfo& textureInfo, } void TextureManager::AsyncLoadComplete( AsyncLoadingInfoContainerType& loadingContainer, uint32_t id, - Devel::PixelBuffer pixelBuffer, bool isMaskTask ) + Devel::PixelBuffer pixelBuffer ) { DALI_LOG_INFO( gTextureManagerLogFilter, Debug::Concise, "TextureManager::AsyncLoadComplete( id:%d )\n", id ); @@ -771,10 +786,6 @@ void TextureManager::AsyncLoadComplete( AsyncLoadingInfoContainerType& loadingCo if( textureInfo.loadState != CANCELLED ) { - if( isMaskTask ) - { - textureInfo.loadState = MASK_APPLIED; - } // textureInfo can be invalidated after this call (as the mTextureInfoContainer may be modified) PostLoad( textureInfo, pixelBuffer ); } @@ -804,8 +815,9 @@ void TextureManager::PostLoad( TextureInfo& textureInfo, Devel::PixelBuffer& pix // wait for the mask to finish loading. if( textureInfo.maskTextureId != INVALID_TEXTURE_ID ) { - if( textureInfo.loadState == MASK_APPLIED ) + if( textureInfo.loadState == MASK_APPLYING ) { + textureInfo.loadState = MASK_APPLIED; UploadTexture( pixelBuffer, textureInfo ); NotifyObservers( textureInfo, true ); } @@ -892,8 +904,9 @@ void TextureManager::ApplyMask( TextureInfo& textureInfo, TextureId maskTextureI textureInfo.loadState = MASK_APPLYING; auto& loadersContainer = textureInfo.url.IsLocalResource() ? mAsyncLocalLoaders : mAsyncRemoteLoaders; auto loadingHelperIt = loadersContainer.GetNext(); + auto premultiplyOnLoad = textureInfo.preMultiplyOnLoad ? DevelAsyncImageLoader::PreMultiplyOnLoad::ON : DevelAsyncImageLoader::PreMultiplyOnLoad::OFF; DALI_ASSERT_ALWAYS(loadingHelperIt != loadersContainer.End()); - loadingHelperIt->ApplyMask( textureInfo.textureId, pixelBuffer, maskPixelBuffer, textureInfo.scaleFactor, textureInfo.cropToMask ); + loadingHelperIt->ApplyMask( textureInfo.textureId, pixelBuffer, maskPixelBuffer, textureInfo.scaleFactor, textureInfo.cropToMask, premultiplyOnLoad ); } } @@ -1154,13 +1167,14 @@ void TextureManager::AsyncLoadingHelper::Load(TextureId textureId, } void TextureManager::AsyncLoadingHelper::ApplyMask( TextureId textureId, - Devel::PixelBuffer pixelBuffer, - Devel::PixelBuffer maskPixelBuffer, - float contentScale, - bool cropToMask ) + Devel::PixelBuffer pixelBuffer, + Devel::PixelBuffer maskPixelBuffer, + float contentScale, + bool cropToMask, + DevelAsyncImageLoader::PreMultiplyOnLoad preMultiplyOnLoad ) { mLoadingInfoContainer.push_back(AsyncLoadingInfo(textureId)); - auto id = DevelAsyncImageLoader::ApplyMask( mLoader, pixelBuffer, maskPixelBuffer, contentScale, cropToMask ); + auto id = DevelAsyncImageLoader::ApplyMask( mLoader, pixelBuffer, maskPixelBuffer, contentScale, cropToMask, preMultiplyOnLoad ); mLoadingInfoContainer.back().loadId = id; } @@ -1182,10 +1196,9 @@ TextureManager::AsyncLoadingHelper::AsyncLoadingHelper( } void TextureManager::AsyncLoadingHelper::AsyncLoadComplete(uint32_t id, - Devel::PixelBuffer pixelBuffer, - bool isMaskTask) + Devel::PixelBuffer pixelBuffer ) { - mTextureManager.AsyncLoadComplete(mLoadingInfoContainer, id, pixelBuffer, isMaskTask); + mTextureManager.AsyncLoadComplete( mLoadingInfoContainer, id, pixelBuffer ); } void TextureManager::SetBrokenImageUrl(const std::string& brokenImageUrl)