[3.0] Modify to use remote-surface for WatchApplication
[platform/core/uifw/dali-adaptor.git] / adaptors / common / adaptor-impl.h
index 036dc92..b2bd30a 100644 (file)
@@ -2,7 +2,7 @@
 #define __DALI_INTERNAL_ADAPTOR_IMPL_H__
 
 /*
- * Copyright (c) 2014 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2016 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.
@@ -30,7 +30,6 @@
 #include <render-surface.h>
 #include <tts-player.h>
 #include <imf-manager.h>
-#include <device-layout.h>
 #include <clipboard.h>
 
 #include <tizen-platform-abstraction.h>
 #include <damage-observer.h>
 #include <window-visibility-observer.h>
 #include <kernel-trace.h>
+#include <system-trace.h>
 #include <trigger-event-factory.h>
 #include <networking/socket-factory.h>
 
 namespace Dali
 {
 
+class RenderSurface;
+class Window;
+
 namespace Integration
 {
 class Core;
@@ -63,8 +66,7 @@ class EglFactory;
 class GestureManager;
 class GlImplementation;
 class GlSyncImplementation;
-class RenderSurface;
-class UpdateRenderController;
+class ThreadController;
 class TriggerEvent;
 class CallbackManager;
 class FeedbackPluginProxy;
@@ -90,15 +92,25 @@ public:
 
   /**
    * Creates a New Adaptor
-   * @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]  baseLayout  The base layout that the application has been written for
-   * @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,
+                             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( RenderSurface* surface,
-                             const DeviceLayout& baseLayout,
-                             Dali::Configuration::ContextLoss configuration );
+  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.
@@ -120,6 +132,11 @@ public:
    */
   static bool IsAvailable();
 
+  /**
+   * @copydoc Dali::Core::SceneCreated();
+   */
+  void SceneCreated();
+
 public: // AdaptorInternalServices implementation
   /**
    * @copydoc Dali::Adaptor::Start()
@@ -142,6 +159,16 @@ public: // AdaptorInternalServices implementation
   virtual void Stop();
 
   /**
+   * @copydoc Dali::Adaptor::ContextLost()
+   */
+  virtual void ContextLost();
+
+  /**
+   * @copydoc Dali::Adaptor::ContextRegained()
+   */
+  virtual void ContextRegained();
+
+  /**
    * @copydoc Dali::EventFeeder::FeedTouchPoint()
    */
   virtual void FeedTouchPoint( TouchPoint& point, int timeStamp );
@@ -149,7 +176,7 @@ public: // AdaptorInternalServices implementation
   /**
    * @copydoc Dali::EventFeeder::FeedWheelEvent()
    */
-  virtual void FeedWheelEvent( MouseWheelEvent& wheelEvent );
+  virtual void FeedWheelEvent( WheelEvent& wheelEvent );
 
   /**
    * @copydoc Dali::EventFeeder::FeedKeyEvent()
@@ -169,12 +196,12 @@ public: // AdaptorInternalServices implementation
   /**
    * @copydoc AdaptorInterface::ReplaceSurface()
    */
-  virtual void ReplaceSurface( Dali::RenderSurface& surface );
+  virtual void ReplaceSurface( Any nativeWindow, RenderSurface& surface );
 
   /**
    * @copydoc Dali::Adaptor::GetSurface()
    */
-  virtual Dali::RenderSurface& GetSurface() const;
+  virtual RenderSurface& GetSurface() const;
 
   /**
    * @copydoc Dali::Adaptor::ReleaseSurfaceLock()
@@ -194,9 +221,9 @@ public: // AdaptorInternalServices implementation
   virtual bool AddIdle( CallbackBase* callback );
 
   /**
-   * @copydoc Internal::Framework::CallFromMainLoop()
+   * @copydoc Dali::Adaptor::RemoveIdle()
    */
-  virtual bool CallFromMainLoop( CallbackBase* callback );
+  virtual void RemoveIdle( CallbackBase* callback );
 
 public:
 
@@ -216,14 +243,6 @@ public:
   void SetUseHardwareVSync(bool useHardware);
 
   /**
-   * Overrides DPI.
-   * Primarily for host/simulation testing
-   * @param[in] hDpi The Horizontal DPI
-   * @param[in] vDpi The Vertical DPI
-   */
-  void SetDpi(size_t hDpi, size_t vDpi);
-
-  /**
    * @return reference to EglFactory class
    */
   EglFactory& GetEGLFactory() const;
