1 #ifndef DALI_TOOLKIT_ASYNC_IMAGE_LOADER_IMPL_H
2 #define DALI_TOOLKIT_ASYNC_IMAGE_LOADER_IMPL_H
5 * Copyright (c) 2020 Samsung Electronics Co., Ltd.
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
21 #include <dali/public-api/images/pixel-data.h>
22 #include <dali/public-api/object/base-object.h>
25 #include <dali-toolkit/public-api/image-loader/async-image-loader.h>
26 #include <dali-toolkit/devel-api/image-loader/async-image-loader-devel.h>
27 #include <dali-toolkit/internal/image-loader/image-load-thread.h>
38 class AsyncImageLoader : public BaseObject
48 * @copydoc Toolkit::AsyncImageLoader::New()
50 static IntrusivePtr<AsyncImageLoader> New();
53 * @copydoc Toolkit::AsyncImageLoader::LoadAnimatedImage( Dali::AnimatedImageLoading animatedImageLoading, uint32_t frameIndex )
55 uint32_t LoadAnimatedImage( Dali::AnimatedImageLoading animatedImageLoading,
56 uint32_t frameIndex );
59 * @copydoc Toolkit::AsyncImageLoader::Load( const std::string&, ImageDimensions, FittingMode::Type, SamplingMode::Type, bool , DevelAsyncImageLoader::PreMultiplyOnLoad )
61 uint32_t Load( const VisualUrl& url,
62 ImageDimensions dimensions,
63 FittingMode::Type fittingMode,
64 SamplingMode::Type samplingMode,
65 bool orientationCorrection,
66 DevelAsyncImageLoader::PreMultiplyOnLoad preMultiplyOnLoad );
69 * @brief Starts an mask applying task.
70 * @param[in] pixelBuffer of the to be masked image
71 * @param[in] maskPixelBuffer of the mask image
72 * @param[in] contentScale The factor to scale the content
73 * @param[in] cropToMask Whether to crop the content to the mask size
74 * @param[in] preMultiplyOnLoad ON if the image color should be multiplied by it's alpha. Set to OFF if there is no alpha.
75 * @return The loading task id
77 uint32_t ApplyMask( Devel::PixelBuffer pixelBuffer,
78 Devel::PixelBuffer maskPixelBuffer,
81 DevelAsyncImageLoader::PreMultiplyOnLoad preMultiplyOnLoad );
84 * @copydoc Toolkit::AsyncImageLoader::ImageLoadedSignal
86 Toolkit::AsyncImageLoader::ImageLoadedSignalType& ImageLoadedSignal();
89 * @copydoc Toolkit::AsyncImageLoader::PixelBufferLoadedSignal
91 Toolkit::DevelAsyncImageLoader::PixelBufferLoadedSignalType& PixelBufferLoadedSignal();
94 * @copydoc Toolkit::AsyncImageLoader::Cancel
96 bool Cancel( uint32_t loadingTaskId );
99 * @copydoc Toolkit::AsyncImageLoader::CancelAll
104 * Process the completed loading task from the worker thread.
106 void ProcessLoadedImage();
113 ~AsyncImageLoader() override;
116 Toolkit::AsyncImageLoader::ImageLoadedSignalType mLoadedSignal;
117 Toolkit::DevelAsyncImageLoader::PixelBufferLoadedSignalType mPixelBufferLoadedSignal;
119 ImageLoadThread mLoadThread;
120 uint32_t mLoadTaskId;
121 bool mIsLoadThreadStarted;
124 } // namespace Internal
126 inline const Internal::AsyncImageLoader& GetImplementation( const Toolkit::AsyncImageLoader& handle )
128 DALI_ASSERT_ALWAYS( handle && "AsyncImageLoader handle is empty" );
130 const BaseObject& object = handle.GetBaseObject();
132 return static_cast<const Internal::AsyncImageLoader&>( object );
135 inline Internal::AsyncImageLoader& GetImplementation( Toolkit::AsyncImageLoader& handle )
137 DALI_ASSERT_ALWAYS( handle && "AsyncImageLoader handle is empty" );
139 BaseObject& object = handle.GetBaseObject();
141 return static_cast<Internal::AsyncImageLoader&>( object );
144 } // namespace Toolkit
148 #endif // DALI_TOOLKIT_ASYNC_IMAGE_LOADER_IMPL_H