Cleanup ResourceLoading and PlatformAbstraction 82/129982/3
authorKimmo Hoikka <kimmo.hoikka@samsung.com>
Thu, 18 May 2017 17:04:28 +0000 (18:04 +0100)
committerKimmo Hoikka <kimmo.hoikka@samsung.com>
Thu, 25 May 2017 12:27:04 +0000 (13:27 +0100)
- Removed ResourceType base class
- Clarified PlatformAbstraction methods

Change-Id: I0811af69e8781136cde0d6f62fe49bc820d577c8

automated-tests/src/dali/dali-test-suite-utils/test-platform-abstraction.cpp
automated-tests/src/dali/dali-test-suite-utils/test-platform-abstraction.h
dali/integration-api/platform-abstraction.h
dali/integration-api/resource-types.h
dali/internal/event/images/nine-patch-image-impl.cpp
dali/internal/event/images/resource-image-impl.cpp

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 db2586b..7a41087 100644 (file)
@@ -2,7 +2,7 @@
 #define __DALI_INTEGRATION_PLATFORM_ABSTRACTION_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.
@@ -42,11 +42,6 @@ class PlatformAbstraction
 {
 public:
 
-  /**
-   * Virtual destructor.
-   */
-  virtual ~PlatformAbstraction() {}
-
   // Resource Loading
 
   /**
@@ -94,8 +89,8 @@ public:
                                                bool orientationCorrection = true) = 0;
 
   /**
-   * Request a resource from the native filesystem. This is a synchronous request, i.e.
-   * it will block the main loop whilst executing. It should therefore be used sparingly.
+   * Request an image from the native filesystem. This is a synchronous request, i.e.
+   * it will block the main loop whilst executing.
    *
    * Multi-threading note: this method will be called from the main thread only i.e. not
    * from within the Core::Render() method.
@@ -103,7 +98,7 @@ public:
    * @param[in] resourcePath The path to the resource
    * @return A pointer to a ref-counted resource
    */
-  virtual ResourcePointer LoadResourceSynchronously( const ResourceType& resourceType, const std::string& resourcePath ) = 0;
+  virtual ResourcePointer LoadImageSynchronously( const BitmapResourceType& resourceType, const std::string& resourcePath ) = 0;
 
   /**
    * Decode a buffer of data synchronously.
@@ -113,7 +108,7 @@ public:
    *
    * @return A pointer to the decoded buffer.
    */
-  virtual BitmapPtr DecodeBuffer( const ResourceType& resourceType, uint8_t * buffer, size_t bufferSize ) = 0;
+  virtual BitmapPtr DecodeBuffer( const BitmapResourceType& resourceType, uint8_t * buffer, size_t bufferSize ) = 0;
 
   /**
    * Load a shader binary file into a buffer
@@ -132,6 +127,13 @@ public:
    */
   virtual bool SaveShaderBinaryFile( const std::string& filename, const unsigned char * buffer, unsigned int numBytes ) const = 0;
 
+protected:
+
+  /**
+   * Virtual destructor.
+   */
+  virtual ~PlatformAbstraction() {}
+
 }; // class PlatformAbstraction
 
 } // namespace Integration
index d793a0c..2ca2293 100644 (file)
 
 // EXTERNAL INCLUDES
 #include <stdint.h>
-#include <string>
 
 // INTERNAL INCLUDES
-#include <dali/public-api/common/dali-common.h>
-#include <dali/public-api/common/vector-wrapper.h>
 #include <dali/public-api/images/image-operations.h>
 #include <dali/public-api/math/uint-16-pair.h>
-#include <dali/public-api/math/vector2.h>
 
 namespace Dali
 {
@@ -37,55 +33,10 @@ typedef Uint16Pair ImageDimensions;
 namespace Integration
 {
 
-// Resource Types
-
-/**
- * Extendable set of resource types
- */
-enum ResourceTypeId
-{
-  ResourceBitmap
-};
-
-/**
- * The abstract base class for resource types.
- */
-struct ResourceType
-{
-  /**
-   * Constructor.
-   * @param[in] typeId resource type id
-   */
-  ResourceType(ResourceTypeId typeId)
-  : id(typeId) {}
-
-  /**
-   * Destructor.
-   */
-  virtual ~ResourceType() {}
-
-  /**
-   * Create a copy of the resource type with the same attributes.
-   * @return pointer to the new ResourceType.
-   */
-  virtual ResourceType* Clone() const = 0;
-
-  const ResourceTypeId id;
-
-private:
-
-  // Undefined copy constructor.
-  ResourceType(const ResourceType& typePath);
-
-  // Undefined assignment operator.
-  ResourceType& operator=(const ResourceType& rhs);
-};
-
 /**
- * BitmapResourceType describes a bitmap resource, which can be requested
- * from ResourceLoader::LoadResource() or AllocateBitmapImage.
+ * BitmapResourceType describes a bitmap resource.
  */
-struct BitmapResourceType : public ResourceType
+struct BitmapResourceType
 {
   /**
    * Constructor.
@@ -101,21 +52,17 @@ struct BitmapResourceType : public ResourceType
                       FittingMode::Type scalingMode = FittingMode::DEFAULT,
                       SamplingMode::Type samplingMode = SamplingMode::DEFAULT,
                       bool orientationCorrection = true )
-  : ResourceType(ResourceBitmap),
-    size(size), scalingMode(scalingMode), samplingMode(samplingMode), orientationCorrection(orientationCorrection) {}
+  : size( size ),
+    scalingMode( scalingMode ),
+    samplingMode( samplingMode ),
+    orientationCorrection( orientationCorrection )
+  {}
 
   /**
    * Destructor.
    */
-  virtual ~BitmapResourceType() {}
-
-  /**
-   * @copydoc ResourceType::Clone
-   */
-  virtual ResourceType* Clone() const
-  {
-    return new BitmapResourceType( size, scalingMode, samplingMode, orientationCorrection );
-  }
+  ~BitmapResourceType()
+  {}
 
   /**
    * Attributes are copied from the request.
@@ -132,6 +79,7 @@ private:
 
   // Undefined assignment operator.
   BitmapResourceType& operator=(const BitmapResourceType& rhs);
+
 };
 
 } // namespace Integration
index 97842b6..24b5e6f 100644 (file)
@@ -181,7 +181,7 @@ NinePatchImage::NinePatchImage( const std::string& filename )
   Integration::BitmapResourceType resourceType;
 
   // Note, bitmap is only destroyed when the image is destroyed.
-  Integration::ResourcePointer resource = platformAbstraction.LoadResourceSynchronously( resourceType, filename );
+  Integration::ResourcePointer resource = platformAbstraction.LoadImageSynchronously( resourceType, filename );
   if( resource )
   {
     mBitmap = static_cast<Integration::Bitmap*>( resource.Get());
index 26114ac..dc116cc 100644 (file)
@@ -147,7 +147,7 @@ void ResourceImage::Reload()
                                                 mAttributes.GetOrientationCorrection() );
 
   // Note, bitmap is only destroyed when the image is destroyed.
-  Integration::ResourcePointer resource = platformAbstraction.LoadResourceSynchronously( resourceType, mUrl );
+  Integration::ResourcePointer resource = platformAbstraction.LoadImageSynchronously( resourceType, mUrl );
   if( resource )
   {
     Integration::Bitmap* bitmap = static_cast<Integration::Bitmap*>( resource.Get() );