Cleanup ResourceLoading and PlatformAbstraction 81/129981/6
authorKimmo Hoikka <kimmo.hoikka@samsung.com>
Thu, 18 May 2017 17:01:40 +0000 (18:01 +0100)
committerKimmo Hoikka <kimmo.hoikka@samsung.com>
Thu, 25 May 2017 13:27:01 +0000 (14:27 +0100)
- Removed ResourceType base class
- Removed ResourceLoader and ResourceLoadingClient
- Cleaned up code and comments

Change-Id: Ic61bf03ff482826405a7480450950d717aefcb1f

35 files changed:
adaptors/devel-api/adaptor-framework/bitmap-saver.cpp
adaptors/devel-api/adaptor-framework/image-loading.cpp
adaptors/tizen/native-image-source-impl-tizen.cpp
automated-tests/src/dali-adaptor-internal/image-loaders.cpp
automated-tests/src/dali-adaptor-internal/image-loaders.h
automated-tests/src/dali-adaptor/dali-test-suite-utils/test-platform-abstraction.cpp
automated-tests/src/dali-adaptor/dali-test-suite-utils/test-platform-abstraction.h
automated-tests/src/dali-platform-abstraction/utc-image-loading-common.cpp
automated-tests/src/dali-platform-abstraction/utc-image-loading-common.h
platform-abstractions/tizen/file.list
platform-abstractions/tizen/image-loaders/image-loader.cpp
platform-abstractions/tizen/image-loaders/image-loader.h
platform-abstractions/tizen/image-loaders/loader-astc.cpp
platform-abstractions/tizen/image-loaders/loader-astc.h
platform-abstractions/tizen/image-loaders/loader-bmp.cpp
platform-abstractions/tizen/image-loaders/loader-bmp.h
platform-abstractions/tizen/image-loaders/loader-gif.cpp
platform-abstractions/tizen/image-loaders/loader-gif.h
platform-abstractions/tizen/image-loaders/loader-ico.cpp
platform-abstractions/tizen/image-loaders/loader-ico.h
platform-abstractions/tizen/image-loaders/loader-jpeg-turbo.cpp
platform-abstractions/tizen/image-loaders/loader-jpeg.h
platform-abstractions/tizen/image-loaders/loader-ktx.cpp
platform-abstractions/tizen/image-loaders/loader-ktx.h
platform-abstractions/tizen/image-loaders/loader-png.cpp
platform-abstractions/tizen/image-loaders/loader-png.h
platform-abstractions/tizen/image-loaders/loader-wbmp.cpp
platform-abstractions/tizen/image-loaders/loader-wbmp.h
platform-abstractions/tizen/resource-loader/debug/resource-loader-debug.cpp [deleted file]
platform-abstractions/tizen/resource-loader/debug/resource-loader-debug.h [deleted file]
platform-abstractions/tizen/resource-loader/resource-loader.cpp [deleted file]
platform-abstractions/tizen/resource-loader/resource-loader.h [deleted file]
platform-abstractions/tizen/resource-loader/resource-loading-client.h [deleted file]
platform-abstractions/tizen/tizen-platform-abstraction.cpp
platform-abstractions/tizen/tizen-platform-abstraction.h

index ef5bf4b..bfa9572 100644 (file)
 #include <dali/public-api/common/dali-vector.h>
 
 // INTERNAL INCLUDES
-#include <platform-abstractions/tizen/resource-loader/resource-loader.h>
 #include <platform-abstractions/tizen/image-loaders/loader-jpeg.h>
 #include <platform-abstractions/tizen/image-loaders/loader-png.h>
+#include <platform-abstractions/tizen/tizen-platform-abstraction.h>
 #include <image-encoder.h>
 
+
 namespace Dali
 {
 
@@ -130,7 +131,7 @@ bool EncodeToFile(const unsigned char* const pixelBuffer,
     DALI_LOG_ERROR("Encoding pixels failed\n");
     return false;
   }
-  return TizenPlatform::ResourceLoader::SaveFile( filename, pixbufEncoded.Begin(), pixbufEncoded.Count() );
+  return TizenPlatform::SaveFile( filename, pixbufEncoded.Begin(), pixbufEncoded.Count() );
 }
 
 } // namespace Dali
index c194a76..701ccc7 100644 (file)
@@ -21,7 +21,6 @@
 #include "image-loaders/image-loader.h"
 #include <resource-loader/network/file-download.h>
 #include <platform-abstractions/portable/file-closer.h>
