Merge "use modern construct '= default' for special functions." into devel/master
[platform/core/uifw/dali-core.git] / dali / integration-api / platform-abstraction.h
index 3697fa1..64ce4f7 100644 (file)
@@ -1,8 +1,8 @@
-#ifndef __DALI_INTEGRATION_PLATFORM_ABSTRACTION_H__
-#define __DALI_INTEGRATION_PLATFORM_ABSTRACTION_H__
+#ifndef DALI_INTEGRATION_PLATFORM_ABSTRACTION_H
+#define DALI_INTEGRATION_PLATFORM_ABSTRACTION_H
 
 /*
- * Copyright (c) 2014 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2020 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.
 
 // 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/public-api/images/image-operations.h>
+#include <dali/integration-api/bitmap.h>
+#include <dali/integration-api/resource-types.h>
 #include <dali/public-api/common/dali-vector.h>
+#include <dali/public-api/images/image-operations.h>
+#include <dali/public-api/signals/callback.h>
 
 namespace Dali
 {
-
 namespace Integration
 {
+using ResourceId      = uint32_t;
+using ResourcePointer = IntrusivePtr<Dali::RefObject>;
 
 /**
  * PlatformAbstraction is an abstract interface, used by Dali to access platform specific services.
@@ -39,32 +41,6 @@ namespace Integration
 class PlatformAbstraction
 {
 public:
-
-  /**
-   * Virtual destructor.
-   */
-  virtual ~PlatformAbstraction() {}
-
-  // DALi Lifecycle
-
-  /**
-   * 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
 
   /**
@@ -83,11 +59,11 @@ public:
    * 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;
+  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
@@ -105,26 +81,15 @@ public:
    * 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.
-   * 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;
+  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 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.
@@ -132,7 +97,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.
@@ -142,52 +107,7 @@ public:
    *
    * @return A pointer to the decoded buffer.
    */
-  virtual BitmapPtr DecodeBuffer( const ResourceType& resourceType, uint8_t * buffer, size_t bufferSize ) = 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;
-
-  /**
-   * 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;
-
-  /**
-   * 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 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;
-
-  /**
-   * 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;
+  virtual BitmapPtr DecodeBuffer(const BitmapResourceType& resourceType, uint8_t* buffer, size_t bufferSize) = 0;
 
   /**
    * Load a shader binary file into a buffer
@@ -195,7 +115,7 @@ public:
    * @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;
+  virtual bool LoadShaderBinaryFile(const std::string& filename, Dali::Vector<uint8_t>& buffer) const = 0;
 
   /**
    * Save a shader binary file to the resource file system.
@@ -204,7 +124,27 @@ public:
    * @param[in] numbytes Size of the buffer.
    * @result             true if the file is saved, else false.
    */
-  virtual bool SaveShaderBinaryFile( const std::string& filename, const unsigned char * buffer, unsigned int numBytes ) const = 0;
+  virtual bool SaveShaderBinaryFile(const std::string& filename, const uint8_t* buffer, uint32_t numBytes) const = 0;
+
+  /**
+   * Sets a callback to occur in the future
+   * @param[in] milliseconds number of milliseconds to wait until executing the callback
+   * @param[in] callback function to call when the timer expires
+   * @result    a timer reference ID, to be used for cancelling the timer
+   */
+  virtual uint32_t StartTimer(uint32_t milliseconds, CallbackBase* callback) = 0;
+
+  /**
+   * Cancels a running timer
+   * @param[in] timerId the ID reference returned when the timer was started
+   */
+  virtual void CancelTimer(uint32_t timerId) = 0;
+
+protected:
+  /**
+   * Virtual destructor.
+   */
+  virtual ~PlatformAbstraction() = default;
 
 }; // class PlatformAbstraction
 
@@ -212,4 +152,4 @@ public:
 
 } // namespace Dali
 
-#endif // __DALI_INTEGRATION_PLATFORM_ABSTRACTION_H__
+#endif // DALI_INTEGRATION_PLATFORM_ABSTRACTION_H