X-Git-Url: http://review.tizen.org/git/?p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git;a=blobdiff_plain;f=dali-toolkit%2Finternal%2Fimage-loader%2Fasync-image-loader-impl.cpp;h=ea10924db49929b7d1bfbbdc23a42ee0f5498840;hp=dd98ae3b2a90f2e48b544082bd28378ef577eaa9;hb=a4b26c19783f73d4e0f3a9fdd23f5a1810406734;hpb=7b3868bc2f2ecb7ecc030e92d47d64b3057ca8f8 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 dd98ae3..ea10924 100644 --- a/dali-toolkit/internal/image-loader/async-image-loader-impl.cpp +++ b/dali-toolkit/internal/image-loader/async-image-loader-impl.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019 Samsung Electronics Co., Ltd. + * Copyright (c) 2021 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. @@ -19,22 +19,22 @@ #include "async-image-loader-impl.h" // EXTERNAL INCLUDES -#include +#include + +// INTERNAL INCLUDES +#include namespace Dali { - namespace Toolkit { - namespace Internal { - AsyncImageLoader::AsyncImageLoader() : mLoadedSignal(), - mLoadThread( new EventThreadCallback( MakeCallback( this, &AsyncImageLoader::ProcessLoadedImage ) ) ), - mLoadTaskId( 0u ), - mIsLoadThreadStarted( false ) + mLoadThread(new EventThreadCallback(MakeCallback(this, &AsyncImageLoader::ProcessLoadedImage))), + mLoadTaskId(0u), + mIsLoadThreadStarted(false) { } @@ -49,34 +49,65 @@ IntrusivePtr AsyncImageLoader::New() return internal; } -uint32_t AsyncImageLoader::Load( const VisualUrl& url, - ImageDimensions dimensions, - FittingMode::Type fittingMode, - SamplingMode::Type samplingMode, - bool orientationCorrection, - DevelAsyncImageLoader::PreMultiplyOnLoad preMultiplyOnLoad) +uint32_t AsyncImageLoader::LoadAnimatedImage(Dali::AnimatedImageLoading animatedImageLoading, + uint32_t frameIndex) { - if( !mIsLoadThreadStarted ) + if(!mIsLoadThreadStarted) { mLoadThread.Start(); mIsLoadThreadStarted = true; } - mLoadThread.AddTask( new LoadingTask( ++mLoadTaskId, url, dimensions, fittingMode, samplingMode, orientationCorrection, preMultiplyOnLoad ) ); + mLoadThread.AddTask(new LoadingTask(++mLoadTaskId, animatedImageLoading, frameIndex)); + + return mLoadTaskId; +} + +uint32_t AsyncImageLoader::Load(const VisualUrl& url, + ImageDimensions dimensions, + FittingMode::Type fittingMode, + SamplingMode::Type samplingMode, + bool orientationCorrection, + DevelAsyncImageLoader::PreMultiplyOnLoad preMultiplyOnLoad) +{ + if(!mIsLoadThreadStarted) + { + mLoadThread.Start(); + mIsLoadThreadStarted = true; + } + if(url.IsBufferResource()) + { + auto visualFactory = Toolkit::VisualFactory::Get(); + if(visualFactory) + { + // Get EncodedImageBuffer from texturemanager + // and make new LoadingTask with buffer + auto& textureManager = GetImplementation(visualFactory).GetTextureManager(); + + const EncodedImageBuffer& encodedBuffer = textureManager.GetEncodedImageBuffer(url.GetUrl()); + + mLoadThread.AddTask(new LoadingTask(++mLoadTaskId, encodedBuffer, dimensions, fittingMode, samplingMode, orientationCorrection, preMultiplyOnLoad)); + } + } + else + { + mLoadThread.AddTask(new LoadingTask(++mLoadTaskId, url, dimensions, fittingMode, samplingMode, orientationCorrection, preMultiplyOnLoad)); + } return mLoadTaskId; } -uint32_t AsyncImageLoader::ApplyMask( Devel::PixelBuffer pixelBuffer, - Devel::PixelBuffer maskPixelBuffer, - float contentScale, - bool cropToMask ) +uint32_t AsyncImageLoader::ApplyMask(Devel::PixelBuffer pixelBuffer, + Devel::PixelBuffer maskPixelBuffer, + float contentScale, + bool cropToMask, + DevelAsyncImageLoader::PreMultiplyOnLoad preMultiplyOnLoad) { - if( !mIsLoadThreadStarted ) + 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; } @@ -91,9 +122,9 @@ Toolkit::DevelAsyncImageLoader::PixelBufferLoadedSignalType& AsyncImageLoader::P return mPixelBufferLoadedSignal; } -bool AsyncImageLoader::Cancel( uint32_t loadingTaskId ) +bool AsyncImageLoader::Cancel(uint32_t loadingTaskId) { - return mLoadThread.CancelTask( loadingTaskId ); + return mLoadThread.CancelTask(loadingTaskId); } void AsyncImageLoader::CancelAll() @@ -103,20 +134,20 @@ void AsyncImageLoader::CancelAll() void AsyncImageLoader::ProcessLoadedImage() { - while( LoadingTask *next = mLoadThread.NextCompletedTask() ) + while(LoadingTask* next = mLoadThread.NextCompletedTask()) { - if( mPixelBufferLoadedSignal.GetConnectionCount() > 0 ) + if(mPixelBufferLoadedSignal.GetConnectionCount() > 0) { - mPixelBufferLoadedSignal.Emit( next->id, next->pixelBuffer, next->isMaskTask ); + mPixelBufferLoadedSignal.Emit(next->id, next->pixelBuffer); } - else if( mLoadedSignal.GetConnectionCount() > 0 ) + else if(mLoadedSignal.GetConnectionCount() > 0) { PixelData pixelData; - if( next->pixelBuffer ) + if(next->pixelBuffer) { - pixelData = Devel::PixelBuffer::Convert( next->pixelBuffer ); + pixelData = Devel::PixelBuffer::Convert(next->pixelBuffer); } - mLoadedSignal.Emit( next->id, pixelData ); + mLoadedSignal.Emit(next->id, pixelData); } delete next;