-#include <platform-abstractions/tizen/resource-loader/resource-loading-client.h>
 
 namespace Dali
 {
@@ -35,7 +34,7 @@ const size_t MAXIMUM_DOWNLOAD_IMAGE_SIZE  = 50 * 1024 * 1024 ;
 PixelData LoadImageFromFile( const std::string& url, ImageDimensions size, FittingMode::Type fittingMode, SamplingMode::Type samplingMode, bool orientationCorrection )
 {
   Integration::BitmapResourceType resourceType( size, fittingMode, samplingMode, orientationCorrection );
-  IntrusivePtr<Dali::RefObject> resource = TizenPlatform::ImageLoader::LoadResourceSynchronously( resourceType, url );
+  IntrusivePtr<Dali::RefObject> resource = TizenPlatform::ImageLoader::LoadImageSynchronously( resourceType, url );
 
   if( resource )
   {
@@ -93,7 +92,6 @@ PixelData DownloadImageSynchronously( const std::string& url, ImageDimensions si
           resourceType,
           url,
           fp,
-          TizenPlatform::StubbedResourceLoadingClient(),
           bitmap );
 
         if ( result && bitmap )
index 8b24177..3afb87b 100755 (executable)
@@ -31,7 +31,6 @@
 #include <render-surface.h>
 
 // Allow this to be encoded and saved:
-#include <platform-abstractions/tizen/resource-loader/resource-loader.h>
 #include <bitmap-saver.h>
 
 namespace Dali
index 5acbd85..a5fd26e 100644 (file)
 #include <dali-test-suite-utils.h>
 
 
-class StubImageLoaderClient : public Dali::TizenPlatform::ResourceLoadingClient
-{
-public:
-  StubImageLoaderClient() {}
-  ~StubImageLoaderClient() {}
-
-  virtual void InterruptionPoint() const {}
-};
-
 AutoCloseFile::AutoCloseFile( FILE *fp )
 : filePtr( fp )
 {
@@ -115,7 +106,7 @@ void TestImageLoading( const ImageDetails& image, const LoadFunctions& functions
   Dali::Integration::BitmapPtr bitmapPtr( bitmap );
 
   // Load Bitmap and check its return values.
-  DALI_TEST_CHECK( functions.loader( StubImageLoaderClient(), input, *bitmap ) );
+  DALI_TEST_CHECK( functions.loader( input, *bitmap ) );
   DALI_TEST_EQUALS( image.width,  bitmap->GetImageWidth(),  TEST_LOCATION );
   DALI_TEST_EQUALS( image.height, bitmap->GetImageHeight(), TEST_LOCATION );
 
@@ -155,7 +146,7 @@ void CompareLoadedImageData( const ImageDetails& image, const LoadFunctions& fun
   Dali::Integration::BitmapPtr bitmapPointer( bitmap );
 
   // Load Bitmap and check its return values.
-  DALI_TEST_CHECK( functions.loader( StubImageLoaderClient(), input, *bitmap ) );
+  DALI_TEST_CHECK( functions.loader( input, *bitmap ) );
   DALI_TEST_EQUALS( image.width,  bitmap->GetImageWidth(),  TEST_LOCATION );
   DALI_TEST_EQUALS( image.height, bitmap->GetImageHeight(), TEST_LOCATION );
 
@@ -191,7 +182,7 @@ void DumpImageBufferToTempFile( std::string filename, std::string targetFilename
   Dali::Integration::BitmapPtr bitmapPtr( bitmap );
   const Dali::TizenPlatform::ImageLoader::Input input( fp );
 
-  DALI_TEST_CHECK( functions.loader( StubImageLoaderClient(), input, *bitmap ) );
+  DALI_TEST_CHECK( functions.loader( input, *bitmap ) );
 
   Dali::PixelBuffer* bufferPtr( bitmapPtr->GetBuffer() );
 
index c74029f..9a3ce7a 100644 (file)
@@ -20,7 +20,6 @@
 
 #include <dali/dali.h>
 #include <dali/integration-api/bitmap.h>
-#include "platform-abstractions/tizen/resource-loader/resource-loading-client.h"
 #include "platform-abstractions/tizen/image-loaders/image-loader-input.h"
 
 // Simple structure to close the file when finished with it.
@@ -83,7 +82,7 @@ private:
  */
 struct LoadFunctions
 {
-  typedef bool (*LoadBitmapFunction)( const Dali::TizenPlatform::ResourceLoadingClient& client, const Dali::TizenPlatform::ImageLoader::Input& input, Dali::Integration::Bitmap& );
+  typedef bool (*LoadBitmapFunction)( const Dali::TizenPlatform::ImageLoader::Input& input, Dali::Integration::Bitmap& );
   typedef bool (*LoadBitmapHeaderFunction)( const Dali::TizenPlatform::ImageLoader::Input& input, unsigned int& width, unsigned int& height );
 
   LoadFunctions( LoadBitmapHeaderFunction _header, LoadBitmapFunction _loader );
index b177e4a..cb0b39c 100644 (file)
@@ -25,7 +25,6 @@ namespace Dali
 TestPlatformAbstraction::TestPlatformAbstraction()
 : mTrace(),
   mIsLoadingResult( false ),
-  mSize(),
   mClosestSize(),
   mLoadFileResult(),
   mSaveFileResult( false ),
@@ -60,13 +59,13 @@ ImageDimensions TestPlatformAbstraction::GetClosestImageSize( Integration::Resou
   return closestSize;
 }
 
-Integration::ResourcePointer TestPlatformAbstraction::LoadResourceSynchronously( const Integration::ResourceType& resourceType, const std::string& resourcePath )
+Integration::ResourcePointer TestPlatformAbstraction::LoadImageSynchronously( const Integration::BitmapResourceType& resourceType, const std::string& resourcePath )
 {
   mTrace.PushCall("LoadResourceSynchronously", "");
   return mSynchronouslyLoadedResource;
 }
 
-Integration::BitmapPtr TestPlatformAbstraction::DecodeBuffer( const Integration::ResourceType& resourceType, uint8_t * buffer, size_t size )
+Integration::BitmapPtr TestPlatformAbstraction::DecodeBuffer( const Integration::BitmapResourceType& resourceType, uint8_t * buffer, size_t size )
 {
   mTrace.PushCall("DecodeBuffer", "");
   return mDecodedBitmap;
index 230ed02..201e29d 100644 (file)
@@ -26,6 +26,7 @@
 
 // INTERNAL INCLUDES
 #include <dali/integration-api/platform-abstraction.h>
+#include <dali/public-api/math/vector2.h>
 
 #include "test-trace-call-stack.h"
 
@@ -71,12 +72,12 @@ public:
   /**
    * @copydoc PlatformAbstraction::LoadResourceSynchronously()
    */
-  virtual Integration::ResourcePointer LoadResourceSynchronously( const Integration::ResourceType& resourceType, const std::string& resourcePath );
+  virtual Integration::ResourcePointer LoadImageSynchronously( const Integration::BitmapResourceType& resourceType, const std::string& resourcePath );
 
   /**
    * @copydoc PlatformAbstraction::DecodeBuffer()
    */
-  virtual Integration::BitmapPtr DecodeBuffer( const Dali::Integration::ResourceType& resourceType, uint8_t * buffer, size_t size );
+  virtual Integration::BitmapPtr DecodeBuffer( const Dali::Integration::BitmapResourceType& resourceType, uint8_t * buffer, size_t size );
 
   /**
    * @copydoc PlatformAbstraction::LoadShaderBinaryFile()
@@ -176,7 +177,6 @@ private:
 
   mutable TraceCallStack        mTrace;
   bool                          mIsLoadingResult;
-  Vector2                       mSize;
   Vector2                       mClosestSize;
 
   LoadFileResult                mLoadFileResult;
@@ -188,4 +188,4 @@ private:
 
 } // Dali
 
-#endif /* __DALI_TET_PLATFORM_ABSTRACTION_H__ */
+#endif /* __DALI_TEST_PLATFORM_ABSTRACTION_H__ */
index 11a3356..f201516 100644 (file)
@@ -25,7 +25,7 @@ double GetTimeMilliseconds( Integration::PlatformAbstraction& abstraction )
 }
 
 /** Live platform abstraction recreated for each test case. */
-Integration::PlatformAbstraction * gAbstraction = 0;
+TizenPlatform::TizenPlatformAbstraction* gAbstraction = 0;
 
 /** A variety of parameters to reach different code paths in image loading code. */
 std::vector<ImageParameters> gCancelAttributes;
@@ -33,7 +33,7 @@ std::vector<ImageParameters> gCancelAttributes;
 void utc_dali_loading_startup(void)
 {
   test_return_value = TET_UNDEF;
-  gAbstraction = CreatePlatformAbstraction();
+  gAbstraction = TizenPlatform::CreatePlatformAbstraction();
 
   // Setup some loading parameters to engage post-processing stages:
 
index 3cb9cd0..7e5d3cb 100644 (file)
@@ -66,7 +66,7 @@ const unsigned NUM_VALID_IMAGES = sizeof(VALID_IMAGES) / sizeof(VALID_IMAGES[0])
 } // anon namespace
 
 /** Live platform abstraction recreated for each test case. */
-extern Integration::PlatformAbstraction * gAbstraction;
+extern TizenPlatform::TizenPlatformAbstraction* gAbstraction;
 
 /** A variety of parameters to reach different code paths in the image loading. */
 typedef std::pair<ImageDimensions, std::pair<FittingMode::Type, std::pair<SamplingMode::Type, bool> > > ImageParameters;
index fab51bc..be5f212 100755 (executable)
@@ -4,13 +4,9 @@ tizen_platform_abstraction_src_files = \
   $(tizen_platform_abstraction_src_dir)/tizen-platform-abstraction.cpp \
   $(tizen_platform_abstraction_src_dir)/tizen-logging.cpp \
   \
-  $(tizen_platform_abstraction_src_dir)/resource-loader/resource-loader.cpp \
-  \
   $(tizen_platform_abstraction_src_dir)/resource-loader/network/file-download.cpp \
   $(tizen_platform_abstraction_src_dir)/resource-loader/network/http-utils.cpp \
   \
-  $(tizen_platform_abstraction_src_dir)/resource-loader/debug/resource-loader-debug.cpp \
-  \
   $(tizen_platform_abstraction_src_dir)/image-loaders/loader-astc.cpp \
   $(tizen_platform_abstraction_src_dir)/image-loaders/loader-bmp.cpp \
   $(tizen_platform_abstraction_src_dir)/image-loaders/loader-gif.cpp \
index d1fb566..ab76a83 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2017 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.
@@ -41,7 +41,7 @@ namespace TizenPlatform
 
 namespace
 {
-typedef bool (*LoadBitmapFunction)( const ResourceLoadingClient& client, const ImageLoader::Input& input, Integration::Bitmap& bitmap );
+typedef bool (*LoadBitmapFunction)( const ImageLoader::Input& input, Integration::Bitmap& bitmap );
 typedef bool (*LoadBitmapHeaderFunction)( const ImageLoader::Input& input, unsigned int& width, unsigned int& height );
 
 #if defined(DEBUG_ENABLED)
@@ -252,10 +252,9 @@ bool GetBitmapLoaderFunctions( FILE *fp,
 namespace ImageLoader
 {
 
-bool ConvertStreamToBitmap( const ResourceType& resourceType, std::string path, FILE * const fp, const ResourceLoadingClient& client, BitmapPtr& ptr )
+bool ConvertStreamToBitmap( const BitmapResourceType& resource, std::string path, FILE * const fp, BitmapPtr& ptr )
 {
   DALI_LOG_TRACE_METHOD( gLogFilter );
-  DALI_ASSERT_DEBUG( ResourceBitmap == resourceType.id );
 
   bool result = false;
   BitmapPtr bitmap = 0;
@@ -275,16 +274,11 @@ bool ConvertStreamToBitmap( const ResourceType& resourceType, std::string path,
       bitmap = Bitmap::New( profile, ResourcePolicy::OWNED_DISCARD );
 
       DALI_LOG_SET_OBJECT_STRING( bitmap, path );
-      const BitmapResourceType& resType = static_cast<const BitmapResourceType&>( resourceType );
-      const ScalingParameters scalingParameters( resType.size, resType.scalingMode, resType.samplingMode );
-      const ImageLoader::Input input( fp, scalingParameters, resType.orientationCorrection );
-
-      // Check for cancellation now we have hit the filesystem, done some allocation, and burned some cycles:
-      // This won't do anything from synchronous API, it's only useful when called from another thread.
-      client.InterruptionPoint(); // Note: By design, this can throw an exception
+      const ScalingParameters scalingParameters( resource.size, resource.scalingMode, resource.samplingMode );
+      const ImageLoader::Input input( fp, scalingParameters, resource.orientationCorrection );
 
       // Run the image type decoder:
-      result = function( client, input, *bitmap );
+      result = function( input, *bitmap );
 
       if (!result)
       {
@@ -292,9 +286,7 @@ bool ConvertStreamToBitmap( const ResourceType& resourceType, std::string path,
         bitmap = 0;
       }
 
-      // Apply the requested image attributes if not interrupted:
-      client.InterruptionPoint(); // Note: By design, this can throw an exception
-      bitmap = Internal::Platform::ApplyAttributesToBitmap( bitmap, resType.size, resType.scalingMode, resType.samplingMode );
+      bitmap = Internal::Platform::ApplyAttributesToBitmap( bitmap, resource.size, resource.scalingMode, resource.samplingMode );
     }
     else
     {
@@ -306,22 +298,22 @@ bool ConvertStreamToBitmap( const ResourceType& resourceType, std::string path,
   return result;
 }
 
-ResourcePointer LoadResourceSynchronously( const Integration::ResourceType& resourceType, const std::string& resourcePath )
+ResourcePointer LoadImageSynchronously( const Integration::BitmapResourceType& resource, const std::string& path )
 {
-  ResourcePointer resource;
+  ResourcePointer result;
   BitmapPtr bitmap = 0;
 
-  Internal::Platform::FileCloser fc( resourcePath.c_str(), "rb");
+  Internal::Platform::FileCloser fc( path.c_str(), "rb");
   FILE * const fp = fc.GetFile();
   if( fp != NULL )
   {
-    bool result = ConvertStreamToBitmap( resourceType, resourcePath, fp, StubbedResourceLoadingClient(), bitmap );
-    if( result && bitmap )
+    bool success = ConvertStreamToBitmap( resource, path, fp, bitmap );
+    if( success && bitmap )
     {
-      resource.Reset(bitmap.Get());
+      result.Reset(bitmap.Get());
     }
   }
-  return resource;
+  return result;
 }
 
 ///@ToDo: Rename GetClosestImageSize() functions. Make them use the orientation correction and scaling information. Requires jpeg loader to tell us about reorientation. [Is there still a requirement for this functionality at all?]
index 02317b5..15469ba 100644 (file)
@@ -2,7 +2,7 @@
 #define __DALI_TIZEN_PLATFORM_IMAGE_LOADER_H__
 
 /*
- * Copyright (c) 2014 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2017 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.
@@ -22,9 +22,6 @@
 #include <dali/integration-api/resource-types.h>
 #include <dali/integration-api/bitmap.h>
 
-// INTERNAL INCLUDES
-#include "resource-loading-client.h"
-
 namespace Dali
 {
 namespace Integration
@@ -38,14 +35,13 @@ namespace ImageLoader
 {
 /**
  * Convert a file stream into a bitmap.
- * @param[in] resourceType The type of resource to convert.
+ * @param[in] resource The resource to convert.
  * @param[in] path The path to the resource.
  * @param[in] fp File Pointer. Closed on exit.
- * @param[in] client The component that is initiating the conversion.
  * @param[out] bitmap Pointer to write bitmap to
  * @return true on success, false on failure
  */
-bool ConvertStreamToBitmap( const Integration::ResourceType& resourceType, std::string path, FILE * const fp, const ResourceLoadingClient& client, Integration::BitmapPtr& ptr);
+bool ConvertStreamToBitmap( const Integration::BitmapResourceType& resource, std::string path, FILE * const fp, Integration::BitmapPtr& ptr );
 
 /**
  * Convert a bitmap and write to a file stream.
@@ -56,15 +52,26 @@ bool ConvertStreamToBitmap( const Integration::ResourceType& resourceType, std::
  */
 bool ConvertBitmapToStream( std::string path, FILE * const fp, Integration::BitmapPtr& ptr );
 
+/**
+ * Loads an image synchronously
+ * @param resource details of the image
+ * @param path to the image
+ * @return bitmap
+ */
+Integration::ResourcePointer LoadImageSynchronously( const Integration::BitmapResourceType& resource, const std::string& path );
 
-Integration::ResourcePointer LoadResourceSynchronously( const Integration::ResourceType& resourceType, const std::string& resourcePath );
-
+/**
+ * @returns the closest image size
+ */
 ImageDimensions  GetClosestImageSize( const std::string& filename,
                           ImageDimensions size,
                           FittingMode::Type fittingMode,
                           SamplingMode::Type samplingMode,
                           bool orientationCorrection );
 
+/**
+ * @returns the closest image size
+ */
 ImageDimensions GetClosestImageSize( Integration::ResourcePointer resourceBuffer,
                           ImageDimensions size,
                           FittingMode::Type fittingMode,
index b37cce4..aed1071 100755 (executable)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2016 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2017 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.
@@ -174,7 +174,7 @@ bool LoadAstcHeader( const ImageLoader::Input& input, unsigned int& width, unsig
 }
 
 // File loading API entry-point:
-bool LoadBitmapFromAstc( const ResourceLoadingClient& client, const ImageLoader::Input& input, Integration::Bitmap& bitmap )
+bool LoadBitmapFromAstc( const ImageLoader::Input& input, Integration::Bitmap& bitmap )
 {
   FILE* const filePointer = input.file;
   if( !filePointer )
index 6b43542..cb50b93 100644 (file)
@@ -2,7 +2,7 @@
 #define __DALI_TIZEN_PLATFORM_LOADER_ASTC_H__
 
 /*
- * Copyright (c) 2016 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2017 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.
@@ -45,12 +45,11 @@ const unsigned char MAGIC_BYTE_2 = 0xAB;
  * Loads a compressed bitmap image from a ASTC file without decoding it.
  * This function checks the header first
  * and if it is not a ASTC file, or the header contents are invalid, it will return a failure.
- * @param[in]     client todor
- * @param[in]     input  Information about the input image (including file pointer)
- * @param[in/out] bitmap The bitmap class where the decoded image will be stored
- * @return               True if file loaded successfully, false otherwise
+ * @param[in]  input  Information about the input image (including file pointer)
+ * @param[out] bitmap The bitmap class where the decoded image will be stored
+ * @return True if file loaded successfully, false otherwise
  */
-bool LoadBitmapFromAstc( const ResourceLoadingClient& client, const ImageLoader::Input& input, Integration::Bitmap& bitmap );
+bool LoadBitmapFromAstc( const ImageLoader::Input& input, Integration::Bitmap& bitmap );
 
 /**
  * Loads the header of a ASTC file and fills in the width and height appropriately.
index f1ddcbf..4082c5c 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2016 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2017 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.
@@ -1051,7 +1051,7 @@ bool LoadBmpHeader( const ImageLoader::Input& input, unsigned int& width, unsign
   return ret;
 }
 
-bool LoadBitmapFromBmp( const ResourceLoadingClient& client, const ImageLoader::Input& input, Integration::Bitmap& bitmap )
+bool LoadBitmapFromBmp( const ImageLoader::Input& input, Integration::Bitmap& bitmap )
 {
   DALI_ASSERT_DEBUG( bitmap.GetPackedPixelsProfile() != 0 && "Need a packed pixel bitmap to load into." );
   FILE* const fp = input.file;
index 41872aa..5328632 100644 (file)
@@ -2,7 +2,7 @@
 #define __DALI_TIZEN_PLATFORM_LOADER_BMP_H__
 
 /*
- * Copyright (c) 2014 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2017 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.
@@ -43,12 +43,11 @@ const unsigned char MAGIC_BYTE_2 = 0x4D;
 /**
  * Loads the bitmap from an BMP file.  This function checks the header first
  * and if it is not a BMP file, then it returns straight away.
- * @param[in]  fp      Pointer to the Image file
- * @param[in]  bitmap  The bitmap class where the decoded image will be stored
- * @param[in]  attributes  Describes the dimensions, pixel format and other details for loading the image data
+ * @param[in]  input  Information about the input image (including file pointer)
+ * @param[out] bitmap The bitmap class where the decoded image will be stored
  * @return  true if file decoded successfully, false otherwise
  */
-bool LoadBitmapFromBmp( const ResourceLoadingClient& client, const ImageLoader::Input& input, Integration::Bitmap& bitmap );
+bool LoadBitmapFromBmp( const ImageLoader::Input& input, Integration::Bitmap& bitmap );
 
 /**
  * Loads the header of a BMP file and fills in the width and height appropriately.
index 8f8481c..1891eb1 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2016 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2017 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.
@@ -298,7 +298,7 @@ bool LoadGifHeader( const ImageLoader::Input& input, unsigned int& width, unsign
   return LoadGifHeader(fp, width, height, &gifInfo);
 }
 
-bool LoadBitmapFromGif( const ResourceLoadingClient& client, const ImageLoader::Input& input, Integration::Bitmap& bitmap )
+bool LoadBitmapFromGif( const ImageLoader::Input& input, Integration::Bitmap& bitmap )
 {
   FILE* const fp = input.file;
   // Load the GIF Header file.
index d2afd3b..59d2591 100644 (file)
@@ -2,7 +2,7 @@
 #define __DALI_TIZEN_PLATFORM_LOADER_GIF_H__
 
 /*
- * Copyright (c) 2014 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2017 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.
@@ -44,12 +44,11 @@ const unsigned char MAGIC_BYTE_2 = 0x49;
  * Loads the bitmap from a GIF file.  This function checks the header first
  * and if it is not a GIF file, then it returns straight away.
  * @note For animated GIFs, only the first image is displayed
- * @param[in]  fp      Pointer to the Image file
- * @param[in]  bitmap  The bitmap class where the decoded image will be stored
- * @param[in]  attributes  Describes the dimensions, pixel format and other details for loading the image data
+ * @param[in]  input  Information about the input image (including file pointer)
+ * @param[out] bitmap The bitmap class where the decoded image will be stored
  * @return  true if file decoded successfully, false otherwise
  */
-bool LoadBitmapFromGif( const ResourceLoadingClient& client, const ImageLoader::Input& input, Integration::Bitmap& bitmap );
+bool LoadBitmapFromGif( const ImageLoader::Input& input, Integration::Bitmap& bitmap );
 
 /**
  * Loads the header of a GIF file and fills in the width and height appropriately.
index a7e5467..d58088b 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2016 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2017 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.
@@ -360,7 +360,7 @@ bool LoadIcoHeader( const ImageLoader::Input& input, unsigned int& width, unsign
   return true;
 }
 
-bool LoadBitmapFromIco( const ResourceLoadingClient& client, const ImageLoader::Input& input, Integration::Bitmap& bitmap )
+bool LoadBitmapFromIco( const ImageLoader::Input& input, Integration::Bitmap& bitmap )
 {
   IcoData chosen;
   Dali::Vector<unsigned char> map;
index 7b56737..3d9adb5 100644 (file)
@@ -2,7 +2,7 @@
 #define __DALI_TIZEN_PLATFORM_LOADER_ICO_H__
 
 /*
- * Copyright (c) 2014 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2017 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.
@@ -40,9 +40,19 @@ namespace Ico
 const unsigned char MAGIC_BYTE_1 = 0x00;
 const unsigned char MAGIC_BYTE_2 = 0x00;
 }
+/**
+ * @param[in]  input  Information about the input image (including file pointer)
+ * @param[out] bitmap The bitmap class where the decoded image will be stored
+ * @return  true if file decoded successfully, false otherwise
+ */
+bool LoadBitmapFromIco( const ImageLoader::Input& input, Integration::Bitmap& bitmap );
 
-bool LoadBitmapFromIco( const ResourceLoadingClient& client, const ImageLoader::Input& input, Integration::Bitmap& bitmap );
-
+/**
+ * @param[in]  input  Information about the input image (including file pointer)
+ * @param[out] width of image
+ * @param[out] height of image
+ * @return  true if header loaded successfully, false otherwise
+ */
 bool LoadIcoHeader( const ImageLoader::Input& input, unsigned int& width, unsigned int& height );
 
 }
index 067f1e2..6066192 100755 (executable)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2017 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.
@@ -17,9 +17,7 @@
 
 // INTERNAL HEADERS
 #include "loader-jpeg.h"
-#include "resource-loading-client.h"
 #include <dali/integration-api/bitmap.h>
-#include <resource-loader/debug/resource-loader-debug.h>
 #include "platform-capabilities.h"
 #include "image-operations.h"
 
@@ -226,7 +224,7 @@ bool LoadJpegHeader( FILE *fp, unsigned int &width, unsigned int &height )
   return true;
 }
 
-bool LoadBitmapFromJpeg( const ResourceLoadingClient& client, const ImageLoader::Input& input, Integration::Bitmap& bitmap )
+bool LoadBitmapFromJpeg( const ImageLoader::Input& input, Integration::Bitmap& bitmap )
 {
   const int flags= 0;
   FILE* const fp = input.file;
@@ -279,9 +277,6 @@ bool LoadBitmapFromJpeg( const ResourceLoadingClient& client, const ImageLoader:
     DALI_LOG_ERROR("Error seeking to start of file\n");
   }
 
-  // Allow early cancellation between the load and the decompress:
-  client.InterruptionPoint();
-
   AutoJpg autoJpg(tjInitDecompress());
 
   if(autoJpg.GetHandle() == NULL)
@@ -342,9 +337,6 @@ bool LoadBitmapFromJpeg( const ResourceLoadingClient& client, const ImageLoader:
 
   unsigned char * const bitmapPixelBuffer =  bitmap.GetPackedPixelsProfile()->ReserveBuffer(Pixel::RGB888, scaledPostXformWidth, scaledPostXformHeight);
 
-  // Allow early cancellation before decoding:
-  client.InterruptionPoint();
-
   if( tjDecompress2( autoJpg.GetHandle(), jpegBufferPtr, jpegBufferSize, bitmapPixelBuffer, scaledPreXformWidth, 0, scaledPreXformHeight, DECODED_PIXEL_LIBJPEG_TYPE, flags ) == -1 )
   {
     std::string errorString = tjGetErrorStr();
@@ -363,12 +355,6 @@ bool LoadBitmapFromJpeg( const ResourceLoadingClient& client, const ImageLoader:
   const unsigned int  bufferWidth  = GetTextureDimension( scaledPreXformWidth );
   const unsigned int  bufferHeight = GetTextureDimension( scaledPreXformHeight );
 
-  if( transform != JPGFORM_NONE )
-  {
-    // Allow early cancellation before shuffling pixels around on the CPU:
-    client.InterruptionPoint();
-  }
-
   bool result = false;
   switch(transform)
   {
index 65ccc2e..baf69b0 100644 (file)
@@ -2,7 +2,7 @@
 #define __DALI_TIZEN_PLATFORM_LOADER_JPEG_H__
 
 /*
- * Copyright (c) 2015 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2017 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.
@@ -46,12 +46,11 @@ const unsigned char MAGIC_BYTE_2 = 0xD8;
 /**
  * Loads the bitmap from an JPEG file.  This function checks the header first
  * and if it is not a JPEG file, then it returns straight away.
- * @param[in]  fp      Pointer to the Image file
- * @param[in]  bitmap  The bitmap class where the decoded image will be stored
- * @param[in]  attributes  Describes the dimensions, pixel format and other details for loading the image data
+ * @param[in]  input  Information about the input image (including file pointer)
+ * @param[out] bitmap The bitmap class where the decoded image will be stored
  * @return  true if file decoded successfully, false otherwise
  */
-bool LoadBitmapFromJpeg( const ResourceLoadingClient& client, const ImageLoader::Input& input, Integration::Bitmap& bitmap );
+bool LoadBitmapFromJpeg( const ImageLoader::Input& input, Integration::Bitmap& bitmap );
 
 /**
  * Loads the header of a JPEG file and fills in the width and height appropriately.
index 766eefe..2348b4d 100755 (executable)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2016 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2017 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.
@@ -515,7 +515,7 @@ bool LoadKtxHeader( const ImageLoader::Input& input, unsigned int& width, unsign
 }
 
 // File loading API entry-point:
-bool LoadBitmapFromKtx( const ResourceLoadingClient& client, const ImageLoader::Input& input, Integration::Bitmap& bitmap )
+bool LoadBitmapFromKtx( const ImageLoader::Input& input, Integration::Bitmap& bitmap )
 {
   DALI_COMPILE_TIME_ASSERT( sizeof(Byte) == 1);
   DALI_COMPILE_TIME_ASSERT( sizeof(uint32_t) == 4);
index 1728f81..c019ae8 100644 (file)
@@ -2,7 +2,7 @@
 #define __DALI_TIZEN_PLATFORM_LOADER_KTX_H__
 
 /*
- * Copyright (c) 2016 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2017 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.
@@ -44,12 +44,11 @@ const unsigned char MAGIC_BYTE_2 = 0x4B;
  * Loads a compressed bitmap from a KTX file without decoding it.
  * This function checks the header first
  * and if it is not a KTX file, then it returns straight away.
- * @param[in]  fp      Pointer to the Image file
- * @param[in]  bitmap  The bitmap class where the decoded image will be stored
- * @param[in]  attributes  Describes the dimensions, pixel format and other details for loading the image data
+ * @param[in]  input  Information about the input image (including file pointer)
+ * @param[out] bitmap The bitmap class where the decoded image will be stored
  * @return  true if file loaded successfully, false otherwise
  */
-bool LoadBitmapFromKtx( const ResourceLoadingClient& client, const ImageLoader::Input& input, Integration::Bitmap& bitmap );
+bool LoadBitmapFromKtx( const ImageLoader::Input& input, Integration::Bitmap& bitmap );
 
 /**
  * Loads the header of a KTX file and fills in the width and height appropriately.
index 7d19b56..42d5d34 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2017 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.
@@ -128,7 +128,7 @@ bool LoadPngHeader( const ImageLoader::Input& input, unsigned int& width, unsign
   return success;
 }
 
-bool LoadBitmapFromPng( const ResourceLoadingClient& client, const ImageLoader::Input& input, Integration::Bitmap& bitmap )
+bool LoadBitmapFromPng( const ImageLoader::Input& input, Integration::Bitmap& bitmap )
 {
   png_structp png = NULL;
   png_infop info = NULL;
index bfaab88..e676588 100644 (file)
@@ -2,7 +2,7 @@
 #define __DALI_TIZEN_PLATFORM_LOADER_PNG_H__
 
 /*
- * Copyright (c) 2015 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2017 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.
@@ -46,12 +46,11 @@ const unsigned char MAGIC_BYTE_2 = 0x50;
 /**
  * Loads the bitmap from an PNG file.  This function checks the header first
  * and if it is not a PNG file, then it returns straight away.
- * @param[in]  fp      Pointer to the Image file
- * @param[in]  bitmap  The bitmap class where the decoded image will be stored
- * @param[in]  attributes  Describes the dimensions, pixel format and other details for loading the image data
+ * @param[in]  input  Information about the input image (including file pointer)
+ * @param[out] bitmap The bitmap class where the decoded image will be stored
  * @return  true if file decoded successfully, false otherwise
  */
-bool LoadBitmapFromPng( const ResourceLoadingClient& client, const ImageLoader::Input& input, Integration::Bitmap& bitmap );
+bool LoadBitmapFromPng( const ImageLoader::Input& input, Integration::Bitmap& bitmap );
 
 /**
  * Loads the header of a PNG file and fills in the width and height appropriately.
index f042ce7..d4d6466 100755 (executable)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2017 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.
@@ -92,7 +92,7 @@ int extractMultiByteInteger(unsigned int *data, void *map, size_t length, size_t
 
 }// end unnamed namespace
 
-bool LoadBitmapFromWbmp( const ResourceLoadingClient& client, const ImageLoader::Input& input, Integration::Bitmap& bitmap )
+bool LoadBitmapFromWbmp( const ImageLoader::Input& input, Integration::Bitmap& bitmap )
 {
   FILE* const fp = input.file;
   if(fp == NULL)
index 30c94a5..a2040a0 100755 (executable)
@@ -2,7 +2,7 @@
 #define __DALI_TIZEN_PLATFORM_LOADER_WBMP_H__
 
 /*
- * Copyright (c) 2014 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2017 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.
@@ -34,8 +34,19 @@ namespace TizenPlatform
 
 class ResourceLoadingClient;
 
-bool LoadBitmapFromWbmp( const ResourceLoadingClient& client, const ImageLoader::Input& input, Integration::Bitmap& bitmap );
+/**
+ * @param[in]  input  Information about the input image (including file pointer)
+ * @param[out] bitmap The bitmap class where the decoded image will be stored
+ * @return  true if file decoded successfully, false otherwise
+ */
+bool LoadBitmapFromWbmp( const ImageLoader::Input& input, Integration::Bitmap& bitmap );
 
+/**
+ * @param[in]  input  Information about the input image (including file pointer)
+ * @param[out] width of image
+ * @param[out] height of image
+ * @return  true if header loaded successfully, false otherwise
+ */
 bool LoadWbmpHeader( const ImageLoader::Input& input, unsigned int& width, unsigned int& height );
 
 }
diff --git a/platform-abstractions/tizen/resource-loader/debug/resource-loader-debug.cpp b/platform-abstractions/tizen/resource-loader/debug/resource-loader-debug.cpp
deleted file mode 100644 (file)
index 11f0a83..0000000
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- * Copyright (c) 2014 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.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-#include "resource-loader-debug.h"
-
-#if defined(DEBUG_ENABLED)
-
-namespace Dali
-{
-namespace TizenPlatform
-{
-using namespace Dali::Integration;
-
-/**
- * Filter for resource loader debug. Change levels here to turn on debugging
- */
-Debug::Filter* gLoaderFilter = Debug::Filter::New(Debug::Concise, false, "LOG_RESOURCE_LOADER");
-
-} //TizenPlatform
-} //Dali
-
-#endif
diff --git a/platform-abstractions/tizen/resource-loader/debug/resource-loader-debug.h b/platform-abstractions/tizen/resource-loader/debug/resource-loader-debug.h
deleted file mode 100644 (file)
index cc6f774..0000000
+++ /dev/null
@@ -1,38 +0,0 @@
-#ifndef __DALI_TIZEN_PLATFORM_RESOURCE_LOADER_DEBUG_H__
-#define __DALI_TIZEN_PLATFORM_RESOURCE_LOADER_DEBUG_H__
-
-/*
- * Copyright (c) 2014 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.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-#include <dali/integration-api/debug.h>
-#if defined(DEBUG_ENABLED)
-
-#include <platform-abstractions/tizen/resource-loader/resource-loader.h>
-
-
-namespace Dali
-{
-namespace TizenPlatform
-{
-
-extern Debug::Filter* gLoaderFilter;
-
-} // TizenPlatform
-} // Dali
-
-#endif // defined(DEBUG_ENABLED)
-#endif //__DALI_TIZEN_PLATFORM_RESOURCE_LOADER_DEBUG_H__
diff --git a/platform-abstractions/tizen/resource-loader/resource-loader.cpp b/platform-abstractions/tizen/resource-loader/resource-loader.cpp
deleted file mode 100755 (executable)
index 38222b8..0000000
+++ /dev/null
@@ -1,95 +0,0 @@
-/*
- * Copyright (c) 2016 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.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-// CLASS HEADER
-#include "resource-loader.h"
-
-// EXTERNAL HEADERS
-#include <iostream>
-#include <fstream>
-#include <queue>
-#include <cstring>
-#include <dali/devel-api/common/map-wrapper.h>
-#include <dali/devel-api/threading/mutex.h>
-
-// INTERNAL HEADERS
-#include <dali/integration-api/bitmap.h>
-#include <dali/integration-api/debug.h>
-#include <dali/public-api/common/dali-common.h>
-#include <dali/devel-api/common/set-wrapper.h>
-#include <dali/public-api/math/vector2.h>
-#include "debug/resource-loader-debug.h"
-
-using namespace Dali::Integration;
-
-namespace Dali
-{
-
-namespace TizenPlatform
-{
-
-/********************************************************************************/
-/****************************   RESOURCE LOADER METHODS  ************************/
-/********************************************************************************/
-ResourceLoader::ResourceLoader()
-{
-}
-
-ResourceLoader::~ResourceLoader()
-{
-}
-
-bool ResourceLoader::SaveFile(const std::string& filename, const unsigned char * buffer, unsigned int numBytes )
-{
-  DALI_LOG_TRACE_METHOD(gLoaderFilter);
-
-  DALI_ASSERT_DEBUG( 0 != filename.length());
-
-  bool result = false;
-
-  std::filebuf buf;
-  buf.open(filename.c_str(), std::ios::out | std::ios_base::trunc | std::ios::binary);
-  if( buf.is_open() )
-  {
-    std::ostream stream(&buf);
-
-    // determine size of buffer
-    int length = static_cast<int>(numBytes);
-
-    // write contents of buffer to the file
-    stream.write(reinterpret_cast<const char*>(buffer), length);
-
-    if( !stream.bad() )
-    {
-      DALI_LOG_INFO(gLoaderFilter, Debug::Verbose, "ResourceLoader::SaveFile(%s) - wrote %d bytes\n", filename.c_str(), length);
-      result = true;
-    }
-  }
-
-#if defined(DEBUG_BUILD)
-  if( !result )
-  {
-    DALI_LOG_INFO(gLoaderFilter, Debug::Verbose, "ResourceLoader::SaveFile(%s) - failed to load\n", filename.c_str());
-  }
-#endif
-
-  return result;
-}
-
-} // namespace TizenPlatform
-
-} // namespace Dali
diff --git a/platform-abstractions/tizen/resource-loader/resource-loader.h b/platform-abstractions/tizen/resource-loader/resource-loader.h
deleted file mode 100644 (file)
index c595539..0000000
+++ /dev/null
@@ -1,136 +0,0 @@
-#ifndef __DALI_TIZEN_PLATFORM_RESOURCE_LOADER_H__
-#define __DALI_TIZEN_PLATFORM_RESOURCE_LOADER_H__
-
-/*
- * Copyright (c) 2014 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.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-#include <dali/integration-api/platform-abstraction.h>
-#include <dali/public-api/common/dali-vector.h>
-
-#include <string>
-
-namespace Dali
-{
-
-namespace Integration
-{
-namespace Log
-{
-class Filter;
-}
-}
-
-namespace TizenPlatform
-{
-
-/**
- * Contains information about a successfully loaded resource
- */
-struct LoadedResource
-{
-  /**
-   * Constructor
-   * @param[in] loadedId        The ID of the resource
-   * @param[in] loadedType      The resource type
-   * @param[in] loadedResource  A pointer to the loaded resource data
-   */
-  LoadedResource(Integration::ResourceId      loadedId,
-                 Integration::ResourceTypeId  loadedType,
-                 Integration::ResourcePointer loadedResource)
-  : id(loadedId),
-    type(loadedType),
-    resource(loadedResource)
-  {
-  }
-
-  /// Copy constructor
-  LoadedResource(const LoadedResource& loaded)
-  : id(loaded.id),
-    type(loaded.type),
-    resource(loaded.resource)
-  {
-  }
-
-  /// Assignment operator
-  LoadedResource& operator=(const LoadedResource& rhs)
-  {
-    if( this != &rhs )
-    {
-      id = rhs.id;
-      type = rhs.type;
-      resource = rhs.resource;
-    }
-    return *this;
-  }
-
-  Integration::ResourceId      id;         ///< Integer ID
-  Integration::ResourceTypeId  type;       ///< Type enum (bitmap, ...)
-  Integration::ResourcePointer resource;   ///< Reference counting pointer to the loaded / decoded representation  of the resource.
-};
-
-/**
- * Contains information about a failed resource load/save request
- */
-struct FailedResource
-{
-};
-
-/**
- * This implements the resource loading part of the PlatformAbstraction API.
- * The requests for a specific resource type are farmed-out to a resource
- * requester for that type which handles them in their own dedicated loading
- * threads.
- */
-class ResourceLoader
-{
-public:
-
-  /**
-   * Create a resource loader.
-   * There should exactly one of these objects per Dali Core.
-   */
-  ResourceLoader();
-
-  /**
-   * Non-virtual destructor.
-   * ResourceLoader is NOT intended as a base class.
-   */
-  ~ResourceLoader();
-
-  // From PlatformAbstraction
-
-  /**
-   * @copydoc TizenPlatformAbstraction::SaveFile()
-   */
-  static bool SaveFile( const std::string& filename, const unsigned char * buffer, unsigned int numBytes );
-
-private:
-  // Undefined
-  ResourceLoader( const ResourceLoader& resourceLoader );
-
-  // Undefined
-  ResourceLoader& operator=( const ResourceLoader& resourceLoader );
-
-private:
-
-};
-
-} // namespace TizenPlatform
-
-} // namespace Dali
-
-#endif // __DALI_TIZEN_PLATFORM_RESOURCE_LOADER_H_
diff --git a/platform-abstractions/tizen/resource-loader/resource-loading-client.h b/platform-abstractions/tizen/resource-loader/resource-loading-client.h
deleted file mode 100644 (file)
index 27c07f0..0000000
+++ /dev/null
@@ -1,84 +0,0 @@
-#ifndef _DALI_PLATFORM_RESOURCE_LOADING_CLIENT_H_
-#define _DALI_PLATFORM_RESOURCE_LOADING_CLIENT_H_
-/*
- * Copyright (c) 2014 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.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-// INTERNAL INCLUDES
-
-// EXTERNAL INCLUDES
-
-namespace Dali
-{
-namespace TizenPlatform
-{
-
-/**
- * @brief Abstract interface to the caller of a low-level resource loading
- * function such as a loader for an image format.
- */
-class ResourceLoadingClient
-{
-public:
-  /**
-   * @brief Check whether the current request has been cancelled.
-   *
-   * This will throw an exception to unwind the stack if the current request
-   * has been cancelled.
-   *
-   * @note Only place calls to this function at exception-safe locations in loader code.
-   **/
-  virtual void InterruptionPoint() const = 0;
-
-protected:
-  /** Construction is restricted to derived / implementing classes. */
-  ResourceLoadingClient() {}
-  /** Destruction of an object through this interface is not allowed. */
-  ~ResourceLoadingClient() {}
-
-private:
-  ResourceLoadingClient( const ResourceLoadingClient& rhs );
-  ResourceLoadingClient& operator =( ResourceLoadingClient& rhs );
-};
-
-/**
- * @brief Default implementation of a caller of a low-level resource loading
- * function which does nothing.
- */
-class StubbedResourceLoadingClient : public ResourceLoadingClient
-{
-public:
-  /**
-   * @brief Check whether the current request has been cancelled.
-   *
-   * This does nothing and so can never throw an exception.
-   **/
-  virtual void InterruptionPoint() const {}
-
-  /** Construction is a NOP. */
-  StubbedResourceLoadingClient() {}
-  /** Destruction has no work to do. */
-  ~StubbedResourceLoadingClient() {}
-
-private:
-  StubbedResourceLoadingClient( const StubbedResourceLoadingClient& rhs );
-  StubbedResourceLoadingClient& operator =( StubbedResourceLoadingClient& rhs );
-};
-
-} /* namespace TizenPlatform */
-} /* namespace Dali */
-
-#endif /* _DALI_PLATFORM_RESOURCE_LOADING_CLIENT_H_ */
index 0ca22e4..959e338 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2017 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.
  *
  */
 
+// CLASS HEADER
 #include "tizen-platform-abstraction.h"
 
-#ifndef DALI_PROFILE_UBUNTU
-#include <vconf.h>
-#endif // DALI_PROFILE_UBUNTU
+// EXTERNAL INCLUDES
 #include <dirent.h>
-
+#include <fstream>
 #include <dali/integration-api/debug.h>
 #include <dali/integration-api/bitmap.h>
 #include <dali/integration-api/resource-types.h>
 
 // INTERNAL INCLUDES
-#include "resource-loader/resource-loader.h"
 #include "image-loaders/image-loader.h"
 #include "portable/file-closer.h"
 
 namespace Dali
 {
 
-Integration::PlatformAbstraction* CreatePlatformAbstraction()
-{
-  return new TizenPlatform::TizenPlatformAbstraction();
-}
-
-
 namespace TizenPlatform
 {
 
 TizenPlatformAbstraction::TizenPlatformAbstraction()
-: mResourceLoader(new ResourceLoader),
-  mDataStoragePath( "" )
+: mDataStoragePath( "" )
 {
 }
 
 TizenPlatformAbstraction::~TizenPlatformAbstraction()
 {
-  delete mResourceLoader;
-}
-
-int TizenPlatformAbstraction::GetDefaultFontSize() const
-{
-  int fontSize( -1 );
-
-#ifndef DALI_PROFILE_UBUNTU
-  vconf_get_int( VCONFKEY_SETAPPL_ACCESSIBILITY_FONT_SIZE, &fontSize );
-#endif // DALI_PROFILE_UBUNTU
-
-  return fontSize;
 }
 
 ImageDimensions TizenPlatformAbstraction::GetClosestImageSize( const std::string& filename,
@@ -83,12 +62,12 @@ ImageDimensions TizenPlatformAbstraction::GetClosestImageSize( Integration::Reso
   return ImageLoader::GetClosestImageSize( resourceBuffer, size, fittingMode, samplingMode, orientationCorrection );
 }
 
-Integration::ResourcePointer TizenPlatformAbstraction::LoadResourceSynchronously(const Integration::ResourceType& resourceType, const std::string& resourcePath)
+Integration::ResourcePointer TizenPlatformAbstraction::LoadImageSynchronously(const Integration::BitmapResourceType& resource, const std::string& resourcePath)
 {
-  return ImageLoader::LoadResourceSynchronously( resourceType, resourcePath );
+  return ImageLoader::LoadImageSynchronously( resource, resourcePath );
 }
 
-Integration::BitmapPtr TizenPlatformAbstraction::DecodeBuffer( const Integration::ResourceType& resourceType, uint8_t * buffer, size_t size )
+Integration::BitmapPtr TizenPlatformAbstraction::DecodeBuffer( const Integration::BitmapResourceType& resource, uint8_t * buffer, size_t size )
 {
   Integration::BitmapPtr bitmap = 0;
 
@@ -96,7 +75,7 @@ Integration::BitmapPtr TizenPlatformAbstraction::DecodeBuffer( const Integration
   FILE * const fp = fileCloser.GetFile();
   if( fp )
   {
-    bool result = ImageLoader::ConvertStreamToBitmap( resourceType, "", fp, StubbedResourceLoadingClient(), bitmap );
+    bool result = ImageLoader::ConvertStreamToBitmap( resource, "", fp, bitmap );
     if ( !result || !bitmap )
     {
       bitmap.Reset();
@@ -115,12 +94,9 @@ bool TizenPlatformAbstraction::LoadShaderBinaryFile( const std::string& filename
   std::string path;
 
   // First check the system location where shaders are stored at install time:
-  if( mResourceLoader )
-  {
-    path = DALI_SHADERBIN_DIR;
-    path += filename;
-    result = mResourceLoader->LoadFile( path, buffer );
-  }
+  path = DALI_SHADERBIN_DIR;
+  path += filename;
+  result = LoadFile( path, buffer );
 
   // Fallback to the cache of shaders stored after previous runtime compilations:
   // On desktop this looks in the current working directory that the app was launched from.
@@ -128,7 +104,7 @@ bool TizenPlatformAbstraction::LoadShaderBinaryFile( const std::string& filename
   {
     path = mDataStoragePath;
     path += filename;
-    result = mResourceLoader->LoadFile( path, buffer );
+    result = LoadFile( path, buffer );
   }
 #endif
 
@@ -141,14 +117,12 @@ bool TizenPlatformAbstraction::SaveShaderBinaryFile( const std::string& filename
 
 #ifdef SHADERBIN_CACHE_ENABLED
 
-    // Fallback to the cache of shaders stored after previous runtime compilations:
-    // On desktop this looks in the current working directory that the app was launched from.
-    if( mResourceLoader )
-    {
-      std::string path = mDataStoragePath;
-      path += filename;
-      result = mResourceLoader->SaveFile( path, buffer, numBytes );
-    }
+  // Use the cache of shaders stored after previous runtime compilations:
+  // On desktop this looks in the current working directory that the app was launched from.
+  std::string path = mDataStoragePath;
+  path += filename;
+  result = SaveFile( path, buffer, numBytes );
+
 #endif
 
   return result;
@@ -159,6 +133,38 @@ void TizenPlatformAbstraction::SetDataStoragePath( const std::string& path )
   mDataStoragePath = path;
 }
 
+TizenPlatformAbstraction* CreatePlatformAbstraction()
+{
+  return new TizenPlatformAbstraction();
+}
+
+bool SaveFile( const std::string& filename, const unsigned char * buffer, unsigned int numBytes )
+{
+  DALI_ASSERT_DEBUG( 0 != filename.length());
+
+  bool result = false;
+
+  std::filebuf buf;
+  buf.open(filename.c_str(), std::ios::out | std::ios_base::trunc | std::ios::binary);
+  if( buf.is_open() )
+  {
+    std::ostream stream(&buf);
+
+    // determine size of buffer
+    int length = static_cast<int>(numBytes);
+
+    // write contents of buffer to the file
+    stream.write(reinterpret_cast<const char*>(buffer), length);
+
+    if( !stream.bad() )
+    {
+      result = true;
+    }
+  }
+
+  return result;
+}
+
 }  // namespace TizenPlatform
 
 }  // namespace Dali
index 3e61966..13db481 100644 (file)
 namespace Dali
 {
 
-/**
- * Construct a platform abstraction and return it.
- */
-Integration::PlatformAbstraction* CreatePlatformAbstraction();
-
 namespace TizenPlatform
 {
 
@@ -75,19 +70,14 @@ public: // PlatformAbstraction overrides
                                                bool orientationCorrection );
 
   /**
-   * @copydoc PlatformAbstraction::LoadResourceSynchronously()
+   * @copydoc PlatformAbstraction::LoadImageSynchronously()
    */
-  virtual Integration::ResourcePointer LoadResourceSynchronously(const Integration::ResourceType& resourceType, const std::string& resourcePath);
+  virtual Integration::ResourcePointer LoadImageSynchronously(const Integration::BitmapResourceType& resource, const std::string& resourcePath);
 
   /**
    * @copydoc PlatformAbstraction::DecodeBuffer()
    */
-  virtual Integration::BitmapPtr DecodeBuffer( const Integration::ResourceType& resourceType, uint8_t * buffer, size_t size );
-
-  /**
-   * @copydoc PlatformAbstraction::GetDefaultFontSize()
-   */
-  virtual int GetDefaultFontSize() const;
+  virtual Integration::BitmapPtr DecodeBuffer( const Integration::BitmapResourceType& resource, uint8_t * buffer, size_t size );
 
   /**
    * @copydoc PlatformAbstraction::LoadShaderBinaryFile()
@@ -110,11 +100,27 @@ private:
   TizenPlatformAbstraction( const TizenPlatformAbstraction& ); ///< Undefined
   TizenPlatformAbstraction& operator=( const TizenPlatformAbstraction& ); ///< Undefined
 
-  ResourceLoader* mResourceLoader;
   std::string mDataStoragePath;
+
 };
 
+/**
+ * Construct a platform abstraction and return it.
+ * @return TizenPlatformAbstraction instance
+ */
+TizenPlatformAbstraction* CreatePlatformAbstraction();
+
+/**
+ * Save a file to disk
+ * @param filename to create
+ * @param buffer to store
+ * @param numBytes to store
+ * @return true if successful, false otherwise
+ */
+bool SaveFile( const std::string& filename, const unsigned char * buffer, unsigned int numBytes );
+
 }  // namespace TizenPlatform
+
 }  // namespace Dali
 
 #endif // __DALI_TIZEN_PLATFORM_ABSTRACTION_H__