[Tizen] Add codes for Dali Windows Backend
[platform/core/uifw/dali-core.git] / dali / integration-api / platform-abstraction.h
index 6398636..7a41087 100644 (file)
@@ -2,7 +2,7 @@
 #define __DALI_INTEGRATION_PLATFORM_ABSTRACTION_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.
@@ -20,8 +20,8 @@
 
 // INTERNAL INCLUDES
 
-#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/integration-api/bitmap.h>
+#include <dali/integration-api/resource-types.h>
 #include <dali/public-api/images/image-operations.h>
 #include <dali/public-api/common/dali-vector.h>
 
@@ -30,6 +30,8 @@ namespace Dali
 
 namespace Integration
 {
+typedef unsigned int ResourceId;
+typedef IntrusivePtr<Dali::RefObject> ResourcePointer;
 
 /**
  * PlatformAbstraction is an abstract interface, used by Dali to access platform specific services.
@@ -40,38 +42,6 @@ class PlatformAbstraction
 {
 public:
 
-  virtual ~PlatformAbstraction() {}
-
-  // Dali Lifecycle
-
-  /**
-   * Get the monotonic time since an unspecified reference point.
-   * This is used by Dali to calculate time intervals during animations; the interval is
-   * recalculated when Dali is resumed with Dali::Integration::Core::Resume().
-   * Multi-threading note: this method may be called from either the main or rendering thread.
-   * @param[out] seconds The time in seconds since the reference point.
-   * @param[out] microSeconds The remainder in microseconds.
-   */
-  virtual void GetTimeMicroseconds(unsigned int& seconds, unsigned int& microSeconds) = 0;
-
-  /**
-   * Tell the platform abstraction that Dali is ready to pause, such as when the
-   * application enters a background state.
-   * Allows background threads to pause their work until Resume() is called.
-   * This is a good time to release recreatable data such as memory caches
-   * to cooperate with other apps and reduce the chance of this one being
-   * force-killed in a low memory situation.
-   */
-  virtual void Suspend() = 0;
-
-  /**
-   * Tell the platform abstraction that Dali is resuming from a pause, such as
-   * when it has transitioned from a background state to a foreground one.
-   * It is time to wake up sleeping background threads and recreate memory
-   * caches and other temporary data.
-   */
-  virtual void Resume() = 0;
-
   // Resource Loading
 
   /**
@@ -97,7 +67,7 @@ public:
                                                bool orientationCorrection = true) = 0;
 
   /**
-   @brief Determine the size of an image the resource loaders will provide when
+   @brief Determine the size of an image the resource loaders will provide when
    * given the same image loading parameters.
    *
    * This is a synchronous request.
@@ -119,19 +89,8 @@ public:
                                                bool orientationCorrection = true) = 0;
 
   /**
-   * Request a resource from the native filesystem. This is an asynchronous request.
-   * After this method returns, FillResourceCache() will be called to retrieve the result(s) of the
-   * resource loading operation. Loading resources in separate worker thread is recommended.
-   * Multi-threading note: this method will be called from the main thread only i.e. not
-   * from within the Core::Render() method.
-   * @param[in] request A unique resource request. This is not guaranteed to survive after LoadResource
-   * returns; the loading process should take a copy.
-   */
-  virtual void LoadResource(const ResourceRequest& request) = 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.
@@ -139,84 +98,17 @@ 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;
-
-  /**
-   * Cancel an ongoing LoadResource() request.
-   * Multi-threading note: this method will be called from the main thread only i.e. not
-   * from within the Core::Render() method.
-   * @param[in] id The ID of the resource to cancel.
-   * @param[in] typeId The ID type of the resource to cancel.
-   */
-  virtual void CancelLoad(ResourceId id, ResourceTypeId typeId) = 0;
-
-  /**
-   * Query whether any asynchronous LoadResource() requests are ongoing.
-   * Multi-threading note: this method may be called from either the main or rendering thread.
-   * @return True if resources are being loaded.
-   */
-  virtual bool IsLoading() = 0;
-
-  /**
-   * Retrieve newly loaded resources.
-   * If no resources have finished loading, then this method returns immediately.
-   * Multi-threading note: this method will be called from the update thread, from within
-   * the UpdateManager::Update() method.
-   * @param[in] cache The resource cache to fill.
-   */
-  virtual void GetResources(ResourceCache& cache) = 0;
+  virtual ResourcePointer LoadImageSynchronously( const BitmapResourceType& resourceType, const std::string& resourcePath ) = 0;
 
   /**
-   * Waits for the asynchronous loader threads (if any) to finish.
-   * This will be only be called before Core destruction; no resource loading requests will be
-   * made following this method.
-   */
-  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
-   * @param[in] dpiVertical   vertical dpi value
-   */
-  virtual void SetDpi (unsigned int dpiHorizontal, unsigned int dpiVertical) = 0;
-
-  /**
-   * Load a file into a buffer
-   * @param[in] filename The filename to load
-   * @param[out] buffer  A buffer to receive the file.
-   * @result             true if the file is loaded.
-   */
-  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 Dali::Vector. The size() member specifies the buffer length.
-   * @result             true if the file is saved.
+   * Decode a buffer of data synchronously.
+   * @param[in] resourceType The type of resource to load
+   * @param[in] buffer The decoded data
+   * @param[in] bufferSize The size of the buffer used by the decoded data.
+   *
+   * @return A pointer to the decoded buffer.
    */
-  virtual bool SaveFile( const std::string& filename, const unsigned char * buffer, unsigned int numBytes ) const = 0;
+  virtual BitmapPtr DecodeBuffer( const BitmapResourceType& resourceType, uint8_t * buffer, size_t bufferSize ) = 0;
 
   /**
    * Load a shader binary file into a buffer
@@ -235,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