[4.0] Supports screen rotation.
[platform/core/uifw/dali-adaptor.git] / adaptors / common / adaptor-impl.h
old mode 100644 (file)
new mode 100755 (executable)
index 5e4e25e..ae27285
@@ -2,7 +2,7 @@
 #define __DALI_INTERNAL_ADAPTOR_IMPL_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.
@@ -23,6 +23,7 @@
 #include <dali/public-api/common/view-mode.h>
 #include <dali/public-api/math/rect.h>
 #include <dali/public-api/signals/callback.h>
+#include <dali/public-api/math/uint-16-pair.h>
 #include <dali/integration-api/render-controller.h>
 
 // INTERNAL INCLUDES
@@ -48,6 +49,7 @@ namespace Dali
 {
 
 class RenderSurface;
+class Window;
 
 namespace Integration
 {
@@ -65,7 +67,7 @@ class EglFactory;
 class GestureManager;
 class GlImplementation;
 class GlSyncImplementation;
-class UpdateRenderController;
+class ThreadController;
 class TriggerEvent;
 class CallbackManager;
 class FeedbackPluginProxy;
@@ -89,17 +91,29 @@ public:
 
   typedef Dali::Adaptor::AdaptorSignalType AdaptorSignalType;
 
+  typedef Uint16Pair SurfaceSize;          ///< Surface size type
+
   /**
    * Creates a New Adaptor
-   * @param[in]  nativeWindow  native window handle
-   * @param[in]  surface       A render surface can be one of the following
-   *                           - Pixmap, adaptor will use existing Pixmap to draw on to
-   *                           - Window, adaptor will use existing Window to draw on to
-   * @param[in]  configuration The context loss configuration ( to choose resource discard policy )
+   * @param[in]  nativeWindow        Native window handle
+   * @param[in]  surface             A render surface can be one of the following
+   *                                  - Pixmap, adaptor will use existing Pixmap to draw on to
+   *                                  - Window, adaptor will use existing Window to draw on to
+   * @param[in]  configuration       The context loss configuration ( to choose resource discard policy )
+   * @param[in]  environmentOptions  A pointer to the environment options. If NULL then one is created.
    */
   static Dali::Adaptor* New( Any nativeWindow,
                              RenderSurface* surface,
-                             Dali::Configuration::ContextLoss configuration );
+                             Dali::Configuration::ContextLoss configuration,
+                             EnvironmentOptions* environmentOptions );
+
+  /**
+   * Creates a New Adaptor
+   * @param[in]  nativeWindow        native window handle
+   * @param[in]  configuration       The context loss configuration ( to choose resource discard policy )
+   * @param[in]  environmentOptions  A pointer to the environment options. If NULL then one is created.
+   */
+  static Dali::Adaptor* New( Dali::Window window, Dali::Configuration::ContextLoss configuration, EnvironmentOptions* environmentOptions );
 
   /**
    * 2-step initialisation, this should be called after creating an adaptor instance.
@@ -121,6 +135,11 @@ public:
    */
   static bool IsAvailable();
 
+  /**
+   * @copydoc Dali::Core::SceneCreated();
+   */
+  void SceneCreated();
+
 public: // AdaptorInternalServices implementation
   /**
    * @copydoc Dali::Adaptor::Start()
@@ -143,29 +162,29 @@ public: // AdaptorInternalServices implementation
   virtual void Stop();
 
   /**
-   * @copydoc Dali::EventFeeder::FeedTouchPoint()
+   * @copydoc Dali::Adaptor::ContextLost()
    */
-  virtual void FeedTouchPoint( TouchPoint& point, int timeStamp );
+  virtual void ContextLost();
 
   /**
-   * @copydoc Dali::EventFeeder::FeedWheelEvent()
+   * @copydoc Dali::Adaptor::ContextRegained()
    */
-  virtual void FeedWheelEvent( WheelEvent& wheelEvent );
+  virtual void ContextRegained();
 
   /**
-   * @copydoc Dali::EventFeeder::FeedKeyEvent()
+   * @copydoc Dali::EventFeeder::FeedTouchPoint()
    */
-  virtual void FeedKeyEvent( KeyEvent& keyEvent );
+  virtual void FeedTouchPoint( TouchPoint& point, int timeStamp );
 
   /**
-   * @copydoc AdaptorInterface::MoveResize()
+   * @copydoc Dali::EventFeeder::FeedWheelEvent()
    */
-  virtual bool MoveResize( const PositionSize& positionSize );
+  virtual void FeedWheelEvent( WheelEvent& wheelEvent );
 
   /**
-   * @copydoc AdaptorInterface::SurfaceResized()
+   * @copydoc Dali::EventFeeder::FeedKeyEvent()
    */
-  virtual void SurfaceResized( const PositionSize& positionSize );
+  virtual void FeedKeyEvent( KeyEvent& keyEvent );
 
   /**
    * @copydoc AdaptorInterface::ReplaceSurface()
@@ -192,12 +211,12 @@ public: // AdaptorInternalServices implementation
   /**
    * @copydoc Dali::Adaptor::AddIdle()
    */
-  virtual bool AddIdle( CallbackBase* callback );
+  virtual bool AddIdle( CallbackBase* callback, bool forceAdd );
 
   /**
-   * @copydoc Internal::Framework::CallFromMainLoop()
+   * @copydoc Dali::Adaptor::RemoveIdle()
    */
-  virtual bool CallFromMainLoop( CallbackBase* callback );
+  virtual void RemoveIdle( CallbackBase* callback );
 
 public:
 
@@ -267,6 +286,12 @@ public:
    */
   Any GetNativeWindowHandle();
 
+  /**
+   * Sets use remote surface for eglSurface output
+   * @param[in] useRemoteSurface True if the remote surface is used
+   */
+  void SetUseRemoteSurface(bool useRemoteSurface);
+
 public:
 
   /**
@@ -294,10 +319,51 @@ public:
   void RequestUpdateOnce();
 
   /**
+   * Request adaptor to update indicator's height
+   */
+  void IndicatorSizeChanged(int height);
+
+  /**
+   * @copydoc Dali::Adaptor::NotifySceneCreated()
+   */
+  void NotifySceneCreated();
+
+  /**
    * @copydoc Dali::Adaptor::NotifyLanguageChanged()
    */
   void NotifyLanguageChanged();
 
+  /**
+   * Gets AppId of current application
+   */
+  void GetAppId( std::string& appId );
+
+  /**
+   * Informs core the surface size and orientation has changed
+   */
+  void SurfaceResizePrepare( SurfaceSize surfaceSize, int orientation );
+
+  /**
+   * Informs core the surface size has changed
+   */
+  void SurfaceResizePrepare( SurfaceSize surfaceSize );
+
+  /**
+   * Informs ThreadController the surface size has changed
+   */
+  void SurfaceResizeComplete( SurfaceSize surfaceSize );
+
+  /**
+   * Sets layout direction of root by system language
+   * @param[in] locale System locale
+   */
+  void SetRootLayoutDirection( std::string locale );
+
+  /**
+   * @copydoc Dali::Adaptor::RenderOnce
+   */
+  void RenderOnce();
+
 public:  //AdaptorInternalServices
 
   /**
@@ -318,7 +384,7 @@ public:  //AdaptorInternalServices
   /**
    * @copydoc Dali::Internal::Adaptor::AdaptorInternalServices::GetTriggerEventInterface()
    */
-  virtual TriggerEventInterface& GetTriggerEventInterface();
+  virtual TriggerEventInterface& GetProcessCoreEventsTrigger();
 
   /**
    * @copydoc Dali::Internal::Adaptor::AdaptorInternalServices::GetTriggerEventFactoryInterface()
@@ -410,15 +476,14 @@ private: // From Dali::Internal::Adaptor::CoreEventInterface
 private: // From Dali::Integration::RenderController
 
   /**
-   * Called by the Dali core when it requires another update
+   * @copydoc Dali::Integration::RenderController::RequestUpdate()
    */
-  virtual void RequestUpdate();
+  virtual void RequestUpdate( bool forceUpdate );
 
   /**
-   * Called by Dali core when it requires an notification event being sent on idle.
-   * Multi-threading note: this method must be called from the main thread only.
+   * @copydoc Dali::Integration::RenderController::RequestProcessEventsOnIdle()
    */
-  virtual void RequestProcessEventsOnIdle();
+  virtual void RequestProcessEventsOnIdle( bool forceProcess );
 
 private: // From Dali::Internal::Adaptor::WindowVisibilityObserver
 
@@ -448,17 +513,17 @@ private:
 private:
 
   /**
-   * Informs core the surface size has changed
-   */
-  void SurfaceSizeChanged(const PositionSize& positionSize);
-
-  /**
    * Assigns the render surface to the adaptor
    *
    */
   void SetSurface(RenderSurface *surface);
 
   /**
+   * called after surface is created
+   */
+  void SurfaceInitialized();
+
+  /**
    * Sends an notification message from main loop idle handler
    */
   void ProcessCoreEventsFromIdle();
@@ -469,6 +534,11 @@ private:
    */
   void GetDataStoragePath(std::string& path);
 
+  /**
+   * Sets up system information if needs
+   */
+  void SetupSystemInformation();
+
 private:
 
   /**
@@ -478,8 +548,9 @@ private:
    * @param[in]  surface      A render surface can be one of the following
    *                          - Pixmap, adaptor will use existing Pixmap to draw on to
    *                          - Window, adaptor will use existing Window to draw on to
+   * @param[in]  environmentOptions  A pointer to the environment options. If NULL then one is created.
    */
-  Adaptor( Any nativeWindow, Dali::Adaptor& adaptor, RenderSurface* surface );
+  Adaptor( Any nativeWindow, Dali::Adaptor& adaptor, RenderSurface* surface, EnvironmentOptions* environmentOptions );
 
 private: // Types
 
@@ -502,7 +573,7 @@ private: // Data
   Dali::Adaptor&                        mAdaptor;                     ///< Reference to public adaptor instance.
   State                                 mState;                       ///< Current state of the adaptor
   Dali::Integration::Core*              mCore;                        ///< Dali Core
-  UpdateRenderController*               mUpdateRenderController;      ///< Controls update/render threads
+  ThreadController*                     mThreadController;            ///< Controls the threads
   VSyncMonitor*                         mVSyncMonitor;                ///< Monitors VSync events
   GlImplementation*                     mGLES;                        ///< GL implementation
   GlSyncImplementation*                 mGlSync;                      ///< GL Sync implementation
@@ -510,12 +581,12 @@ private: // Data
 
   Any                                   mNativeWindow;                ///< window identifier
   RenderSurface*                        mSurface;                     ///< Current surface
-  TizenPlatform::TizenPlatformAbstraction*  mPlatformAbstraction;         ///< Platform abstraction
+  TizenPlatform::TizenPlatformAbstraction* mPlatformAbstraction;      ///< Platform abstraction
 
   EventHandler*                         mEventHandler;                ///< event handler
   CallbackManager*                      mCallbackManager;             ///< Used to install callbacks
   bool                                  mNotificationOnIdleInstalled; ///< whether the idle handler is installed to send an notification event
-  TriggerEvent*                         mNotificationTrigger;         ///< Notification event trigger
+  TriggerEventInterface*                mNotificationTrigger;         ///< Notification event trigger
   GestureManager*                       mGestureManager;              ///< Gesture manager
   FeedbackPluginProxy*                  mDaliFeedbackPlugin;          ///< Used to access feedback support
   FeedbackController*                   mFeedbackController;          ///< Plays feedback effects for Dali-Toolkit UI Controls.
@@ -523,13 +594,15 @@ private: // Data
   ObserverContainer                     mObservers;                   ///< A list of adaptor observer pointers
   DragAndDropDetectorPtr                mDragAndDropDetector;         ///< The Drag & Drop detector
   RotationObserver*                     mDeferredRotationObserver;    ///< deferred Rotation observer needs event handler
-  EnvironmentOptions                    mEnvironmentOptions;          ///< environment options
+  EnvironmentOptions*                   mEnvironmentOptions;          ///< environment options
   PerformanceInterface*                 mPerformanceInterface;        ///< Performance interface
   KernelTrace                           mKernelTracer;                ///< Kernel tracer
   SystemTrace                           mSystemTracer;                ///< System tracer
   TriggerEventFactory                   mTriggerEventFactory;         ///< Trigger event factory
   ObjectProfiler*                       mObjectProfiler;              ///< Tracks object lifetime for profiling
   SocketFactory                         mSocketFactory;               ///< Socket factory
+  const bool                            mEnvironmentOptionsOwned:1;   ///< Whether we own the EnvironmentOptions (and thus, need to delete it)
+  bool                                  mUseRemoteSurface;            ///< whether the remoteSurface is used or not
 public:
   inline static Adaptor& GetImplementation(Dali::Adaptor& adaptor) {return *adaptor.mImpl;}
 };