@@ -267,6 +286,19 @@ public:
    */
   void SetMinimumPinchDistance(float distance);
 
+  /**
+   * Gets native window handle
+   *
+   * @return native window handle
+   */
+  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 +326,25 @@ public:
   void RequestUpdateOnce();
 
   /**
+   * @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 has changed
+   */
+  void SurfaceSizeChanged( const PositionSize& positionSize );
+
 public:  //AdaptorInternalServices
 
   /**
@@ -318,7 +365,7 @@ public:  //AdaptorInternalServices
   /**
    * @copydoc Dali::Internal::Adaptor::AdaptorInternalServices::GetTriggerEventInterface()
    */
-  virtual TriggerEventInterface& GetTriggerEventInterface();
+  virtual TriggerEventInterface& GetProcessCoreEventsTrigger();
 
   /**
    * @copydoc Dali::Internal::Adaptor::AdaptorInternalServices::GetTriggerEventFactoryInterface()
@@ -348,7 +395,12 @@ public:  //AdaptorInternalServices
   /**
    * copydoc Dali::Internal::Adaptor::AdaptorInternalServices::GetKernelTraceInterface()
    */
-  virtual KernelTraceInterface& GetKernelTraceInterface();
+  virtual TraceInterface& GetKernelTraceInterface();
+
+  /**
+   * copydoc Dali::Internal::Adaptor::AdaptorInternalServices::GetSystemTraceInterface()
+   */
+  virtual TraceInterface& GetSystemTraceInterface();
 
 public: // Stereoscopy
 
@@ -443,20 +495,15 @@ private:
 private:
 
   /**
-   * Helper to parse log options
-   */
-  void ParseEnvironmentOptions();
-
-  /**
-   * Informs core the surface size has changed
+   * Assigns the render surface to the adaptor
+   *
    */
-  void SurfaceSizeChanged(const PositionSize& positionSize);
+  void SetSurface(RenderSurface *surface);
 
   /**
-   * Assigns the render surface to the adaptor
-   *
+   * called after surface is created
    */
-  void SetSurface(Dali::RenderSurface *surface);
+  void SurfaceInitialized();
 
   /**
    * Sends an notification message from main loop idle handler
@@ -473,13 +520,14 @@ private:
 
   /**
    * Constructor
-   * @param[in]  adaptor     The public adaptor
-   * @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]  baseLayout  The base layout that the application has been written for
+   * @param[in]  nativeWindow native window handle
+   * @param[in]  adaptor      The public adaptor
+   * @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( Dali::Adaptor& adaptor, RenderSurface* surface, const DeviceLayout& baseLayout );
+  Adaptor( Any nativeWindow, Dali::Adaptor& adaptor, RenderSurface* surface, EnvironmentOptions* environmentOptions );
 
 private: // Types
 
@@ -496,41 +544,42 @@ private: // Types
 
 private: // Data
 
-  AdaptorSignalType                       mResizedSignal;             ///< Resized signal.
-  AdaptorSignalType                       mLanguageChangedSignal;     ///< Language changed signal.
+  AdaptorSignalType                     mResizedSignal;               ///< Resized signal.
+  AdaptorSignalType                     mLanguageChangedSignal;       ///< Language changed signal.
 
   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
   EglFactory*                           mEglFactory;                  ///< EGL Factory
 
+  Any                                   mNativeWindow;                ///< window identifier
   RenderSurface*                        mSurface;                     ///< Current surface
   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
-  size_t                                mHDpi;                        ///< Override horizontal DPI
-  size_t                                mVDpi;                        ///< Override vertical DPI
   FeedbackPluginProxy*                  mDaliFeedbackPlugin;          ///< Used to access feedback support
   FeedbackController*                   mFeedbackController;          ///< Plays feedback effects for Dali-Toolkit UI Controls.
   Dali::TtsPlayer                       mTtsPlayers[Dali::TtsPlayer::MODE_NUM];                   ///< Provides TTS support
   ObserverContainer                     mObservers;                   ///< A list of adaptor observer pointers
   DragAndDropDetectorPtr                mDragAndDropDetector;         ///< The Drag & Drop detector
   RotationObserver*                     mDeferredRotationObserver;    ///< deferred Rotation observer needs event handler
-  DeviceLayout                          mBaseLayout;                  ///< The base layout of the application
-  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;}
 };