/*
- * Copyright (c) 2017 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2019 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.
// EXTERNAL INCLUDES
#include <dali/devel-api/adaptor-framework/image-loading.h>
-#include <dali/integration-api/adaptors/adaptor.h>
#include <dali/devel-api/adaptor-framework/thread-settings.h>
+#include <dali/integration-api/adaptor-framework/adaptor.h>
+#include <dali/integration-api/debug.h>
namespace Dali
{
fittingMode( fittingMode ),
samplingMode( samplingMode ),
orientationCorrection( orientationCorrection ),
- preMultiplyOnLoad( preMultiplyOnLoad )
+ preMultiplyOnLoad( preMultiplyOnLoad ),
+ isMaskTask( false ),
+ maskPixelBuffer(),
+ contentScale( 1.0f ),
+ cropToMask( false )
+{
+}
+
+LoadingTask::LoadingTask( uint32_t id, Devel::PixelBuffer pixelBuffer, Devel::PixelBuffer maskPixelBuffer, float contentScale, bool cropToMask,
+ DevelAsyncImageLoader::PreMultiplyOnLoad preMultiplyOnLoad )
+: pixelBuffer( pixelBuffer ),
+ url( "" ),
+ id( id ),
+ dimensions(),
+ fittingMode(),
+ samplingMode(),
+ orientationCorrection(),
+ preMultiplyOnLoad( preMultiplyOnLoad ),
+ isMaskTask( true ),
+ maskPixelBuffer( maskPixelBuffer ),
+ contentScale( contentScale ),
+ cropToMask( cropToMask )
{
}
pixelBuffer = Dali::DownloadImageSynchronously ( url.GetUrl(), dimensions, fittingMode, samplingMode, orientationCorrection );
}
+ if( !pixelBuffer )
+ {
+ DALI_LOG_ERROR( "LoadingTask::Load: Loading is failed: %s\n", url.GetUrl().c_str() );
+ }
+}
+
+void LoadingTask::ApplyMask()
+{
+ pixelBuffer.ApplyMask( maskPixelBuffer, contentScale, cropToMask );
+}
+
+void LoadingTask::MultiplyAlpha()
+{
if( pixelBuffer && Pixel::HasAlpha( pixelBuffer.GetPixelFormat() ) )
{
if( preMultiplyOnLoad == DevelAsyncImageLoader::PreMultiplyOnLoad::ON )
}
}
-
ImageLoadThread::ImageLoadThread( EventThreadCallback* trigger )
: mTrigger( trigger ),
mLogFactory( Dali::Adaptor::Get().GetLogFactory() )
while( LoadingTask* task = NextTaskToProcess() )
{
- task->Load();
+ if( !task->isMaskTask )
+ {
+ task->Load();
+ }
+ else
+ {
+ task->ApplyMask();
+ }
+ task->MultiplyAlpha();
+
AddCompletedTask( task );
}
}