1 #ifndef DALI_SCENE3D_IMAGE_RESOURCE_LOADER_H
2 #define DALI_SCENE3D_IMAGE_RESOURCE_LOADER_H
5 * Copyright (c) 2024 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.
22 #include <dali/public-api/common/vector-wrapper.h>
23 #include <dali/public-api/images/image-operations.h>
24 #include <dali/public-api/images/pixel-data.h>
25 #include <dali/public-api/object/base-handle.h>
26 #include <dali/public-api/rendering/texture.h>
37 * The namespace to load the images and cache raw PixelData.
38 * The cached resources will be reused when the same input parameter is loaded multiple times.
39 * @note This class can be called from worker threads.
41 namespace ImageResourceLoader
43 // Called by main thread.
45 * @brief Get cached texture handle filled as white with RGB888 format.
46 * @return A Texture object containing the white RGB888 color.
48 Dali::Texture GetEmptyTextureWhiteRGB();
51 * @brief Get cached cube texture handle filled as white with RGB888 format at 6 faces.
52 * @return A Texture object containing the white RGB888 color at 6 faces.
54 Dali::Texture GetEmptyCubeTextureWhiteRGB();
57 * @brief Get cached texture handle, or create new texture and upload.
58 * @param[in] pixelData The PixelData of image to upload
59 * @param[in] mipmapRequired True if this texture need to generate mipmap
60 * @return A Texture object containing the pixelData, or an invalid object on failure
62 Dali::Texture GetCachedTexture(Dali::PixelData pixelData, bool mipmapRequired);
65 * @brief Request to remove unused Texture and PixelData. We can choose the collect garbages incrementally or fully.
67 * @param[in] fullCollect True if we want to collect whole garbages. Default is false.
69 void RequestGarbageCollect(bool fullCollect = false);
72 * @brief Let we ensure to create a ResourceLoader cache handler.
74 void EnsureResourceLoaderCreated();
76 // Can be called by worker thread.
78 * @brief Get cached pixelData handle filled as white with RGB888 format.
79 * @return A PixelData object containing the white RGB888 color.
81 Dali::PixelData GetEmptyPixelDataWhiteRGB();
84 * @brief Get cached pixelData handle filled as white with RGBA8888 format.
85 * @return A PixelData object containing the white RGBA8888 color.
87 Dali::PixelData GetEmptyPixelDataWhiteRGBA();
90 * @brief Get cached pixelData handle that will be used for Z-Axis with RGB8888 format.
91 * @return A PixelData object containing the Z-Axis RGB8888 color.
93 Dali::PixelData GetEmptyPixelDataZAxisRGB();
96 * @brief Get cached pixelData handle that will be used for Z-Axis and 1.0 alpha with RGBA8888 format.
97 * @return A PixelData object containing the Z-Axis and 1.0 alpha RGBA8888 color.
99 Dali::PixelData GetEmptyPixelDataZAxisAndAlphaRGBA();
102 * @brief Get cached image, or loads an image synchronously.
103 * @note If cache handler is not created yet, or destroyed due to app terminated, it will load image synchronously without cache.
104 * @param[in] url The URL of the image file to load
105 * @return A PixelData object containing the image, or an invalid object on failure
107 Dali::PixelData GetCachedPixelData(const std::string& url);
110 * @brief Get cached image, or loads an image synchronously by specifying the target dimensions and options.
111 * @note If cache handler is not created yet, or destroyed due to app terminated, it will load image synchronously without cache.
112 * @param[in] url The URL of the image file to load
113 * @param[in] dimensions The width and height to fit the loaded image to
114 * @param[in] fittingMode The method used to fit the shape of the image before loading to the shape defined by the size parameter
115 * @param[in] samplingMode The filtering method used when sampling pixels from the input image while fitting it to desired size
116 * @param[in] orientationCorrection Reorient the image to respect any orientation metadata in its header
117 * @return A PixelData object containing the image, or an invalid object on failure
119 Dali::PixelData GetCachedPixelData(const std::string& url,
120 ImageDimensions dimensions,
121 FittingMode::Type fittingMode,
122 SamplingMode::Type samplingMode,
123 bool orientationCorrection);
124 } // namespace ImageResourceLoader
126 } // namespace Internal
128 } // namespace Scene3D
132 #endif // DALI_SCENE3D_MODEL_CACHE_MANAGER_H