// EXTERNAL INCLUDES
#include <dali/devel-api/adaptor-framework/pixel-buffer.h>
#include <dali/devel-api/common/owner-container.h>
+#include <dali/public-api/adaptor-framework/encoded-image-buffer.h>
#include <dali/public-api/common/dali-vector.h>
#include <dali/public-api/object/ref-object.h>
#include <dali/public-api/rendering/geometry.h>
*/
enum class StorageType : uint8_t
{
- KEEP_PIXEL_BUFFER,
- RETURN_PIXEL_BUFFER,
- UPLOAD_TO_TEXTURE
+ KEEP_PIXEL_BUFFER, ///< Keep loaded pixel buffer inside of texture manager without making texture. This could be used for inside pixel process like mask image.
+ RETURN_PIXEL_BUFFER, ///< Return loaded pixel buffer without making texture.
+ /// Because a pixel buffer cannot be used multiple texture, this pixel buffer only cached during loading, and is removed after loading is finished.
+ UPLOAD_TO_TEXTURE ///< Loaded image will be uploaded to texture and the texture will be returned.
};
/**
*
* @return The texture set containing the frame of animated image, or empty if still loading.
*/
-
TextureSet LoadAnimatedImageTexture(Dali::AnimatedImageLoading animatedImageLoading,
uint32_t frameIndex,
Dali::SamplingMode::Type samplingMode,
*
* @return The pixel buffer containing the image, or empty if still loading.
*/
-
Devel::PixelBuffer LoadPixelBuffer(const VisualUrl& url,
Dali::ImageDimensions desiredSize,
Dali::FittingMode::Type fittingMode,
* @brief Requests an image load of the given URL.
*
* The parameters are used to specify how the image is loaded.
- * The observer has the UploadComplete method called when the load is ready.
+ * The observer has the LoadComplete method called when the load is ready.
*
* When the client has finished with the Texture, Remove() should be called.
*
*
* @return The texture set containing the image, or empty if still loading.
*/
-
TextureSet LoadTexture(const VisualUrl& url,
Dali::ImageDimensions desiredSize,
Dali::FittingMode::Type fittingMode,
* @brief Requests an image load of the given URL.
*
* The parameters are used to specify how the image is loaded.
- * The observer has the UploadComplete method called when the load is ready.
+ * The observer has the LoadComplete method called when the load is ready.
*
* When the client has finished with the Texture, Remove() should be called.
*
* @param[in] orientationCorrection Whether to rotate image to match embedded orientation data
* @param[in] reloadPolicy Forces a reload of the texture even if already cached
* @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
+ * @param[in] synchronousLoading true if the frame should be loaded synchronously
* @return A TextureId to use as a handle to reference this Texture
*/
TextureId RequestLoad(const VisualUrl& url,
TextureUploadObserver* observer,
bool orientationCorrection,
TextureManager::ReloadPolicy reloadPolicy,
- MultiplyOnLoad& preMultiplyOnLoad);
+ MultiplyOnLoad& preMultiplyOnLoad,
+ bool synchronousLoading = false);
/**
* @brief Requests an image load of the given URL, when the texture has
* the blended texture.
*
* The parameters are used to specify how the image is loaded.
- * The observer has the UploadComplete method called when the load is ready.
+ * The observer has the LoadComplete method called when the load is ready.
*
* When the client has finished with the Texture, Remove() should be called.
*
* @param[in] reloadPolicy Forces a reload of the texture even if already cached
* @param[in] preMultiplyOnLoad True if the image color should be multiplied by it's alpha. Set to false if the
* image has no alpha channel
+ * @param[in] synchronousLoading true if the frame should be loaded synchronously
* @return A TextureId to use as a handle to reference this Texture
*/
TextureId RequestLoad(const VisualUrl& url,
TextureUploadObserver* observer,
bool orientationCorrection,
TextureManager::ReloadPolicy reloadPolicy,
- MultiplyOnLoad& preMultiplyOnLoad);
+ MultiplyOnLoad& preMultiplyOnLoad,
+ bool synchronousLoading = false);
/**
* Requests a masking image to be loaded. This mask is not uploaded to GL,
* instead, it is stored in CPU memory, and can be used for CPU blending.
*/
- TextureId RequestMaskLoad(const VisualUrl& maskUrl);
+ TextureId RequestMaskLoad(const VisualUrl& maskUrl,
+ bool synchronousLoading = false);
/**
* @brief Remove a Texture from the TextureManager.
TextureSet GetTextureSet(TextureId textureId);
/**
+ * @brief Get the encoded image buffer
+ * @param[in] textureId The textureId to look up
+ * @return the encoded image buffer, or an empty handle if textureId is not valid
+ */
+ EncodedImageBuffer GetEncodedImageBuffer(TextureId textureId);
+
+ /**
+ * @brief Get the encoded image buffer by VisualUrl
+ * @param[in] url The url to look up
+ * @return the encoded image buffer, or an empty handle if url is not buffer resource or buffer is not valid
+ */
+ EncodedImageBuffer GetEncodedImageBuffer(const std::string& url);
+
+ /**
* Adds an external texture to the texture manager
* @param[in] texture The texture to add
* @return string containing the URL for the texture
std::string AddExternalTexture(TextureSet& texture);
/**
+ * Adds an external encoded image buffer to the texture manager
+ * @param[in] encodedImageBuffer The image buffer to add
+ * @return string containing the URL for the texture
+ */
+ std::string AddExternalEncodedImageBuffer(const EncodedImageBuffer& encodedImageBuffer);
+
+ /**
* Removes an external texture from texture manager
* @param[in] url The string containing the texture to remove
* @return handle to the texture
TextureSet RemoveExternalTexture(const std::string& url);
/**
- * @brief Notify that external textures are used.
+ * Removes an external encoded image buffer from texture manager
+ * @param[in] url The string containing the encoded image buffer to remove
+ * @return handle to the encoded image buffer
+ */
+ EncodedImageBuffer RemoveExternalEncodedImageBuffer(const std::string& url);
+
+ /**
+ * @brief Notify that external textures or external encoded image buffers are used.
* @param[in] url The URL of the texture to use.
*/
- void UseExternalTexture(const VisualUrl& url);
+ void UseExternalResource(const VisualUrl& url);
/**
* Add an observer to the object.
* CPU blend with the mask, and upload the blend texture.
*
* The parameters are used to specify how the image is loaded.
- * The observer has the UploadComplete method called when the load is ready.
+ * The observer has the LoadComplete method called when the load is ready.
*
* When the client has finished with the Texture, Remove() should be called.
*
* there is no alpha
* @param[in] animatedImageLoading The AnimatedImageLoading to load animated image
* @param[in] frameIndex The frame index of a frame to be loaded frame
+ * @param[in] synchronousLoading true if the frame should be loaded synchronously
* @return A TextureId to use as a handle to reference this Texture
*/
TextureId RequestLoadInternal(
TextureManager::ReloadPolicy reloadPolicy,
MultiplyOnLoad& preMultiplyOnLoad,
Dali::AnimatedImageLoading animatedImageLoading,
- uint32_t frameIndex);
+ uint32_t frameIndex,
+ bool synchronousLoading);
/**
* @brief Get the current state of a texture
*/
LoadState GetTextureStateInternal(TextureId textureId);
+ /**
+ * @brief Load a new image synchronously.
+ * @param[in] url The URL of the image to load
+ * @param[in] desiredSize The size the image is likely to appear at.
+ * This can be set to 0,0 for automatic
+ * @param[in] fittingMode The FittingMode to use
+ * @param[in] samplingMode The SamplingMode to use
+ * @param[in] orientationCorrection Whether to use image metadata to rotate or flip the image,
+ * e.g., from portrait to landscape
+ * @return PixelBuffer of loaded image.
+ */
+ Devel::PixelBuffer LoadImageSynchronously(const VisualUrl& url,
+ const ImageDimensions desiredSize,
+ FittingMode::Type fittingMode,
+ Dali::SamplingMode::Type samplingMode,
+ bool orientationCorrection);
+
typedef size_t TextureHash; ///< The type used to store the hash used for Texture caching.
// Structs:
bool CreateTiledGeometry(const Devel::PixelBuffer& pixelBuffer, TextureInfo& textureInfo);
/**
- * Mark the texture as complete, and inform observers
- * @param[in] textureInfo The struct associated with this Texture
- */
- void UploadComplete(TextureInfo& textureInfo);
-
- /**
* Notify the current observers that the texture upload is complete,
* then remove the observers from the list.
* @param[in] textureInfo The struct associated with this Texture
int16_t referenceCount{1};
};
+ struct EncodedBufferTextureInfo
+ {
+ EncodedBufferTextureInfo(TextureId textureId,
+ const EncodedImageBuffer& encodedImageBuffer)
+ : textureId(textureId),
+ encodedImageBuffer(encodedImageBuffer),
+ referenceCount(1u)
+ {
+ }
+ TextureId textureId;
+ EncodedImageBuffer encodedImageBuffer;
+ int16_t referenceCount;
+ };
+
private:
/**
* Deleted copy constructor.
*/
void ObserverDestroyed(TextureUploadObserver* observer);
-private: // Member Variables:
- TextureInfoContainerType mTextureInfoContainer; ///< Used to manage the life-cycle and caching of Textures
- RoundRobinContainerView<AsyncLoadingHelper> mAsyncLocalLoaders; ///< The Asynchronous image loaders used to provide all local async loads
- RoundRobinContainerView<AsyncLoadingHelper> mAsyncRemoteLoaders; ///< The Asynchronous image loaders used to provide all remote async loads
- std::vector<ExternalTextureInfo> mExternalTextures; ///< Externally provided textures
- Dali::Vector<LifecycleObserver*> mLifecycleObservers; ///< Lifecycle observers of texture manager
- Dali::Vector<LoadQueueElement> mLoadQueue; ///< Queue of textures to load after NotifyObservers
- TextureId mCurrentTextureId; ///< The current value used for the unique Texture Id generation
- bool mQueueLoadFlag; ///< Flag that causes Load Textures to be queued.
+private: // Member Variables:
+ TextureInfoContainerType mTextureInfoContainer; ///< Used to manage the life-cycle and caching of Textures
+ RoundRobinContainerView<AsyncLoadingHelper> mAsyncLocalLoaders; ///< The Asynchronous image loaders used to provide all local async loads
+ RoundRobinContainerView<AsyncLoadingHelper> mAsyncRemoteLoaders; ///< The Asynchronous image loaders used to provide all remote async loads
+ std::vector<ExternalTextureInfo> mExternalTextures; ///< Externally provided textures
+ std::vector<EncodedBufferTextureInfo> mEncodedBufferTextures; ///< Externally encoded buffer textures
+ Dali::Vector<LifecycleObserver*> mLifecycleObservers; ///< Lifecycle observers of texture manager
+ Dali::Vector<LoadQueueElement> mLoadQueue; ///< Queue of textures to load after NotifyObservers
+ TextureId mCurrentTextureId; ///< The current value used for the unique Texture Id generation
+ bool mQueueLoadFlag; ///< Flag that causes Load Textures to be queued.
};
} // namespace Internal