1 #ifndef DALI_TOOLKIT_ASYNC_IMAGE_LOADER_IMPL_H
2 #define DALI_TOOLKIT_ASYNC_IMAGE_LOADER_IMPL_H
5 * Copyright (c) 2021 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/devel-api/image-loader/async-image-loader-devel.h>
26 #include <dali-toolkit/internal/image-loader/image-load-thread.h>
27 #include <dali-toolkit/public-api/image-loader/async-image-loader.h>
35 class AsyncImageLoader : public BaseObject
44 * @copydoc Toolkit::AsyncImageLoader::New()
46 static IntrusivePtr<AsyncImageLoader> New();
49 * @copydoc Toolkit::AsyncImageLoader::LoadAnimatedImage( Dali::AnimatedImageLoading animatedImageLoading, uint32_t frameIndex, DevelAsyncImageLoader::PreMultiplyOnLoad preMultiplyOnLoad)
51 uint32_t LoadAnimatedImage(Dali::AnimatedImageLoading animatedImageLoading,
53 DevelAsyncImageLoader::PreMultiplyOnLoad preMultiplyOnLoad);
56 * @copydoc Toolkit::AsyncImageLoader::Load( const std::string&, ImageDimensions, FittingMode::Type, SamplingMode::Type, bool , DevelAsyncImageLoader::PreMultiplyOnLoad )
58 uint32_t Load(const VisualUrl& url,
59 ImageDimensions dimensions,
60 FittingMode::Type fittingMode,
61 SamplingMode::Type samplingMode,
62 bool orientationCorrection,
63 DevelAsyncImageLoader::PreMultiplyOnLoad preMultiplyOnLoad);
66 * @brief Starts an image loading task by encoded image buffer.
67 * @param[in] encodedImageBuffer The encoded buffer of the image to load
68 * @param[in] dimensions The width and height to fit the loaded image to
69 * @param[in] fittingMode The method used to fit the shape of the image before loading to the shape defined by the size parameter
70 * @param[in] samplingMode The filtering method used when sampling pixels from the input image while fitting it to desired size
71 * @param[in] orientationCorrection Reorient the image to respect any orientation metadata in its header
72 * @param[in] preMultiplyOnLoad ON if the image color should be multiplied by it's alpha. Set to OFF if there is no alpha.
73 * @return The loading task id
75 uint32_t LoadEncodedImageBuffer(const EncodedImageBuffer& encodedImageBuffer,
76 ImageDimensions dimensions,
77 FittingMode::Type fittingMode,
78 SamplingMode::Type samplingMode,
79 bool orientationCorrection,
80 DevelAsyncImageLoader::PreMultiplyOnLoad preMultiplyOnLoad);
83 * @brief Starts an mask applying task.
84 * @param[in] pixelBuffer of the to be masked image
85 * @param[in] maskPixelBuffer of the mask image
86 * @param[in] contentScale The factor to scale the content
87 * @param[in] cropToMask Whether to crop the content to the mask size
88 * @param[in] preMultiplyOnLoad ON if the image color should be multiplied by it's alpha. Set to OFF if there is no alpha.
89 * @return The loading task id
91 uint32_t ApplyMask(Devel::PixelBuffer pixelBuffer,
92 Devel::PixelBuffer maskPixelBuffer,
95 DevelAsyncImageLoader::PreMultiplyOnLoad preMultiplyOnLoad);
98 * @copydoc Toolkit::AsyncImageLoader::ImageLoadedSignal
100 Toolkit::AsyncImageLoader::ImageLoadedSignalType& ImageLoadedSignal();
103 * @copydoc Toolkit::AsyncImageLoader::PixelBufferLoadedSignal
105 Toolkit::DevelAsyncImageLoader::PixelBufferLoadedSignalType& PixelBufferLoadedSignal();
108 * @copydoc Toolkit::AsyncImageLoader::Cancel
110 bool Cancel(uint32_t loadingTaskId);
113 * @copydoc Toolkit::AsyncImageLoader::CancelAll
118 * Process the completed loading task from the worker thread.
120 void ProcessLoadedImage();
126 ~AsyncImageLoader() override;
129 Toolkit::AsyncImageLoader::ImageLoadedSignalType mLoadedSignal;
130 Toolkit::DevelAsyncImageLoader::PixelBufferLoadedSignalType mPixelBufferLoadedSignal;
132 ImageLoadThread mLoadThread;
133 uint32_t mLoadTaskId;
134 bool mIsLoadThreadStarted;
137 } // namespace Internal
139 inline const Internal::AsyncImageLoader& GetImplementation(const Toolkit::AsyncImageLoader& handle)
141 DALI_ASSERT_ALWAYS(handle && "AsyncImageLoader handle is empty");
143 const BaseObject& object = handle.GetBaseObject();
145 return static_cast<const Internal::AsyncImageLoader&>(object);
148 inline Internal::AsyncImageLoader& GetImplementation(Toolkit::AsyncImageLoader& handle)
150 DALI_ASSERT_ALWAYS(handle && "AsyncImageLoader handle is empty");
152 BaseObject& object = handle.GetBaseObject();
154 return static_cast<Internal::AsyncImageLoader&>(object);
157 } // namespace Toolkit
161 #endif // DALI_TOOLKIT_ASYNC_IMAGE_LOADER_IMPL_H