1 #ifndef DALI_TOOLKIT_TEXTURE_ASYNC_LOADING_HELPER_H
2 #define DALI_TOOLKIT_TEXTURE_ASYNC_LOADING_HELPER_H
5 * Copyright (c) 2022 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/signals/connection-tracker.h>
25 #include <dali-toolkit/internal/image-loader/loading-task.h>
26 #include <dali-toolkit/internal/texture-manager/texture-manager-impl.h>
36 * @brief Helper class to keep the relation between AsyncImageLoader and corresponding LoadingInfo container
38 class TextureAsyncLoadingHelper : public ConnectionTracker
42 * @brief Create an TextureAsyncLoadingHelper.
43 * @param[in] textureManager Reference to the texture manager
45 TextureAsyncLoadingHelper(TextureManager& textureManager);
48 * @brief Load a new frame of animated image
49 * @param[in] textureId TextureId to reference the texture that will be loaded
50 * @param[in] animatedImageLoading The AnimatedImageLoading to load animated image
51 * @param[in] frameIndex The frame index of a frame to be loaded frame
52 * @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.
54 void LoadAnimatedImage(const TextureManager::TextureId& textureId,
55 Dali::AnimatedImageLoading animatedImageLoading,
56 const std::uint32_t& frameIndex,
57 const DevelAsyncImageLoader::PreMultiplyOnLoad& preMultiplyOnLoad);
60 * @brief Load a new texture.
61 * @param[in] textureId TextureId to reference the texture that will be loaded
62 * @param[in] url The URL of the image to load
63 * @param[in] desiredSize The size the image is likely to appear at.
64 * This can be set to 0,0 for automatic
65 * @param[in] fittingMode The FittingMode to use
66 * @param[in] samplingMode The SamplingMode to use
67 * @param[in] orientationCorrection Whether to use image metadata to rotate or flip the image,
68 * e.g., from portrait to landscape
69 * @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.
70 * @param[in] loadYuvPlanes True if the image should be loaded as yuv planes
72 void Load(const TextureManager::TextureId& textureId,
74 const Dali::ImageDimensions& desiredSize,
75 const Dali::FittingMode::Type& fittingMode,
76 const Dali::SamplingMode::Type& samplingMode,
77 const bool& orientationCorrection,
78 const DevelAsyncImageLoader::PreMultiplyOnLoad& preMultiplyOnLoad,
79 const bool& loadYuvPlanes);
83 * @param [in] textureId of the texture
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 if the image's color should be multiplied by it's alpha. Set to OFF if there is no alpha.
90 void ApplyMask(const TextureManager::TextureId& textureId,
91 Devel::PixelBuffer pixelBuffer,
92 Devel::PixelBuffer maskPixelBuffer,
93 const float& contentScale,
94 const bool& cropToMask,
95 const DevelAsyncImageLoader::PreMultiplyOnLoad& preMultiplyOnLoad);
98 TextureAsyncLoadingHelper(const TextureAsyncLoadingHelper&) = delete;
99 TextureAsyncLoadingHelper& operator=(const TextureAsyncLoadingHelper&) = delete;
103 * @brief Callback to be called when texture loading is complete, it passes the pixel buffer list on to texture manager.
104 * @param[in] task LoadingTaskPtr
106 void AsyncLoadComplete(LoadingTaskPtr task);
108 private: // Member Variables:
109 TextureManager& mTextureManager;
110 uint32_t mLoadTaskId;
113 } // namespace Internal
115 } // namespace Toolkit
119 #endif // DALI_TOOLKIT_TEXTURE_ASYNC_LOADING_HELPER_H