Merge "Remove RenderableActor" into devel/master
[platform/core/uifw/dali-core.git] / dali / integration-api / platform-abstraction.h
index 5f7601e..59a5cbb 100644 (file)
  */
 
 // INTERNAL INCLUDES
-#include <dali/integration-api/bitmap.h>
+
 #include <dali/integration-api/resource-cache.h>
+#include <dali/integration-api/bitmap.h> ///@todo Remove this include (a bunch of stuff needs to include it though)
+#include <dali/public-api/images/image-operations.h>
+#include <dali/public-api/common/dali-vector.h>
 
 namespace Dali
 {
@@ -28,10 +31,6 @@ namespace Dali
 namespace Integration
 {
 
-class Bitmap;
-class DynamicsFactory;
-
-
 /**
  * PlatformAbstraction is an abstract interface, used by Dali to access platform specific services.
  * A concrete implementation must be created for each platform, and provided when creating the
@@ -63,7 +62,7 @@ public:
    * to cooperate with other apps and reduce the chance of this one being
    * force-killed in a low memory situation.
    */
-  virtual void Suspend() {} ///!ToDo: Make pure virtual once dali-adaptor patch is in place = 0;
+  virtual void Suspend() = 0;
 
   /**
    * Tell the platform abstraction that Dali is resuming from a pause, such as
@@ -71,35 +70,53 @@ public:
    * It is time to wake up sleeping background threads and recreate memory
    * caches and other temporary data.
    */
-  virtual void Resume() {} ///!ToDo: Make pure virtual once dali-adaptor patch is in place = 0;
+  virtual void Resume() = 0;
 
   // Resource Loading
 
   /**
-   * Determine the size of an image the resource loaders will provide when given the same
-   * image attributes.
+   * @brief Determine the size of an image the resource loaders will provide when
+   * given the same image loading parameters.
+   *
    * This is a synchronous request.
    * This function is used to determine the size of an image before it has loaded.
    * @param[in] filename name of the image.
-   * @param[in] attributes The attributes used to load the image
-   * @param[out] closestSize Size of the image that will be loaded.
-   */
-  virtual void GetClosestImageSize( const std::string& filename,
-                                    const ImageAttributes& attributes,
-                                    Vector2& closestSize ) = 0;
-
-  /**
-   * Determine the size of an image the resource loaders will provide when given the same
-   * image attributes.
+   * @param[in] size The requested size for the image.
+   * @param[in] fittingMode The method to use to map the source image to the desired
+   * dimensions.
+   * @param[in] samplingMode The image filter to use if the image needs to be
+   * downsampled to the requested size.
+   * @param[in] orientationCorrection Whether to use image metadata to rotate or
+   * flip the image, e.g., from portrait to landscape.
+   * @return dimensions that image will have if it is loaded with given parameters.
+   */
+  virtual ImageDimensions GetClosestImageSize( const std::string& filename,
+                                               ImageDimensions size = ImageDimensions( 0, 0 ),
+                                               FittingMode::Type fittingMode = FittingMode::SHRINK_TO_FIT,
+                                               SamplingMode::Type samplingMode = SamplingMode::BOX,
+                                               bool orientationCorrection = true) = 0;
+
+  /**
+   @brief Determine the size of an image the resource loaders will provide when
+   * given the same image loading parameters.
+   *
    * This is a synchronous request.
    * This function is used to determine the size of an image before it has loaded.
-   * @param[in] resourceBuffer A pointer to an encoded image buffer
-   * @param[in] attributes The attributes used to load the image
-   * @param[out] closestSize Size of the image that will be loaded.
-   */
-  virtual void GetClosestImageSize( ResourcePointer resourceBuffer,
-                                    const ImageAttributes& attributes,
-                                    Vector2& closestSize ) = 0;
+   * @param[in] filename name of the image.
+   * @param[in] size The requested size for the image.
+   * @param[in] fittingMode The method to use to map the source image to the desired
+   * dimensions.
+   * @param[in] samplingMode The image filter to use if the image needs to be
+   * downsampled to the requested size.
+   * @param[in] orientationCorrection Whether to use image metadata to rotate or
+   * flip the image, e.g., from portrait to landscape.
+   * @return dimensions that image will have if it is loaded with given parameters.
+   */
+  virtual ImageDimensions GetClosestImageSize( ResourcePointer resourceBuffer,
+                                               ImageDimensions size = ImageDimensions( 0, 0 ),
+                                               FittingMode::Type fittingMode = FittingMode::SHRINK_TO_FIT,
+                                               SamplingMode::Type samplingMode = SamplingMode::BOX,
+                                               bool orientationCorrection = true) = 0;
 
   /**
    * Request a resource from the native filesystem. This is an asynchronous request.
@@ -129,6 +146,7 @@ public:
    * This is an asynchronous request.
    */
   virtual void SaveResource(const ResourceRequest& request) = 0;
+
   /**
    * Cancel an ongoing LoadResource() request.
    * Multi-threading note: this method will be called from the main thread only i.e. not
@@ -161,6 +179,27 @@ public:
    */
   virtual void JoinLoaderThreads() = 0;
 
+  // Font Queries
+
+  /**
+   * Called by Dali to retrieve the default font family & style for the platform.
+   * Multi-threading note: this method will be called from the main thread only i.e. not
+   * from within the Core::Render() method.
+   * @param[out] The default font family.
+   * @param[out] The default font style.
+   */
+  virtual void GetDefaultFontDescription( std::string& family, std::string& style ) const = 0;
+
+  /**
+   * Called by Dali to retrieve the default font size for the platform.
+   * This is an accessibility size, which is mapped to a UI Control specific point-size in stylesheets.
+   * For example if zero the smallest size, this could potentially map to TextLabel point-size 8.
+   * Multi-threading note: this method will be called from the main thread only i.e. not
+   * from within the Core::Render() method.
+   * @return The default font size.
+   */
+  virtual int GetDefaultFontSize() const = 0;
+
   /**
    * Sets horizontal and vertical pixels per inch value that is used by the display
    * @param[in] dpiHorizontal horizontal dpi value
@@ -174,21 +213,33 @@ public:
    * @param[out] buffer  A buffer to receive the file.
    * @result             true if the file is loaded.
    */
-  virtual bool LoadFile( const std::string& filename, std::vector< unsigned char >& buffer ) const = 0;
+  virtual bool LoadFile( const std::string& filename, Dali::Vector< unsigned char >& buffer ) const = 0;
 
   /**
    * Load a file into a buffer
    * @param[in] filename The filename to save
    * @param[out] buffer  A buffer containing some data
-   *                     The buffer is implemeneted with a std::vector. The size() member specifies the buffer length.
+   *                     The buffer is implemeneted with a Dali::Vector. The size() member specifies the buffer length.
    * @result             true if the file is saved.
    */
-  virtual bool SaveFile(const std::string& filename, std::vector< unsigned char >& buffer) const = 0;
+  virtual bool SaveFile( const std::string& filename, const unsigned char * buffer, unsigned int numBytes ) const = 0;
+
+  /**
+   * Load a shader binary file into a buffer
+   * @param[in] filename The shader binary filename to load
+   * @param[out] buffer  A buffer to receive the file.
+   * @result             true if the file is loaded.
+   */
+  virtual bool LoadShaderBinaryFile( const std::string& filename, Dali::Vector< unsigned char >& buffer ) const = 0;
 
   /**
-   * Get a pointer to the DynamicsFactory.
+   * Save a shader binary file to the resource file system.
+   * @param[in] filename The shader binary filename to save to.
+   * @param[in] buffer  A buffer to write the file from.
+   * @param[in] numbytes Size of the buffer.
+   * @result             true if the file is saved, else false.
    */
-  virtual DynamicsFactory* GetDynamicsFactory() = 0;
+  virtual bool SaveShaderBinaryFile( const std::string& filename, const unsigned char * buffer, unsigned int numBytes ) const = 0;
 
 }; // class PlatformAbstraction