DALI_TEST_EQUALS( textureTrace.FindMethod("BindTexture"), true, TEST_LOCATION );
+ int srcFactorRgb = renderer.GetProperty<int>( Renderer::Property::BLEND_FACTOR_SRC_RGB );
+ int destFactorRgb = renderer.GetProperty<int>( Renderer::Property::BLEND_FACTOR_DEST_RGB );
+ int srcFactorAlpha = renderer.GetProperty<int>( Renderer::Property::BLEND_FACTOR_SRC_ALPHA );
+ int destFactorAlpha = renderer.GetProperty<int>( Renderer::Property::BLEND_FACTOR_DEST_ALPHA );
+ DALI_TEST_CHECK( srcFactorRgb == BlendFactor::SRC_ALPHA );
+ DALI_TEST_CHECK( destFactorRgb == BlendFactor::ONE_MINUS_SRC_ALPHA );
+ DALI_TEST_CHECK( srcFactorAlpha == BlendFactor::ONE );
+ DALI_TEST_CHECK( destFactorAlpha == BlendFactor::ONE_MINUS_SRC_ALPHA );
+
+ textureTrace.Reset();
+
+ // Make a new visual with the same image
+ Visual::Base newVisual = factory.CreateVisual( propertyMap );
+ DALI_TEST_CHECK( newVisual );
+
+ // For tesing the LoadResourceFunc is called, a big image size should be set, so the atlasing is not applied.
+ // Image with a size smaller than 512*512 will be uploaded as a part of the atlas.
+
+ DummyControl newActor = DummyControl::New();
+ DummyControlImpl& newDummyImpl = static_cast< DummyControlImpl& >( newActor.GetImplementation() );
+ newDummyImpl.RegisterVisual( Control::CONTROL_PROPERTY_END_INDEX + 1, newVisual );
+
+ newActor.SetSize( 200.f, 200.f );
+ DALI_TEST_EQUALS( newActor.GetRendererCount(), 0u, TEST_LOCATION );
+
+ Stage::GetCurrent().Add( newActor );
+
+ application.SendNotification();
+ application.Render();
+
+ DALI_TEST_EQUALS( newActor.GetRendererCount(), 1u, TEST_LOCATION );
+ auto newRenderer = newActor.GetRendererAt( 0 );
+ preMultipliedIndex = newRenderer.GetPropertyIndex( "preMultipliedAlpha" );
+ DALI_TEST_CHECK( preMultipliedIndex != Property::INVALID_INDEX );
+ preMultipliedAlpha = newRenderer.GetProperty< bool >( preMultipliedIndex );
+ preMultipliedAlpha2 = newRenderer.GetProperty< bool >( Renderer::Property::BLEND_PRE_MULTIPLIED_ALPHA );
+
+ DALI_TEST_EQUALS( preMultipliedAlpha, false, TEST_LOCATION );
+ DALI_TEST_EQUALS( preMultipliedAlpha2, false, TEST_LOCATION );
+
+ srcFactorRgb = newRenderer.GetProperty<int>( Renderer::Property::BLEND_FACTOR_SRC_RGB );
+ destFactorRgb = newRenderer.GetProperty<int>( Renderer::Property::BLEND_FACTOR_DEST_RGB );
+ srcFactorAlpha = newRenderer.GetProperty<int>( Renderer::Property::BLEND_FACTOR_SRC_ALPHA );
+ destFactorAlpha = newRenderer.GetProperty<int>( Renderer::Property::BLEND_FACTOR_DEST_ALPHA );
+ DALI_TEST_CHECK( srcFactorRgb == BlendFactor::SRC_ALPHA );
+ DALI_TEST_CHECK( destFactorRgb == BlendFactor::ONE_MINUS_SRC_ALPHA );
+ DALI_TEST_CHECK( srcFactorAlpha == BlendFactor::ONE );
+ DALI_TEST_CHECK( destFactorAlpha == BlendFactor::ONE_MINUS_SRC_ALPHA );
+
Stage::GetCurrent().Remove( actor );
DALI_TEST_CHECK( actor.GetRendererCount() == 0u );
PROJECT(${name})
SET(PKG_NAME ${name})
+SET(GCC_COMPILER_VERSION_REQUIRED "6")
+if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
+ if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS GCC_COMPILER_VERSION_REQUIRED)
+ message(FATAL_ERROR "The GCC required compiler version is " ${GCC_COMPILER_VERSION_REQUIRED})
+ endif()
+endif()
+
FIND_PACKAGE( PkgConfig REQUIRED )
FIND_PACKAGE( Doxygen QUIET )
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
AnimatedVectorImageVisual::~AnimatedVectorImageVisual()
{
+ // Finalize animation task in the main thread
+ mVectorAnimationTask->Finalize();
}
void AnimatedVectorImageVisual::GetNaturalSize( Vector2& naturalSize )
{
actor.AddRenderer( mImpl->mRenderer );
mRendererAdded = true;
- }
- ResourceReady( Toolkit::Visual::ResourceStatus::READY );
+ ResourceReady( Toolkit::Visual::ResourceStatus::READY );
- DALI_LOG_INFO( gVectorAnimationLogFilter, Debug::Verbose, "AnimatedVectorImageVisual::OnUploadCompleted: Renderer is added [%p]\n", this );
+ DALI_LOG_INFO( gVectorAnimationLogFilter, Debug::Verbose, "AnimatedVectorImageVisual::OnUploadCompleted: Renderer is added [%p]\n", this );
+ }
}
void AnimatedVectorImageVisual::OnAnimationFinished()
DALI_LOG_INFO( gVectorAnimationLogFilter, Debug::Verbose, "VectorAnimationTask::~VectorAnimationTask: destructor [%p]\n", this );
}
+void VectorAnimationTask::Finalize()
+{
+ // Release some objects in the main thread
+ if( mAnimationFinishedTrigger )
+ {
+ mAnimationFinishedTrigger.reset();
+ }
+
+ mVectorRenderer.Reset();
+}
+
void VectorAnimationTask::SetRenderer( Renderer renderer )
{
ConditionalWait::ScopedLock lock( mConditionalWait );
void VectorAnimationTask::SetAnimationFinishedCallback( EventThreadCallback* callback )
{
ConditionalWait::ScopedLock lock( mConditionalWait );
- mAnimationFinishedTrigger = std::unique_ptr< EventThreadCallback >( callback );
+ if( callback )
+ {
+ mAnimationFinishedTrigger = std::unique_ptr< EventThreadCallback >( callback );
+ }
}
void VectorAnimationTask::SetLoopCount( int32_t count )
mCurrentFrame = frameNumber;
mCurrentFrameUpdated = true;
+ mUpdateFrameNumber = false;
mResourceReady = false;
DALI_LOG_INFO( gVectorAnimationLogFilter, Debug::Verbose, "VectorAnimationTask::SetCurrentFrameNumber: frame number = %d [%p]\n", mCurrentFrame, this );
}
// Rasterize
- bool renderSuccess = mVectorRenderer.Render( currentFrame );
- if( !renderSuccess )
+ bool renderSuccess = false;
+ if( mVectorRenderer )
{
- DALI_LOG_INFO( gVectorAnimationLogFilter, Debug::Verbose, "VectorAnimationTask::Rasterize: Rendering failed. Try again later.[%d] [%p]\n", currentFrame, this );
- mUpdateFrameNumber = false;
+ renderSuccess = mVectorRenderer.Render( currentFrame );
+ if( !renderSuccess )
+ {
+ DALI_LOG_INFO( gVectorAnimationLogFilter, Debug::Verbose, "VectorAnimationTask::Rasterize: Rendering failed. Try again later.[%d] [%p]\n", currentFrame, this );
+ mUpdateFrameNumber = false;
+ }
}
if( stopped && renderSuccess )
virtual ~VectorAnimationTask();
/**
+ * @brief Finalizes the task.
+ */
+ void Finalize();
+
+ /**
* @brief Sets the renderer used to display the result image.
*
* @param[in] renderer The renderer used to display the result image
{
ConditionalWait::ScopedLock lock( mConditionalWait );
- if( mAnimationTasks.end() == std::find( mAnimationTasks.begin(), mAnimationTasks.end(), task ) )
+ if( mCompletedTasks.end() == std::find( mCompletedTasks.begin(), mCompletedTasks.end(), task ) )
{
mCompletedTasks.push_back( task );
mCompletedTasks.clear();
// pop out the next task from the queue
- if( !mAnimationTasks.empty() && !mNeedToSleep )
+ while( !mAnimationTasks.empty() && !mNeedToSleep )
{
std::vector< VectorAnimationTaskPtr >::iterator next = mAnimationTasks.begin();
VectorAnimationTaskPtr nextTask = *next;
++( 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 );
}
{
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.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 );
}
}
}
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;
const unsigned int TOOLKIT_MAJOR_VERSION = 1;
const unsigned int TOOLKIT_MINOR_VERSION = 4;
-const unsigned int TOOLKIT_MICRO_VERSION = 44;
+const unsigned int TOOLKIT_MICRO_VERSION = 45;
const char * const TOOLKIT_BUILD_DATE = __DATE__ " " __TIME__;
#ifdef DEBUG_ENABLED
Name: dali-toolkit
Summary: Dali 3D engine Toolkit
-Version: 1.4.44
+Version: 1.4.45
Release: 1
Group: System/Libraries
License: Apache-2.0 and BSD-3-Clause and MIT