- Revert Adaptor patch "Multiply the Alpha of mask to the premultiplied image/I60c056460537db604566f080302be09a6f88d047"
- Force to premultiply alpha after apply alpha mask if there is alpha mask.
Change-Id: I25c8c6a20dcbd39656d195abbff6ca6b4d18a008
Signed-off-by: Seungho, Baek <sbsh.baek@samsung.com>
Devel::PixelBuffer pixelBuffer,
Devel::PixelBuffer maskPixelBuffer,
float contentScale,
- bool cropToMask )
+ bool cropToMask,
+ DevelAsyncImageLoader::PreMultiplyOnLoad preMultiplyOnLoad )
{
- return GetImplementation( asyncImageLoader ).ApplyMask( pixelBuffer, maskPixelBuffer, contentScale, cropToMask );
+ return GetImplementation( asyncImageLoader ).ApplyMask( pixelBuffer, maskPixelBuffer, contentScale, cropToMask, preMultiplyOnLoad );
}
PixelBufferLoadedSignalType& PixelBufferLoadedSignal( AsyncImageLoader asyncImageLoader )
* @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
+ * @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.
* @return The loading task id
*/
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 );
+ bool cropToMask,
+ DevelAsyncImageLoader::PreMultiplyOnLoad preMultiplyOnLoad );
/**
* Connect to this signal if you want to load a PixelBuffer instead of a PixelData.
uint32_t AsyncImageLoader::ApplyMask( Devel::PixelBuffer pixelBuffer,
Devel::PixelBuffer maskPixelBuffer,
float contentScale,
- bool cropToMask )
+ bool cropToMask,
+ DevelAsyncImageLoader::PreMultiplyOnLoad preMultiplyOnLoad)
{
if( !mIsLoadThreadStarted )
{
mLoadThread.Start();
mIsLoadThreadStarted = true;
}
- mLoadThread.AddTask( new LoadingTask( ++mLoadTaskId, pixelBuffer, maskPixelBuffer, contentScale, cropToMask ) );
+ mLoadThread.AddTask( new LoadingTask( ++mLoadTaskId, pixelBuffer, maskPixelBuffer, contentScale, cropToMask, preMultiplyOnLoad ) );
return mLoadTaskId;
}
* @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 );
+ bool cropToMask,
+ DevelAsyncImageLoader::PreMultiplyOnLoad preMultiplyOnLoad );
/**
* @copydoc Toolkit::AsyncImageLoader::ImageLoadedSignal
{
}
-LoadingTask::LoadingTask( uint32_t id, Devel::PixelBuffer pixelBuffer, Devel::PixelBuffer maskPixelBuffer, float contentScale, bool cropToMask )
+LoadingTask::LoadingTask( uint32_t id, Devel::PixelBuffer pixelBuffer, Devel::PixelBuffer maskPixelBuffer, float contentScale, bool cropToMask,
+ DevelAsyncImageLoader::PreMultiplyOnLoad preMultiplyOnLoad )
: pixelBuffer( pixelBuffer ),
url( "" ),
id( id ),
fittingMode(),
samplingMode(),
orientationCorrection(),
- preMultiplyOnLoad(),
+ preMultiplyOnLoad( preMultiplyOnLoad ),
isMaskTask( true ),
maskPixelBuffer( maskPixelBuffer ),
contentScale( contentScale ),
{
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 )
}
}
-void LoadingTask::ApplyMask()
-{
- pixelBuffer.ApplyMask( maskPixelBuffer, contentScale, cropToMask );
-}
-
ImageLoadThread::ImageLoadThread( EventThreadCallback* trigger )
: mTrigger( trigger ),
mLogFactory( Dali::Adaptor::Get().GetLogFactory() )
{
task->ApplyMask();
}
+ task->MultiplyAlpha();
AddCompletedTask( task );
}
* @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.
+ * @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.
*/
LoadingTask( uint32_t id,
const VisualUrl& url,
* @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 );
+ bool cropToMask,
+ DevelAsyncImageLoader::PreMultiplyOnLoad preMultiplyOnLoad);
/**
* Load the image
*/
void ApplyMask();
+ /**
+ * Multiply alpha
+ */
+ void MultiplyAlpha();
+
private:
// Undefined
{
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,
textureInfo.maskApplied = true;
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 );
}
}
}
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;
}
* @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.
+ * @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.
*/
void Load(TextureId textureId,
const VisualUrl& url,
* @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 );
+ bool cropToMask,
+ DevelAsyncImageLoader::PreMultiplyOnLoad preMultiplyOnLoad );
public:
AsyncLoadingHelper(const AsyncLoadingHelper&) = delete;