Added RenderTask WorldToViewport coordinates
[platform/core/uifw/dali-core.git] / dali / public-api / render-tasks / render-task.h
index cdc989d..5f865bb 100644 (file)
@@ -2,7 +2,7 @@
 #define __DALI_RENDER_TASK_H__
 
 /*
- * Copyright (c) 2014 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2015 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/public-api/math/viewport.h>
-#include <dali/public-api/object/constrainable.h>
-#include <dali/public-api/signals/dali-signal-v2.h>
+#include <dali/public-api/object/handle.h>
+#include <dali/public-api/object/property-index-ranges.h>
+#include <dali/public-api/signals/dali-signal.h>
 
 namespace Dali
 {
+/**
+ * @addtogroup dali_core_render_tasks
+ * @{
+ */
 
 class Actor;
 class CameraActor;
@@ -68,22 +73,33 @@ class RenderTask;
  * If the refresh rate id REFRESH_ONCE and a "Finish" signal is connected, it will be emitted when the RenderTask is completed.
  * Note that all connected signals must be disconnected before the object is destroyed. This is typically done in the
  * object destructor, and requires either the Dali::Connection object or Dali::RenderTask handle to be stored.
+ *
+ * Signals
+ * | %Signal Name | Method                |
+ * |--------------|-----------------------|
+ * | finished     | @ref FinishedSignal() |
  */
-class DALI_IMPORT_API RenderTask : public Constrainable
+class DALI_IMPORT_API RenderTask : public Handle
 {
 public:
+
   /**
-   * @brief Typedef for signals sent by this class.
+   * @brief An enumeration of properties belonging to the RenderTask class.
    */
-  typedef SignalV2< void (RenderTask& source) > RenderTaskSignalV2;
-
-  // Default Properties
-  static const Property::Index VIEWPORT_POSITION;    ///< Property  0, name "viewport-position",   type VECTOR2
-  static const Property::Index VIEWPORT_SIZE;        ///< Property  1, name "viewport-size",       type VECTOR2
-  static const Property::Index CLEAR_COLOR;          ///< Property  2, name "clear-color",         type VECTOR4
+  struct Property
+  {
+    enum
+    {
+      VIEWPORT_POSITION = DEFAULT_OBJECT_PROPERTY_START_INDEX, ///< name "viewportPosition",  type Vector2
+      VIEWPORT_SIZE,                                           ///< name "viewportSize",      type Vector2
+      CLEAR_COLOR,                                             ///< name "clearColor",        type Vector4
+    };
+  };
 
-  //Signal Names
-  static const char* const SIGNAL_FINISHED; ///< Name for Finished signal
+  /**
+   * @brief Typedef for signals sent by this class.
+   */
+  typedef Signal< void (RenderTask& source) > RenderTaskSignalType;
 
   /**
    * @brief A pointer to a function for converting screen to frame-buffer coordinates.
@@ -170,16 +186,6 @@ public:
   RenderTask& operator=(const RenderTask& rhs);
 
   /**
-   * @brief This method is defined to allow assignment of the NULL value,
-   * and will throw an exception if passed any other value.
-   *
-   * Assigning to NULL is an alias for Reset().
-   * @param [in] rhs  A NULL pointer
-   * @return A reference to this handle
-   */
-  RenderTask& operator=(BaseHandle::NullType* rhs);
-
-  /**
    * @brief Set the actors to be rendered.
    * @param[in] actor This actor and its children will be rendered.
    * If actor is an empty handle, then nothing will be rendered.
@@ -374,10 +380,18 @@ public:
   /**
    * @brief Set the refresh-rate of the RenderTask.
    *
-   * The default is REFRESH_ALWAYS (1), meaning that the RenderTask will be processed every frame.
-   * It may be desirable to process less frequently e.g. SetRefreshRate(3) will process once every 3 frames.
-   * The REFRESH_ONCE value means that the RenderTask will be processed once only, to take a snap-shot of the scene.
-   * Repeatedly calling SetRefreshRate(REFRESH_ONCE) will cause more snap-shots to be taken.
+   * The default is REFRESH_ALWAYS (1), meaning that the RenderTask
+   * will be processed every frame if the scene graph is changing.  It
+   * may be desirable to process less frequently. For example,
+   * SetRefreshRate(3) will process once every 3 frames if the scene
+   * graph is changing.  If the scene graph is not changing, then the
+   * render task will not be rendered, regardless of this value.
+   *
+   * The REFRESH_ONCE value means that the RenderTask will be
+   * processed once only, to take a snap-shot of the scene.
+   * Repeatedly calling SetRefreshRate(REFRESH_ONCE) will cause more
+   * snap-shots to be taken.
+   *
    * @param[in] refreshRate The new refresh rate.
    */
   void SetRefreshRate( unsigned int refreshRate );
@@ -388,12 +402,38 @@ public:
    */
   unsigned int GetRefreshRate() const;
 
+  /*
+   * @brief Get viewport coordinates for given world position
+   *
+   * @since DALi 1.1.13
+   *
+   * @param[in] position The world position.
+   * @param[out] viewportX The viewport x position.
+   * @param[out] viewportY The viewport y position.
+   * @return true if the position has a screen coordinate
+   */
+  bool WorldToViewport(const Vector3 &position, float& viewportX, float& viewportY) const;
+
+  /*
+   * @brief Get actor local coordinates for given viewport coordinates
+   *
+   * @since DALi 1.1.13
+   *
+   * @param[in] actor The actor describing local coordinate system.
+   * @param[in] viewportX The viewport x position.
+   * @param[in] viewportY The viewport y position.
+   * @param[out] localX The local x position.
+   * @param[out] localY The local y position.
+   * @return true if the screen position has a local coordinate
+   */
+  bool ViewportToLocal(Actor actor, float viewportX, float viewportY, float &localX, float &localY) const;
+
 public: // Signals
 
   /**
    * @brief If the refresh rate is REFRESH_ONCE, connect to this signal to be notified when a RenderTask has finished.
    */
-  RenderTaskSignalV2& FinishedSignal();
+  RenderTaskSignalType& FinishedSignal();
 
 public: // Not intended for application developers
 
@@ -404,6 +444,9 @@ public: // Not intended for application developers
   explicit DALI_INTERNAL RenderTask( Internal::RenderTask* renderTask );
 };
 
+/**
+ * @}
+ */
 } // namespace Dali
 
 #endif //__DALI_RENDER_TASK_H__