Revert "[Tizen] Revert "Support screen rotation""
[platform/core/uifw/dali-adaptor.git] / adaptors / base / combined-update-render / combined-update-render-controller.h
index 3961a12..318b085 100644 (file)
@@ -2,7 +2,7 @@
 #define __DALI_INTERNAL_COMBINED_UPDATE_RENDER_CONTROLLER_H__
 
 /*
- * Copyright (c) 2015 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.
@@ -126,6 +126,11 @@ public:
   virtual void ReplaceSurface( RenderSurface* surface );
 
   /**
+   * @copydoc ThreadControllerInterface::ResizeSurface()
+   */
+  virtual void ResizeSurface();
+
+  /**
    * @copydoc ThreadControllerInterface::SetRenderRefreshRate()
    */
   virtual void SetRenderRefreshRate( unsigned int numberOfFramesPerRender );
@@ -192,11 +197,13 @@ private:
   /**
    * Called by the Update/Render Thread which ensures a wait if required.
    *
-   * @param[out] useElapsedTime If true when returned, then the actual elapsed time will be used for animation.
-   *                            If false when returned, then there should NOT be any animation progression in the next Update.
+   * @param[out] useElapsedTime    If true when returned, then the actual elapsed time will be used for animation.
+   *                               If false when returned, then there should NOT be any animation progression in the next Update.
+   * @param[in]  updateRequired    Whether another update is required.
+   * @param[out] timeToSleepUntil  The time remaining in nanoseconds to keep the thread sleeping before resuming.
    * @return false, if the thread should stop.
    */
-  bool UpdateRenderReady( bool& useElapsedTime );
+  bool UpdateRenderReady( bool& useElapsedTime, bool updateRequired, uint64_t& timeToSleepUntil );
 
   /**
    * Checks to see if the surface needs to be replaced.
@@ -214,6 +221,21 @@ private:
   void SurfaceReplaced();
 
   /**
+   * Checks to see if the surface needs to be resized.
+   * This will lock the mutex in mUpdateRenderThreadWaitCondition.
+   *
+   * @return true if the surface should be resized, false otherwise
+   */
+  bool ShouldSurfaceBeResized();
+
+  /**
+   * Called by the Update/Render thread after a surface has been resized.
+   *
+   * This will lock the mutex in mEventThreadWaitCondition
+   */
+  void SurfaceResized();
+
+  /**
    * Helper for the thread calling the entry function
    * @param[in] This A pointer to the current object
    */
@@ -290,6 +312,7 @@ private:
   float                             mDefaultFrameDelta;                ///< Default time delta between each frame (used for animations). Not protected by lock, but written to rarely so not worth adding a lock when reading.
   uint64_t                          mDefaultFrameDurationMilliseconds; ///< Default duration of a frame (used for predicting the time of the next frame). Not protected by lock, but written to rarely so not worth adding a lock when reading.
   uint64_t                          mDefaultFrameDurationNanoseconds;  ///< Default duration of a frame (used for sleeping if not enough time elapsed). Not protected by lock, but written to rarely so not worth adding a lock when reading.
+  uint64_t                          mDefaultHalfFrameNanoseconds;      ///< Is half of mDefaultFrameDurationNanoseconds. Using a member variable avoids having to do the calculation every frame. Not protected by lock, but written to rarely so not worth adding a lock when reading.
 
   unsigned int                      mUpdateRequestCount;               ///< Count of update-requests we have received to ensure we do not go to sleep too early.
   unsigned int                      mRunning;                          ///< Read and set on the event-thread only to state whether we are running.
@@ -300,12 +323,16 @@ private:
 
   volatile int                      mUpdateRenderRunCount;             ///< The number of times Update/Render cycle should run. If -1, then will run continuously (set by the event-thread, read by v-sync-thread).
   volatile unsigned int             mDestroyUpdateRenderThread;        ///< Whether the Update/Render thread be destroyed (set by the event-thread, read by the update-render-thread).
+  volatile unsigned int             mUpdateRenderThreadCanSleep;       ///< Whether the Update/Render thread can sleep (set by the event-thread, read by the update-render-thread).
+  volatile unsigned int             mPendingRequestUpdate;             ///< Is set as soon as an RequestUpdate is made and unset when the next update happens (set by the event-thread and update-render thread, read by the update-render-thread).
+                                                                       ///< Ensures we do not go to sleep if we have not processed the most recent update-request.
 
   volatile unsigned int             mUseElapsedTimeAfterWait;          ///< Whether we should use the elapsed time after waiting (set by the event-thread, read by the update-render-thread).
 
   RenderSurface* volatile           mNewSurface;                       ///< Will be set to the new-surface if requested (set by the event-thread, read & cleared by the update-render thread).
 
   volatile unsigned int             mPostRendering;                    ///< Whether post-rendering is taking place (set by the event & render threads, read by the render-thread).
+  volatile unsigned int             mSurfaceResized;                   ///< Will be set to resize the surface (set by the event-thread, read & cleared by the update-render thread).
 };
 
 } // namespace Adaptor