From 9f15024d3ea904f4d957be53bf376f132a9d9e51 Mon Sep 17 00:00:00 2001 From: Jiyun Yang Date: Mon, 14 Oct 2019 15:26:23 +0900 Subject: [PATCH] Revert "[Tizen] Fix premultiply alpha issue" This reverts commit 838563603cc78ee33dc46a245adf479e3ec8e390. --- .../image-loader/async-image-loader-devel.cpp | 5 ++--- .../devel-api/image-loader/async-image-loader-devel.h | 6 ++---- .../internal/image-loader/async-image-loader-impl.cpp | 5 ++--- .../internal/image-loader/async-image-loader-impl.h | 4 +--- .../internal/image-loader/image-load-thread.cpp | 19 +++++++------------ .../internal/image-loader/image-load-thread.h | 11 ++--------- .../internal/visuals/texture-manager-impl.cpp | 17 +++++++---------- dali-toolkit/internal/visuals/texture-manager-impl.h | 6 ++---- 8 files changed, 25 insertions(+), 48 deletions(-) diff --git a/dali-toolkit/devel-api/image-loader/async-image-loader-devel.cpp b/dali-toolkit/devel-api/image-loader/async-image-loader-devel.cpp index 5fc985f..3bd3368 100644 --- a/dali-toolkit/devel-api/image-loader/async-image-loader-devel.cpp +++ b/dali-toolkit/devel-api/image-loader/async-image-loader-devel.cpp @@ -39,10 +39,9 @@ uint32_t ApplyMask( AsyncImageLoader asyncImageLoader, Devel::PixelBuffer pixelBuffer, Devel::PixelBuffer maskPixelBuffer, float contentScale, - bool cropToMask, - DevelAsyncImageLoader::PreMultiplyOnLoad preMultiplyOnLoad ) + bool cropToMask ) { - return GetImplementation( asyncImageLoader ).ApplyMask( pixelBuffer, maskPixelBuffer, contentScale, cropToMask, preMultiplyOnLoad ); + return GetImplementation( asyncImageLoader ).ApplyMask( pixelBuffer, maskPixelBuffer, contentScale, cropToMask ); } PixelBufferLoadedSignalType& PixelBufferLoadedSignal( AsyncImageLoader asyncImageLoader ) diff --git a/dali-toolkit/devel-api/image-loader/async-image-loader-devel.h b/dali-toolkit/devel-api/image-loader/async-image-loader-devel.h index 99ca154..681c00b 100644 --- a/dali-toolkit/devel-api/image-loader/async-image-loader-devel.h +++ b/dali-toolkit/devel-api/image-loader/async-image-loader-devel.h @@ -49,7 +49,7 @@ enum class PreMultiplyOnLoad * @param[in] fittingMode The method used to fit the shape of the image before loading to the shape defined by the size parameter * @param[in] samplingMode The filtering method used when sampling pixels from the input image while fitting it to desired size * @param[in] orientationCorrection Reorient the image to respect any orientation metadata in its header - * @param[in] preMultiplyOnLoad ON if the image color should be multiplied by it's alpha. Set to OFF if there is no alpha or if the image need to be applied alpha mask. + * @param[in] preMultiplyOnLoad ON if the image color should be multiplied by it's alpha. Set to OFF if there is no alpha * @return The loading task id */ DALI_TOOLKIT_API uint32_t Load( AsyncImageLoader asyncImageLoader, @@ -69,15 +69,13 @@ DALI_TOOLKIT_API uint32_t Load( AsyncImageLoader asyncImageLoader, * @param[in] maskPixelBuffer Pointer to raw masking data * @param[in] contentScale The factor to scale the content * @param[in] cropToMask Whether to crop the content to the mask size - * @param[in] preMultiplyOnLoad ON if the image color should be multiplied by it's alpha. Set to OFF if there is no alpha. * @return The masking task id */ DALI_TOOLKIT_API uint32_t ApplyMask( AsyncImageLoader asyncImageLoader, Devel::PixelBuffer pixelBuffer, Devel::PixelBuffer maskPixelBuffer, float contentScale, - bool cropToMask, - DevelAsyncImageLoader::PreMultiplyOnLoad preMultiplyOnLoad ); + bool cropToMask ); /** * Connect to this signal if you want to load a PixelBuffer instead of a PixelData. diff --git a/dali-toolkit/internal/image-loader/async-image-loader-impl.cpp b/dali-toolkit/internal/image-loader/async-image-loader-impl.cpp index f08b147..de0ee3f 100644 --- a/dali-toolkit/internal/image-loader/async-image-loader-impl.cpp +++ b/dali-toolkit/internal/image-loader/async-image-loader-impl.cpp @@ -69,15 +69,14 @@ uint32_t AsyncImageLoader::Load( const VisualUrl& url, uint32_t AsyncImageLoader::ApplyMask( Devel::PixelBuffer pixelBuffer, Devel::PixelBuffer maskPixelBuffer, float contentScale, - bool cropToMask, - DevelAsyncImageLoader::PreMultiplyOnLoad preMultiplyOnLoad) + bool cropToMask ) { if( !mIsLoadThreadStarted ) { mLoadThread.Start(); mIsLoadThreadStarted = true; } - mLoadThread.AddTask( new LoadingTask( ++mLoadTaskId, pixelBuffer, maskPixelBuffer, contentScale, cropToMask, preMultiplyOnLoad ) ); + mLoadThread.AddTask( new LoadingTask( ++mLoadTaskId, pixelBuffer, maskPixelBuffer, contentScale, cropToMask ) ); return mLoadTaskId; } diff --git a/dali-toolkit/internal/image-loader/async-image-loader-impl.h b/dali-toolkit/internal/image-loader/async-image-loader-impl.h index a97088d..69a7617 100644 --- a/dali-toolkit/internal/image-loader/async-image-loader-impl.h +++ b/dali-toolkit/internal/image-loader/async-image-loader-impl.h @@ -65,14 +65,12 @@ public: * @param[in] maskPixelBuffer of the mask image * @param[in] contentScale The factor to scale the content * @param[in] cropToMask Whether to crop the content to the mask size - * @param[in] preMultiplyOnLoad ON if the image color should be multiplied by it's alpha. Set to OFF if there is no alpha. * @return The loading task id */ uint32_t ApplyMask( Devel::PixelBuffer pixelBuffer, Devel::PixelBuffer maskPixelBuffer, float contentScale, - bool cropToMask, - DevelAsyncImageLoader::PreMultiplyOnLoad preMultiplyOnLoad ); + bool cropToMask ); /** * @copydoc Toolkit::AsyncImageLoader::ImageLoadedSignal diff --git a/dali-toolkit/internal/image-loader/image-load-thread.cpp b/dali-toolkit/internal/image-loader/image-load-thread.cpp index 29a5dff..f687af6 100644 --- a/dali-toolkit/internal/image-loader/image-load-thread.cpp +++ b/dali-toolkit/internal/image-loader/image-load-thread.cpp @@ -49,8 +49,7 @@ LoadingTask::LoadingTask( uint32_t id, const VisualUrl& url, ImageDimensions dim { } -LoadingTask::LoadingTask( uint32_t id, Devel::PixelBuffer pixelBuffer, Devel::PixelBuffer maskPixelBuffer, float contentScale, bool cropToMask, - DevelAsyncImageLoader::PreMultiplyOnLoad preMultiplyOnLoad ) +LoadingTask::LoadingTask( uint32_t id, Devel::PixelBuffer pixelBuffer, Devel::PixelBuffer maskPixelBuffer, float contentScale, bool cropToMask ) : pixelBuffer( pixelBuffer ), url( "" ), id( id ), @@ -58,7 +57,7 @@ LoadingTask::LoadingTask( uint32_t id, Devel::PixelBuffer pixelBuffer, Devel::Pi fittingMode(), samplingMode(), orientationCorrection(), - preMultiplyOnLoad( preMultiplyOnLoad ), + preMultiplyOnLoad(), isMaskTask( true ), maskPixelBuffer( maskPixelBuffer ), contentScale( contentScale ), @@ -76,15 +75,7 @@ void LoadingTask::Load() { pixelBuffer = Dali::DownloadImageSynchronously ( url.GetUrl(), dimensions, fittingMode, samplingMode, orientationCorrection ); } -} - -void LoadingTask::ApplyMask() -{ - pixelBuffer.ApplyMask( maskPixelBuffer, contentScale, cropToMask ); -} -void LoadingTask::MultiplyAlpha() -{ if( pixelBuffer && Pixel::HasAlpha( pixelBuffer.GetPixelFormat() ) ) { if( preMultiplyOnLoad == DevelAsyncImageLoader::PreMultiplyOnLoad::ON ) @@ -94,6 +85,11 @@ void LoadingTask::MultiplyAlpha() } } +void LoadingTask::ApplyMask() +{ + pixelBuffer.ApplyMask( maskPixelBuffer, contentScale, cropToMask ); +} + ImageLoadThread::ImageLoadThread( EventThreadCallback* trigger ) : mTrigger( trigger ), mLogFactory( Dali::Adaptor::Get().GetLogFactory() ) @@ -125,7 +121,6 @@ void ImageLoadThread::Run() { task->ApplyMask(); } - task->MultiplyAlpha(); AddCompletedTask( task ); } diff --git a/dali-toolkit/internal/image-loader/image-load-thread.h b/dali-toolkit/internal/image-loader/image-load-thread.h index 2edd97a..cd6bd32 100644 --- a/dali-toolkit/internal/image-loader/image-load-thread.h +++ b/dali-toolkit/internal/image-loader/image-load-thread.h @@ -52,7 +52,7 @@ struct LoadingTask * @param [in] fittingMode The method used to fit the shape of the image before loading to the shape defined by the size parameter. * @param [in] samplingMode The filtering method used when sampling pixels from the input image while fitting it to desired size. * @param [in] orientationCorrection Reorient the image to respect any orientation metadata in its header. - * @param [in] preMultiplyOnLoad ON if the image's color should be multiplied by it's alpha. Set to OFF if there is no alpha or if the image need to be applied alpha mask. + * @param [in] preMultiplyOnLoad ON if the image's color should be multiplied by it's alpha. */ LoadingTask( uint32_t id, const VisualUrl& url, @@ -69,14 +69,12 @@ struct LoadingTask * @param [in] maskPixelBuffer of the mask image * @param [in] contentScale The factor to scale the content * @param [in] cropToMask Whether to crop the content to the mask size - * @param [in] preMultiplyOnLoad ON if the image's color should be multiplied by it's alpha. Set to OFF if there is no alpha. */ LoadingTask( uint32_t id, Devel::PixelBuffer pixelBuffer, Devel::PixelBuffer maskPixelBuffer, float contentScale, - bool cropToMask, - DevelAsyncImageLoader::PreMultiplyOnLoad preMultiplyOnLoad); + bool cropToMask ); /** * Load the image @@ -88,11 +86,6 @@ struct LoadingTask */ void ApplyMask(); - /** - * Multiply alpha - */ - void MultiplyAlpha(); - private: // Undefined diff --git a/dali-toolkit/internal/visuals/texture-manager-impl.cpp b/dali-toolkit/internal/visuals/texture-manager-impl.cpp index 7168a50..9a06862 100644 --- a/dali-toolkit/internal/visuals/texture-manager-impl.cpp +++ b/dali-toolkit/internal/visuals/texture-manager-impl.cpp @@ -703,8 +703,7 @@ void TextureManager::LoadTexture( TextureInfo& textureInfo, TextureUploadObserve { auto& loadersContainer = textureInfo.url.IsLocalResource() ? mAsyncLocalLoaders : mAsyncRemoteLoaders; auto loadingHelperIt = loadersContainer.GetNext(); - auto premultiplyOnLoad = ( textureInfo.preMultiplyOnLoad && textureInfo.maskTextureId == INVALID_TEXTURE_ID ) ? - DevelAsyncImageLoader::PreMultiplyOnLoad::ON : DevelAsyncImageLoader::PreMultiplyOnLoad::OFF; + auto premultiplyOnLoad = textureInfo.preMultiplyOnLoad? DevelAsyncImageLoader::PreMultiplyOnLoad::ON : DevelAsyncImageLoader::PreMultiplyOnLoad::OFF; DALI_ASSERT_ALWAYS(loadingHelperIt != loadersContainer.End()); loadingHelperIt->Load(textureInfo.textureId, textureInfo.url, textureInfo.desiredSize, textureInfo.fittingMode, @@ -890,9 +889,8 @@ 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, premultiplyOnLoad ); + loadingHelperIt->ApplyMask( textureInfo.textureId, pixelBuffer, maskPixelBuffer, textureInfo.scaleFactor, textureInfo.cropToMask ); } } @@ -1153,14 +1151,13 @@ void TextureManager::AsyncLoadingHelper::Load(TextureId textureId, } void TextureManager::AsyncLoadingHelper::ApplyMask( TextureId textureId, - Devel::PixelBuffer pixelBuffer, - Devel::PixelBuffer maskPixelBuffer, - float contentScale, - bool cropToMask, - DevelAsyncImageLoader::PreMultiplyOnLoad preMultiplyOnLoad ) + Devel::PixelBuffer pixelBuffer, + Devel::PixelBuffer maskPixelBuffer, + float contentScale, + bool cropToMask ) { mLoadingInfoContainer.push_back(AsyncLoadingInfo(textureId)); - auto id = DevelAsyncImageLoader::ApplyMask( mLoader, pixelBuffer, maskPixelBuffer, contentScale, cropToMask, preMultiplyOnLoad ); + auto id = DevelAsyncImageLoader::ApplyMask( mLoader, pixelBuffer, maskPixelBuffer, contentScale, cropToMask ); mLoadingInfoContainer.back().loadId = id; } diff --git a/dali-toolkit/internal/visuals/texture-manager-impl.h b/dali-toolkit/internal/visuals/texture-manager-impl.h index b782517..ca899fd 100755 --- a/dali-toolkit/internal/visuals/texture-manager-impl.h +++ b/dali-toolkit/internal/visuals/texture-manager-impl.h @@ -712,7 +712,7 @@ private: * @param[in] samplingMode The SamplingMode to use * @param[in] orientationCorrection Whether to use image metadata to rotate or flip the image, * e.g., from portrait to landscape - * @param[in] preMultiplyOnLoad if the image's color should be multiplied by it's alpha. Set to OFF if there is no alpha or if the image need to be applied alpha mask. + * @param[in] preMultiplyOnLoad if the image's color should be multiplied by it's alpha. */ void Load(TextureId textureId, const VisualUrl& url, @@ -729,14 +729,12 @@ private: * @param [in] maskPixelBuffer of the mask image * @param [in] contentScale The factor to scale the content * @param [in] cropToMask Whether to crop the content to the mask size - * @param [in] preMultiplyOnLoad if the image's color should be multiplied by it's alpha. Set to OFF if there is no alpha. */ void ApplyMask( TextureId textureId, Devel::PixelBuffer pixelBuffer, Devel::PixelBuffer maskPixelBuffer, float contentScale, - bool cropToMask, - DevelAsyncImageLoader::PreMultiplyOnLoad preMultiplyOnLoad ); + bool cropToMask ); public: AsyncLoadingHelper(const AsyncLoadingHelper&) = delete; -- 2.7.4