#define DALI_INTERNAL_WEBP_LOADING_H
/*
- * Copyright (c) 2020 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 Samsung Electronics Co., Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
*
*/
// EXTERNAL INCLUDES
-#include <cstdint>
-#include <memory>
-#include <dali/public-api/math/rect.h>
#include <dali/public-api/common/dali-vector.h>
#include <dali/public-api/common/vector-wrapper.h>
+#include <dali/public-api/math/rect.h>
#include <dali/public-api/math/uint-16-pair.h>
+#include <cstdint>
+#include <memory>
// INTERNAL INCLUDES
-#include <dali/public-api/dali-adaptor-common.h>
#include <dali/internal/imaging/common/animated-image-loading-impl.h>
+#include <dali/public-api/dali-adaptor-common.h>
namespace Dali
{
namespace Internal
{
-
namespace Adaptor
{
-
/**
* Class to manage loading frames of an animated webp in small chunks. Lazy initializes only when
* data is actually needed.
* is released. (This is to speed up frame loads, which would otherwise have to re-acquire the
* data from disk)
*/
-class WebPLoading: public Internal::Adaptor::AnimatedImageLoading
+class WebPLoading : public Internal::Adaptor::AnimatedImageLoading
{
public:
-
/**
* Create a WebPLoading with the given url and resourceType.
* @param[in] url The url of the webp image to load
* @param[in] isLocalResource The true or false whether this is a local resource.
* @return A newly created WebPLoading.
*/
- static AnimatedImageLoadingPtr New( const std::string& url, bool isLocalResource );
+ static AnimatedImageLoadingPtr New(const std::string& url, bool isLocalResource);
/**
* @brief Constructor
* @param[in] url The url of the webp image to load
* @param[in] isLocalResource The true or false whether this is a local resource.
*/
- WebPLoading( const std::string& url, bool isLocalResource );
-
+ WebPLoading(const std::string& url, bool isLocalResource);
/**
* @brief Destructor
* @param[out] pixelData The vector in which to return the frame data
* @return True if the frame data was successfully loaded
*/
- bool LoadNextNFrames( uint32_t frameStartIndex, int count, std::vector<Dali::PixelData>& pixelData ) override;
+ bool LoadNextNFrames(uint32_t frameStartIndex, int count, std::vector<Dali::PixelData>& pixelData) override;
+
+ /**
+ * @brief Load the next Frame of the animated image.
+ *
+ * @note This function will load the entire animated image into memory if not already loaded.
+ * @param[in] frameIndex The frame counter to load. Will usually be the next frame.
+ * @return Dali::Devel::PixelBuffer The loaded PixelBuffer. If loading is fail, return empty handle.
+ */
+ Dali::Devel::PixelBuffer LoadFrame(uint32_t frameIndex) override;
/**
* @brief Get the size of a webp image.
*
* @note The frame is needed to be loaded before this function is called.
*
- * @return The time interval of the frame(microsecond).
+ * @return The time interval between frameIndex and frameIndex + 1(microsecond).
+ */
+ uint32_t GetFrameInterval(uint32_t frameIndex) const override;
+
+ /**
+ * @brief Get the animated image file URL
+ *
+ * @return The URL string of the animated image file
+ */
+ std::string GetUrl() const override;
+
+ /**
+ * @brief Return whether the animated image loading is succeeded or not.
+ *
+ * @return True when the animated image loading is succeeded.
+ */
+ bool HasLoadingSucceeded() const override;
+
+private:
+ /**
+ * @brief Decode Frame of the animated image.
+ *
+ * @param[in] frameIndex The frame counter to load. Will usually be the next frame.
+ * @return Dali::Devel::PixelBuffer The loaded PixelBuffer. If loading is fail, return empty handle.
*/
- uint32_t GetFrameInterval( uint32_t frameIndex ) const override;
+ Dali::Devel::PixelBuffer DecodeFrame(uint32_t frameIndex);
private:
struct Impl;