Add features to download images over http protocol.
[platform/core/uifw/dali-adaptor.git] / platform-abstractions / slp / resource-loader / resource-thread-image.h
index 60152a4..9b5079b 100644 (file)
 
 #include <dali/integration-api/resource-cache.h>
 #include <dali/integration-api/resource-types.h>
-#include <dali/integration-api/bitmap.h>
 #include "resource-thread-base.h"
 
 namespace Dali
 {
 
-namespace Integration
-{
-namespace Log
-{
-class Filter;
-}
-}
-
 namespace SlpPlatform
 {
 
@@ -44,34 +35,13 @@ public:
    * Constructor
    * @param[in] resourceLoader A reference to the ResourceLoader
    */
-  ResourceThreadImage(ResourceLoader& resourceLoader);
+  ResourceThreadImage(ResourceLoader& resourceLoader, bool forRemoteImage);
 
   /**
    * Destructor
    */
   virtual ~ResourceThreadImage();
 
-  /**
-   * @copydoc ResourceLoader::LoadResourceSynchronously()
-   * Note, this is not threaded, but is called synchronously.
-   */
-  Integration::ResourcePointer LoadResourceSynchronously( const Integration::ResourceType& resourceType, const std::string& resourcePath );
-
-  /**
-   * @copydoc ResourceLoader::GetClosestImageSize()
-   * Note, this is not threaded, but is called synchronously.
-   */
-  void GetClosestImageSize( const std::string& filename,
-                            const ImageAttributes& attributes,
-                            Vector2 &closestSize );
-
-  /**
-   * @copydoc ResourceLoader::GetClosestImageSize()
-   * Note, this is not threaded, but is called synchronously.
-   */
-  void GetClosestImageSize( Integration::ResourcePointer resourceBuffer,
-                            const ImageAttributes& attributes,
-                            Vector2 &closestSize );
 
 private:
   /**
@@ -80,6 +50,11 @@ private:
   virtual void Load(const Integration::ResourceRequest& request);
 
   /**
+   * @copydoc ResourceThreadBase::Download
+   */
+  virtual void Download(const Integration::ResourceRequest& request);
+
+  /**
    * @copydoc ResourceThreadBase::Decode
    */
   virtual void Decode(const Integration::ResourceRequest& request);
@@ -89,21 +64,27 @@ private:
    */
   virtual void Save(const Integration::ResourceRequest& request);
 
-private:
   /**
-   * Convert the file stream into a bitmap.
-   * @param[in] resourceType The type of resource to convert.
-   * @param[in] path The path to the resource.
-   * @param[in] fp File Pointer. Closed on exit.
-   * @param[out] bitmap Pointer to write bitmap to
-   * @return true on success, false on failure
+   * Download a requested image into a memory buffer.
+   * @param[in] request  The requested resource/file url and attributes
+   * @param[out] dataBuffer  A memory buffer object to be written with downloaded image data.
+   * @param[out] dataSize  The size of the memory buffer.
    */
-  bool ConvertStreamToBitmap( const Integration::ResourceType& resourceType,
-                              std::string path,
-                              FILE * const fp,
-                              Integration::BitmapPtr& ptr );
+  bool DownloadRemoteImageIntoMemory(const Integration::ResourceRequest& request, Dali::Vector<uint8_t>& dataBuffer, size_t& dataSize);
 
+  /**
+   * Load a requested image from a local file.
+   * @param[in] request  The requested resource/file url and attributes
+   */
+  void LoadImageFromLocalFile(const Integration::ResourceRequest& request);
 
+  /**
+   * Decode a requested image from a memory buffer.
+   * @param[in] blobBytes  A pointer to the memory buffer containig the requested image data.
+   * @param[in] blobSize  The size of the memory buffer containing the requested image data.
+   * @param[in] request  The requested resource/file url and attributes
+   */
+  void DecodeImageFromMemory(void* blobBytes, size_t blobSize, const Integration::ResourceRequest& request);
 }; // class ResourceThreadImage
 
 } // namespace SlpPlatform