AnimatedImageLoading AnimatedImageLoading::New( const std::string& url, bool isLocalResource )
{
-
const std::size_t urlSize = url.length();
Internal::Adaptor::AnimatedImageLoadingPtr internal = NULL;
return GetImplementation( *this ).LoadNextNFrames( frameStartIndex, count, pixelData );
}
+Dali::Devel::PixelBuffer AnimatedImageLoading::LoadFrame( uint32_t frameIndex )
+{
+ return GetImplementation( *this ).LoadFrame( frameIndex );
+}
+
ImageDimensions AnimatedImageLoading::GetImageSize() const
{
return GetImplementation( *this ).GetImageSize();
return GetImplementation( *this ).GetFrameInterval( frameIndex );
}
+std::string AnimatedImageLoading::GetUrl() const
+{
+ return GetImplementation( *this ).GetUrl();
+}
+
AnimatedImageLoading::AnimatedImageLoading( Internal::Adaptor::AnimatedImageLoading* internal )
: BaseHandle( internal )
{
// INTERNAL INCLUDES
#include <dali/public-api/dali-adaptor-common.h>
+#include <dali/devel-api/adaptor-framework/pixel-buffer.h>
namespace Dali
{
*/
bool LoadNextNFrames( uint32_t frameStartIndex, int count, std::vector<Dali::PixelData>& pixelData );
+ /**
+ * @brief Load a 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 index to load.
+ * @return Dali::Devel::PixelBuffer The loaded PixelBuffer. If loading is fail, return empty handle.
+ */
+
+ Dali::Devel::PixelBuffer LoadFrame( uint32_t frameIndex );
+
/**
* @brief Get the size of a animated image.
*
*/
uint32_t GetFrameInterval( uint32_t frameIndex ) const;
+ /**
+ * @brief Get the animated image file URL
+ *
+ * @return The URL string of the animated image file
+ */
+ std::string GetUrl() const;
+
public: // Not intended for application developers
/// @cond internal
/**
#define DALI_INTERNAL_ACCESSIBILITY_BRIDGE_DBUS_H
/*
- * Copyright 2019 Samsung Electronics Co., Ltd
+ * Copyright 2020 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.
/**
* @brief Class representing client's end of DBUS connection
*
- * Allows calling (synchronous and asynchronos) methods on selected interface
- * Allows (synchronous and asynchronos) setting / getting properties.
+ * Allows calling (synchronous and asynchronous) methods on selected interface
+ * Allows (synchronous and asynchronous) setting / getting properties.
* Allows registering signals.
*/
class DBusClient
/**
* @brief Class representing server's end of DBUS connection
*
- * Allows listening (synchronously and asynchronosly) on methods on selected interface
- * Allows listening (synchronously and asynchronosly) on setting / getting properties.
+ * Allows listening (synchronously and asynchronously) on methods on selected interface
+ * Allows listening (synchronously and asynchronously) on setting / getting properties.
* Allows emiting signals.
*/
class DBusServer
virtual bool LoadNextNFrames( uint32_t frameStartIndex, int count, std::vector<Dali::PixelData>& pixelData ) = 0;
/**
+ * @copydoc Dali::AnimatedImageLoading::LoadFrame()
+ */
+ virtual Dali::Devel::PixelBuffer LoadFrame( uint32_t frameIndex ) = 0;
+
+ /**
* @copydoc Dali::AnimatedImageLoading::GetImageSize()
*/
virtual ImageDimensions GetImageSize() const = 0;
* @copydoc Dali::AnimatedImageLoading::LoadFrameDelays()
*/
virtual uint32_t GetFrameInterval( uint32_t frameIndex ) const = 0;
+
+ /**
+ * @copydoc Dali::AnimatedImageLoading::GetUrl()
+ */
+ virtual std::string GetUrl() const = 0;
};
} // namespace Adaptor
return ret;
}
+Dali::Devel::PixelBuffer GifLoading::LoadFrame( uint32_t frameIndex )
+{
+ int error;
+ Dali::Devel::PixelBuffer pixelBuffer;
+
+ DALI_LOG_INFO( gGifLoadingLogFilter, Debug::Concise, "LoadFrame( frameIndex:%d )\n", frameIndex );
+
+ pixelBuffer = Dali::Devel::PixelBuffer::New( mImpl->imageProperties.w, mImpl->imageProperties.h, Dali::Pixel::RGBA8888 );
+
+ mImpl->loaderInfo.animated.currentFrame = 1 + ( frameIndex % mImpl->loaderInfo.animated.frameCount );
+ ReadNextFrame( mImpl->loaderInfo, mImpl->imageProperties, pixelBuffer.GetBuffer(), &error );
+
+ if( error != 0 )
+ {
+ pixelBuffer = Dali::Devel::PixelBuffer();
+ }
+ return pixelBuffer;
+}
+
ImageDimensions GifLoading::GetImageSize() const
{
return ImageDimensions( mImpl->imageProperties.w, mImpl->imageProperties.h );
return mImpl->loaderInfo.animated.frames[frameIndex].info.delay * 10;
}
+std::string GifLoading::GetUrl() const
+{
+ return mImpl->mUrl;
+}
+
} // namespace Adaptor
} // namespace Internal
*/
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 gif image.
*
*/
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;
+
private:
struct Impl;
Impl* mImpl;
#endif
}
+Dali::Devel::PixelBuffer WebPLoading::LoadFrame( uint32_t frameIndex )
+{
+ Dali::Devel::PixelBuffer pixelBuffer;
+#ifdef DALI_WEBP_ENABLED
+ if( frameIndex >= mImpl->mWebPAnimInfo.frame_count )
+ {
+ return pixelBuffer;
+ }
+
+ DALI_LOG_INFO( gWebPLoadingLogFilter, Debug::Concise, "LoadNextNFrames( frameIndex:%d )\n", frameIndex );
+
+ if( mImpl->mLoadingFrame > frameIndex )
+ {
+ mImpl->mLoadingFrame = 0;
+ WebPAnimDecoderReset( mImpl->mWebPAnimDecoder );
+ }
+
+ for( ; mImpl->mLoadingFrame < frameIndex ; ++mImpl->mLoadingFrame )
+ {
+ uint8_t* frameBuffer;
+ int timestamp;
+ WebPAnimDecoderGetNext( mImpl->mWebPAnimDecoder, &frameBuffer, ×tamp );
+ mImpl->mTimeStamp[mImpl->mLoadingFrame] = timestamp;
+ }
+
+ const int bufferSize = mImpl->mWebPAnimInfo.canvas_width * mImpl->mWebPAnimInfo.canvas_height * sizeof( uint32_t );
+ uint8_t* frameBuffer;
+ int timestamp;
+ WebPAnimDecoderGetNext( mImpl->mWebPAnimDecoder, &frameBuffer, ×tamp );
+
+ pixelBuffer = Dali::Devel::PixelBuffer::New( mImpl->mWebPAnimInfo.canvas_width, mImpl->mWebPAnimInfo.canvas_height, Dali::Pixel::RGBA8888 );
+ memcpy( pixelBuffer.GetBuffer(), frameBuffer, bufferSize );
+ mImpl->mTimeStamp[mImpl->mLoadingFrame] = timestamp;
+
+ mImpl->mLoadingFrame++;
+ if( mImpl->mLoadingFrame >= mImpl->mWebPAnimInfo.frame_count )
+ {
+ mImpl->mLoadingFrame = 0;
+ WebPAnimDecoderReset( mImpl->mWebPAnimDecoder );
+ }
+#endif
+ return pixelBuffer;
+}
+
ImageDimensions WebPLoading::GetImageSize() const
{
#ifdef DALI_WEBP_ENABLED
}
}
+std::string WebPLoading::GetUrl() const
+{
+ return mImpl->mUrl;
+}
+
} // namespace Adaptor
} // namespace Internal
*/
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.
*
*/
uint32_t GetFrameInterval( uint32_t frameIndex ) const override;
+ std::string GetUrl() const override;
+
private:
struct Impl;
Impl* mImpl;