1 #ifndef DALI_TOOLKIT_TEXTURE_MANAGER_IMPL_H
2 #define DALI_TOOLKIT_TEXTURE_MANAGER_IMPL_H
5 * Copyright (c) 2023 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/devel-api/adaptor-framework/animated-image-loading.h>
22 #include <dali/devel-api/adaptor-framework/pixel-buffer.h>
23 #include <dali/integration-api/processor-interface.h>
24 #include <dali/public-api/adaptor-framework/encoded-image-buffer.h>
25 #include <dali/public-api/adaptor-framework/round-robin-container-view.h>
26 #include <dali/public-api/common/dali-vector.h>
27 #include <dali/public-api/rendering/geometry.h>
30 #include <dali-toolkit/devel-api/image-loader/image-atlas.h>
31 #include <dali-toolkit/internal/texture-manager/texture-cache-manager.h>
32 #include <dali-toolkit/internal/texture-manager/texture-manager-type.h>
33 #include <dali-toolkit/internal/texture-manager/texture-upload-observer.h>
34 #include <dali-toolkit/internal/visuals/visual-url.h>
42 class ImageAtlasManager;
43 typedef IntrusivePtr<ImageAtlasManager> ImageAtlasManagerPtr;
44 class TextureAsyncLoadingHelper;
47 * The TextureManager provides a common Image loading API for Visuals.
49 * The TextureManager is responsible for providing sync, async, atlased and non-atlased
50 * CPU time alpha masking, animated image loads.
52 * Texture caching is provided and performed by TextureCacheManager.
53 * TextureUploadObserver.LoadComplete called when async load completed.
55 class TextureManager : public ConnectionTracker, public Integration::Processor
58 // Copy enum and types and const values that TextureManager will use.
59 using TextureId = TextureManagerType::TextureId;
60 using TextureCacheIndex = TextureManagerType::TextureCacheIndex;
61 using TextureHash = TextureManagerType::TextureHash;
63 static constexpr TextureId INVALID_TEXTURE_ID = TextureManagerType::INVALID_TEXTURE_ID;
64 static constexpr TextureCacheIndex INVALID_CACHE_INDEX = TextureManagerType::INVALID_CACHE_INDEX;
66 using UseAtlas = TextureManagerType::UseAtlas;
67 using StorageType = TextureManagerType::StorageType;
68 using LoadType = TextureManagerType::LoadType;
69 using LoadState = TextureManagerType::LoadState;
70 using ReloadPolicy = TextureManagerType::ReloadPolicy;
71 using MultiplyOnLoad = TextureManagerType::MultiplyOnLoad;
72 using TextureInfo = TextureManagerType::TextureInfo;
78 ~MaskingData() = default;
80 VisualUrl mAlphaMaskUrl;
81 TextureManager::TextureId mAlphaMaskId;
82 float mContentScaleFactor;
84 bool mPreappliedMasking;
85 bool mMaskImageLoadingFailed;
87 using MaskingDataPointer = std::unique_ptr<MaskingData>;
90 * Class to provide lifecycle event on destruction of texture manager.
92 struct LifecycleObserver
95 * Called shortly before the texture manager is destroyed.
97 virtual void TextureManagerDestroyed() = 0;
108 ~TextureManager() override;
110 // TextureManager Main API:
113 * @brief Requests an frame of animated image load.
115 * The parameters are used to specify how the animated image is loaded.
116 * The observer has the LoadComplete method called when the load is ready.
118 * @param[in] url The URL of the image to load
119 * @param[in] animatedImageLoading The AnimatedImageLoading that contain the animated image information
120 * @param[in] frameIndex The frame index to load.
121 * @param[out] textureId The textureId of the frame
122 * @param[in, out] maskInfo Mask info structure
123 * @param[in] desiredSize The size the image is likely to appear at. This can be set to 0, 0 for automatic
124 * @param[in] fittingMode The FittingMode to use
125 * @param[in] samplingMode The SamplingMode to use
126 * @param[in] synchronousLoading true if the frame should be loaded synchronously
127 * @param[in] textureObserver The client object should inherit from this and provide the "LoadCompleted" virtual.
128 * This is called when an image load completes (or fails).
129 * @param[in,out] preMultiplyOnLoad True if the image color should be multiplied by it's alpha. Set to false if the
130 * image has no alpha channel
132 * @return The texture set containing the frame of animated image, or empty if still loading.
134 TextureSet LoadAnimatedImageTexture(const VisualUrl& url,
135 Dali::AnimatedImageLoading animatedImageLoading,
136 const uint32_t& frameIndex,
137 TextureManager::TextureId& textureId,
138 MaskingDataPointer& maskInfo,
139 const Dali::ImageDimensions& desiredSize,
140 const Dali::FittingMode::Type& fittingMode,
141 const Dali::SamplingMode::Type& samplingMode,
142 const bool& synchronousLoading,
143 TextureUploadObserver* textureObserver,
144 TextureManager::MultiplyOnLoad& preMultiplyOnLoad);
147 * @brief Requests an image load of the given URL to get PixelBuffer.
149 * The parameters are used to specify how the image is loaded.
150 * The observer has the LoadComplete method called when the load is ready.
152 * @param[in] url The URL of the image to load
153 * @param[in] desiredSize The size the image is likely to appear at. This can be set to 0,0 for automatic
154 * @param[in] fittingMode The FittingMode to use
155 * @param[in] samplingMode The SamplingMode to use
156 * @param[in] synchronousLoading true if the URL should be loaded synchronously
157 * @param[in] textureObserver The client object should inherit from this and provide the "LoadCompleted" virtual.
158 * This is called when an image load completes (or fails).
159 * @param[in] orientationCorrection Whether to rotate image to match embedded orientation data
160 * @param[in,out] preMultiplyOnLoad True if the image color should be multiplied by it's alpha. Set to false if the
161 * image has no alpha channel
163 * @return The pixel buffer containing the image, or empty if still loading.
165 Devel::PixelBuffer LoadPixelBuffer(
166 const VisualUrl& url,
167 const Dali::ImageDimensions& desiredSize,
168 const Dali::FittingMode::Type& fittingMode,
169 const Dali::SamplingMode::Type& samplingMode,
170 const bool& synchronousLoading,
171 TextureUploadObserver* textureObserver,
172 const bool& orientationCorrection,
173 TextureManager::MultiplyOnLoad& preMultiplyOnLoad);
176 * @brief Requests an image load of the given URL.
178 * The parameters are used to specify how the image is loaded.
179 * The observer has the LoadComplete method called when the load is ready.
181 * When the client has finished with the Texture, Remove() should be called.
183 * @param[in] url The URL of the image to load
184 * @param[in] desiredSize The size the image is likely to appear at. This can be set to 0,0 for automatic
185 * @param[in] fittingMode The FittingMode to use
186 * @param[in] samplingMode The SamplingMode to use
187 * @param[in, out] maskInfo Mask info structure
188 * @param[in] synchronousLoading true if the URL should be loaded synchronously
189 * @param[in, out] textureId The textureId of the URL. It is also be used to check the previous textureId
190 * what requestor had. It will be used only ReloadPolicy::FORCED for now.
191 * @param[out] textureRect The rectangle within the texture atlas that this URL occupies,
192 * this is the rectangle in normalized coordinates.
193 * @param[out] textureRectSize The rectangle within the texture atlas that this URL occupies,
194 * this is the same rectangle in pixels.
195 * @param[in,out] atlasingStatus Set to USE_ATLAS to attempt atlasing. If atlasing fails, the image will still
196 * be loaded, and marked successful, but this will be set to false.
197 * If atlasing succeeds, this will be set to true.
198 * @param[out] loadingStatus The loading status of the texture
199 * @param[in] textureObserver The client object should inherit from this and provide the "LoadCompleted" virtual.
200 * This is called when an image load completes (or fails).
201 * @param[in] atlasObserver This is used if the texture is atlased, and will be called instead of
202 * textureObserver.LoadCompleted
203 * @param[in] imageAtlasManager The atlas manager to use for atlasing textures
204 * @param[in] orientationCorrection Whether to rotate image to match embedded orientation data
205 * @param[in] reloadPolicy Forces a reload of the texture even if already cached
206 * @param[in,out] preMultiplyOnLoad True if the image color should be multiplied by it's alpha. Set to false if the
207 * image has no alpha channel
209 * @return The texture set containing the image, or empty if still loading.
211 TextureSet LoadTexture(
212 const VisualUrl& url,
213 const Dali::ImageDimensions& desiredSize,
214 const Dali::FittingMode::Type& fittingMode,
215 const Dali::SamplingMode::Type& samplingMode,
216 MaskingDataPointer& maskInfo,
217 const bool& synchronousLoading,
218 TextureManager::TextureId& textureId,
219 Dali::Vector4& textureRect,
220 Dali::ImageDimensions& textureRectSize,
221 bool& atlasingStatus,
223 TextureUploadObserver* textureObserver,
224 AtlasUploadObserver* atlasObserver,
225 ImageAtlasManagerPtr imageAtlasManager,
226 const bool& orientationCorrection,
227 const TextureManager::ReloadPolicy& reloadPolicy,
228 TextureManager::MultiplyOnLoad& preMultiplyOnLoad);
231 * Add an observer to the object.
232 * @param[in] observer The observer to add.
234 void AddObserver(TextureManager::LifecycleObserver& observer);
237 * Remove an observer from the object
238 * @pre The observer has already been added.
239 * @param[in] observer The observer to remove.
241 void RemoveObserver(TextureManager::LifecycleObserver& observer);
244 * @brief Returns the geometry associated with texture.
245 * @param[in] textureId Id of the texture
246 * @param[out] frontElements number of front elements
247 * @param[out] backElements number of back elements
248 * @return Returns valid geometry object
250 Geometry GetRenderGeometry(const TextureManager::TextureId& textureId, std::uint32_t& frontElements, std::uint32_t& backElements);
253 * @brief Returns the textureSet in texture manager.
254 * @param[in] textureId Id of the texture
255 * @return The textureSet in texture manager. These textures include YUV textures or images and masks.
257 TextureSet GetTextureSet(const TextureManager::TextureId& textureId);
260 * @brief Returns the textureSet in texture manager.
261 * @param[in] textureInfo the information of the texture
262 * @return The textureSet in texture manager. These textures include YUV textures or images and masks.
264 TextureSet GetTextureSet(const TextureManager::TextureInfo& textureInfo);
267 // API list that need to access TextureCacheManager.
270 * @copydoc TextureCacheManager::GetVisualUrl
272 inline VisualUrl GetVisualUrl(const TextureManager::TextureId& textureId)
274 return mTextureCacheManager.GetVisualUrl(textureId);
278 * @copydoc TextureCacheManager::GetTexture
280 inline Texture GetTexture(const TextureManager::TextureId& textureId)
282 return mTextureCacheManager.GetTexture(textureId);
286 * @copydoc TextureCacheManager::RemoveExternalTexture
288 inline TextureSet RemoveExternalTexture(const std::string& url)
290 return mTextureCacheManager.RemoveExternalTexture(url);
294 * @copydoc TextureCacheManager::RemoveEncodedImageBuffer
296 inline EncodedImageBuffer RemoveEncodedImageBuffer(const std::string& url)
298 return mTextureCacheManager.RemoveEncodedImageBuffer(url);
302 * @copydoc TextureCacheManager::UseExternalResource
304 inline void UseExternalResource(const VisualUrl& url)
306 mTextureCacheManager.UseExternalResource(url);
310 * @copydoc TextureCacheManager::GetEncodedImageBuffer
312 inline EncodedImageBuffer GetEncodedImageBuffer(const std::string& url)
314 return mTextureCacheManager.GetEncodedImageBuffer(url);
318 * @copydoc TextureCacheManager::AddExternalTexture
320 inline std::string AddExternalTexture(const TextureSet& texture, bool preMultiplied = false)
322 return mTextureCacheManager.AddExternalTexture(texture, preMultiplied);
326 * @copydoc TextureCacheManager::AddEncodedImageBuffer
328 inline std::string AddEncodedImageBuffer(const EncodedImageBuffer& encodedImageBuffer)
330 return mTextureCacheManager.AddEncodedImageBuffer(encodedImageBuffer);
333 public: // Load Request API
335 * @brief Requests an image load of the given URL.
337 * The parameters are used to specify how the image is loaded.
338 * The observer has the LoadComplete method called when the load is ready.
340 * When the client has finished with the Texture, Remove() should be called.
342 * @param[in] url The URL of the image to load
343 * @param[in] desiredSize The size the image is likely to appear at. This can be set to 0,0 for automatic
344 * @param[in] fittingMode The FittingMode to use
345 * @param[in] samplingMode The SamplingMode to use
346 * @param[in] useAtlasing Set to USE_ATLAS to attempt atlasing. If atlasing fails, the image will still be loaded, and marked successful,
347 * but "useAtlasing" will be set to false in the "LoadCompleted" callback from the TextureManagerUploadObserver.
348 * @param[in] observer The client object should inherit from this and provide the "LoadCompleted" virtual.
349 * This is called when an image load completes (or fails).
350 * @param[in] orientationCorrection Whether to rotate image to match embedded orientation data
351 * @param[in] reloadPolicy Forces a reload of the texture even if already cached
352 * @param[in,out] preMultiplyOnLoad True if the image color should be multiplied by it's alpha. Set to false if the image has no alpha channel
353 * @param[in] synchronousLoading True if the frame should be loaded synchronously. If you skip this parameter,
355 * @return A TextureId to use as a handle to reference this Texture
357 TextureId RequestLoad(
358 const VisualUrl& url,
359 const ImageDimensions& desiredSize,
360 const Dali::FittingMode::Type& fittingMode,
361 const Dali::SamplingMode::Type& samplingMode,
362 const TextureManager::UseAtlas& useAtlasing,
363 TextureUploadObserver* observer,
364 const bool& orientationCorrection,
365 const TextureManager::ReloadPolicy& reloadPolicy,
366 TextureManager::MultiplyOnLoad& preMultiplyOnLoad,
367 const bool& synchronousLoading = false);
369 private: // Internal Load Request API
371 * @brief Requests an image load of the given URL, when the texture has
372 * have loaded, it will perform a blend with the image mask, and upload
373 * the blended texture.
375 * The parameters are used to specify how the image is loaded.
376 * The observer has the LoadComplete method called when the load is ready.
378 * When the client has finished with the Texture, Remove() should be called.
380 * @param[in] url The URL of the image to load
381 * @param[in] maskTextureId The texture id of an image to mask this with
382 * (can be INVALID if no masking required)
383 * @param[in] previousTextureId The texture id of an image which the requestor already has before
384 * @param[in] contentScale The scale factor to apply to the image before masking
385 * @param[in] desiredSize The size the image is likely to appear at. This can be set to 0,0 for automatic
386 * @param[in] fittingMode The FittingMode to use
387 * @param[in] samplingMode The SamplingMode to use
388 * @param[in] useAtlasing Set to USE_ATLAS to attempt atlasing. If atlasing fails, the image will still
389 * be loaded, and marked successful,
390 * but "useAtlasing" will be set to false in the "LoadCompleted" callback from
391 * the TextureManagerUploadObserver.
392 * @param[in] cropToMask Only used with masking, this will crop the scaled image to the mask size.
393 * If false, then the mask will be scaled to fit the image before being applied.
394 * @param[in] observer The client object should inherit from this and provide the "LoadCompleted"
396 * This is called when an image load completes (or fails).
397 * @param[in] orientationCorrection Whether to rotate image to match embedded orientation data
398 * @param[in] reloadPolicy Forces a reload of the texture even if already cached
399 * @param[in,out] preMultiplyOnLoad True if the image color should be multiplied by it's alpha. Set to false if the
400 * image has no alpha channel
401 * @param[in] synchronousLoading True if the frame should be loaded synchronously. If you skip this parameter,
403 * @return A TextureId to use as a handle to reference this Texture
405 TextureId RequestLoad(
406 const VisualUrl& url,
407 const TextureManager::TextureId& maskTextureId,
408 const TextureManager::TextureId& previousTextureId,
409 const float& contentScale,
410 const ImageDimensions& desiredSize,
411 const Dali::FittingMode::Type& fittingMode,
412 const Dali::SamplingMode::Type& samplingMode,
413 const TextureManager::UseAtlas& useAtlasing,
414 const bool& cropToMask,
415 TextureUploadObserver* observer,
416 const bool& orientationCorrection,
417 const TextureManager::ReloadPolicy& reloadPolicy,
418 TextureManager::MultiplyOnLoad& preMultiplyOnLoad,
419 const bool& synchronousLoading = false);
422 * @brief Requests a masking image to be loaded. This mask is not uploaded to GL,
423 * instead, it is stored in CPU memory, and can be used for CPU blending.
424 * @param[in] maskUrl The URL of the mask image to load
425 * @param[in] storageType, Whether the pixel data is stored in the cache or uploaded to the GPU
426 * @param[in] synchronousLoading True if the frame should be loaded synchronously. If you skip this parameter,
428 * @return A TextureId to use as a handle to reference this mask Texture
430 TextureId RequestMaskLoad(
431 const VisualUrl& maskUrl,
432 StorageType storageType,
433 const bool& synchronousLoading = false);
436 * @brief Requests an image load of the given URL, when the texture has
437 * have loaded, if there is a valid maskTextureId, it will perform a
438 * CPU blend with the mask, and upload the blend texture.
440 * The parameters are used to specify how the image is loaded.
441 * The observer has the LoadComplete method called when the load is ready.
443 * When the client has finished with the Texture, Remove() should be called.
445 * @param[in] url The URL of the image to load
446 * @param[in] maskTextureId The texture id of an image to use as a mask. If no mask is required, then set
447 * to INVALID_TEXTURE_ID
448 * @param[in] previousTextureId The texture id of an image which the requestor already has before. It will be used
449 * when reloadPolicy is FORCED.
450 * @param[in] contentScale The scaling factor to apply to the content when masking
451 * @param[in] desiredSize The size the image is likely to appear at. This can be set to 0,0 for automatic
452 * @param[in] fittingMode The FittingMode to use
453 * @param[in] samplingMode The SamplingMode to use
454 * @param[in] useAtlasing Set to USE_ATLAS to attempt atlasing. If atlasing fails, the image will still be
455 * loaded, and marked successful, but "useAtlasing" will be set to false in the
456 * "LoadCompleted" callback from the TextureManagerUploadObserver.
457 * @param[in] cropToMask Whether to crop the target after masking, or scale the mask to the image before
459 * @param[in] storageType, Whether the pixel data is stored in the cache or uploaded to the GPU
460 * @param[in] observer The client object should inherit from this and provide the "LoadCompleted"
462 * This is called when an image load completes (or fails).
463 * @param[in] orientationCorrection Whether to rotate image to match embedded orientation data
464 * @param[in] reloadPolicy Forces a reload of the texture even if already cached
465 * @param[in,out] preMultiplyOnLoad True if the image color should be multiplied by it's alpha. Set to false if
467 * @param[in] animatedImageLoading The AnimatedImageLoading to load animated image
468 * @param[in] frameIndex The frame index of a frame to be loaded frame
469 * @param[in] synchronousLoading True if the frame should be loaded synchronously. If you skip this parameter,
471 * @return A TextureId to use as a handle to reference this Texture
473 TextureId RequestLoadInternal(
474 const VisualUrl& url,
475 const TextureManager::TextureId& maskTextureId,
476 const TextureManager::TextureId& previousTextureId,
477 const float& contentScale,
478 const Dali::ImageDimensions& desiredSize,
479 const Dali::FittingMode::Type& fittingMode,
480 const Dali::SamplingMode::Type& samplingMode,
481 const TextureManager::UseAtlas& useAtlas,
482 const bool& cropToMask,
483 const TextureManager::StorageType& storageType,
484 TextureUploadObserver* observer,
485 const bool& orientationCorrection,
486 const TextureManager::ReloadPolicy& reloadPolicy,
487 TextureManager::MultiplyOnLoad& preMultiplyOnLoad,
488 Dali::AnimatedImageLoading animatedImageLoading,
489 const std::uint32_t& frameIndex,
490 const bool& synchronousLoading);
493 * @brief Load a new image synchronously.
494 * @param[in] url The URL of the image to load
495 * @param[in] desiredSize The size the image is likely to appear at.
496 * This can be set to 0,0 for automatic
497 * @param[in] fittingMode The FittingMode to use
498 * @param[in] samplingMode The SamplingMode to use
499 * @param[in] orientationCorrection Whether to use image metadata to rotate or flip the image,
500 * e.g., from portrait to landscape
501 * @param[in] loadYuvPlanes True if the image should be loaded as yuv planes
502 * @param[out] pixelBuffers The image pixelBuffer
503 * @return PixelBuffer of loaded image.
505 void LoadImageSynchronously(
506 const VisualUrl& url,
507 const Dali::ImageDimensions& desiredSize,
508 const Dali::FittingMode::Type& fittingMode,
509 const Dali::SamplingMode::Type& samplingMode,
510 const bool& orientationCorrection,
511 const bool& loadYuvPlanes,
512 std::vector<Devel::PixelBuffer>& pixelBuffers);
514 public: // Remove Request API
516 * @brief Request Remove a Texture from the TextureManager.
518 * Textures are cached and therefore only the removal of the last
519 * occurrence of a Texture will cause its removal internally.
521 * @param[in] textureId The ID of the Texture to remove.
522 * @param[in] textureObserver The texture observer.
524 void RequestRemove(const TextureManager::TextureId& textureId, TextureUploadObserver* textureObserver);
528 * @brief Remove a Texture from the TextureManager.
530 * Textures are cached and therefore only the removal of the last
531 * occurrence of a Texture will cause its removal internally.
533 * @param[in] textureId The ID of the Texture to remove.
535 void Remove(const TextureManager::TextureId& textureId);
538 * @brief Initiate remove of texture queued.
540 void ProcessRemoveQueue();
546 * Structure to hold info about a texture load queued during NotifyObservers
550 QueueElement(TextureManager::TextureId textureId, TextureUploadObserver* observer)
551 : mTextureId(textureId),
556 TextureManager::TextureId mTextureId; ///< The texture id of the requested load.
557 TextureUploadObserver* mObserver; ///< Observer of texture load.
561 * @brief Initiate a load or queue load if NotifyObservers is invoking callbacks
562 * @param[in] textureInfo The TextureInfo struct associated with the Texture
563 * @param[in] observer The observer wishing to observe the texture upload
565 void LoadOrQueueTexture(TextureManager::TextureInfo& textureInfo, TextureUploadObserver* observer);
568 * @brief Queue a texture load to be subsequently handled by ProcessLoadQueue.
569 * @param[in] textureInfo The TextureInfo struct associated with the Texture
570 * @param[in] observer The observer wishing to observe the texture upload
572 void QueueLoadTexture(const TextureManager::TextureInfo& textureInfo, TextureUploadObserver* observer);
575 * @brief Used internally to initiate a load.
576 * @param[in] textureInfo The TextureInfo struct associated with the Texture
577 * @param[in] observer The observer wishing to observe the texture upload
579 void LoadTexture(TextureManager::TextureInfo& textureInfo, TextureUploadObserver* observer);
582 * @brief Initiate load of textures queued whilst NotifyObservers invoking callbacks.
584 void ProcessLoadQueue();
587 * Add the observer to the observer list
588 * @param[in] textureInfo The TextureInfo struct associated with the texture
589 * @param[in] observer The observer wishing to observe the texture upload
591 void ObserveTexture(TextureManager::TextureInfo& textureInfo, TextureUploadObserver* observer);
594 * @brief Performs Post-Load steps including atlasing.
595 * @param[in] textureInfo The struct associated with this Texture
596 * @param[in] pixelBuffers The image pixelBuffer
597 * @return True if successful
599 void PostLoad(TextureManager::TextureInfo& textureInfo, std::vector<Devel::PixelBuffer>& pixelBuffers);
602 * Check if there is a texture waiting to be masked. If there
603 * is then apply this mask and upload it.
604 * @param[in] maskTextureInfo The texture info of the mask that has just loaded.
606 void CheckForWaitingTexture(TextureManager::TextureInfo& maskTextureInfo);
609 * Apply the mask to the pixelBuffer.
610 * @param[in] textureInfo The information of texture to apply the mask to
611 * @param[in] maskTextureId The texture id of the mask.
613 void ApplyMask(TextureManager::TextureInfo& textureInfo, const TextureManager::TextureId& maskTextureId);
616 * Upload the texture specified in pixelBuffer to the appropriate location
617 * @param[in] pixelBuffers The image data to upload
618 * @param[in] textureInfo The texture info containing the location to store the data to.
620 void UploadTextures(std::vector<Devel::PixelBuffer>& pixelBuffers, TextureManager::TextureInfo& textureInfo);
623 * Notify the current observers that the texture upload is complete,
624 * then remove the observers from the list.
625 * @param[in] textureInfo The struct associated with this Texture
626 * @param[in] success If the pixel data was retrieved successfully and uploaded to GPU
628 void NotifyObservers(TextureManager::TextureInfo& textureInfo, const bool& success);
631 * Call LoadComplete to the observer.
632 * @param[in] observer The client object should inherit from this and provide the "LoadCompleted"
633 * @param[in] textureInfo The struct associated with this Texture
634 * @param[in] success If the pixel data was retrieved successfully and uploaded to GPU
636 void EmitLoadComplete(TextureUploadObserver* observer, TextureManager::TextureInfo& textureInfo, const bool& success);
639 * @brief Remove observer in textureInfo
641 * @param textureInfo The struct associated with this Texture.
642 * @param observer The observer wishing to remove.
644 void RemoveTextureObserver(TextureManager::TextureInfo& textureInfo, TextureUploadObserver* observer);
648 * @brief Common method to handle loading completion.
649 * TextureAsyncLoadingHelper will call this API After async loading finished.
650 * @param[in] textureId The ID of the texture load complete.
651 * @param[in] pixelBuffers The loaded image data
653 void AsyncLoadComplete(const TextureManager::TextureId& textureId, std::vector<Devel::PixelBuffer>& pixelBuffers);
655 protected: // Implementation of Processor
657 * @copydoc Dali::Integration::Processor::Process()
659 void Process(bool postProcessor) override;
663 * Deleted copy constructor.
665 TextureManager(const TextureManager&) = delete;
668 * Deleted assignment operator.
670 TextureManager& operator=(const TextureManager& rhs) = delete;
673 * This is called by the TextureManagerUploadObserver when an observer is destroyed.
674 * We use the callback to know when to remove an observer from our notify list.
675 * @param[in] observer The observer that generated the callback
677 void ObserverDestroyed(TextureUploadObserver* observer);
679 private: // Member Variables:
680 TextureCacheManager mTextureCacheManager; ///< Manager the life-cycle and caching of Textures
682 std::unique_ptr<TextureAsyncLoadingHelper> mAsyncLoader; ///< The Asynchronous image loader used to provide all local async loads
683 Dali::Vector<LifecycleObserver*> mLifecycleObservers; ///< Lifecycle observers of texture manager
685 Dali::Vector<QueueElement> mLoadQueue; ///< Queue of textures to load after NotifyObservers
686 TextureManager::TextureId mLoadingQueueTextureId; ///< TextureId when it is loading. it causes Load Textures to be queued.
688 Dali::Vector<TextureManager::TextureId> mRemoveQueue; ///< Queue of textures to remove at PostProcess. It will be cleared after PostProcess.
690 bool mLoadYuvPlanes; ///< A global flag to specify if the image should be loaded as yuv planes
691 bool mRemoveProcessorRegistered; ///< Flag if remove processor registered or not.
694 } // namespace Internal
696 } // namespace Toolkit
700 #endif // DALI_TOOLKIT_TEXTURE_MANAGER_IMPL_H