Support multiple window rendering
[platform/core/uifw/dali-core.git] / dali / internal / event / common / stage-impl.h
index 1c07cb8..1f52431 100644 (file)
@@ -1,8 +1,8 @@
-#ifndef __DALI_INTERNAL_STAGE_H__
-#define __DALI_INTERNAL_STAGE_H__
+#ifndef DALI_INTERNAL_STAGE_H
+#define DALI_INTERNAL_STAGE_H
 
 /*
- * Copyright (c) 2014 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2019 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/object/ref-object.h>
 #include <dali/public-api/common/stage.h>
+#include <dali/public-api/object/ref-object.h>
 #include <dali/public-api/object/base-object.h>
+#include <dali/public-api/math/vector2.h>
+#include <dali/public-api/math/vector3.h>
+#include <dali/public-api/math/vector4.h>
+#include <dali/devel-api/common/stage-devel.h>
 #include <dali/integration-api/context-notifier.h>
 #include <dali/internal/common/owner-pointer.h>
 #include <dali/internal/event/actors/layer-impl.h>
 #include <dali/internal/event/common/stage-def.h>
 #include <dali/internal/event/render-tasks/render-task-defaults.h>
 #include <dali/internal/update/manager/update-manager.h>
-#include <dali/public-api/common/view-mode.h>
-#include <dali/public-api/math/vector2.h>
-#include <dali/public-api/math/vector3.h>
-#include <dali/public-api/math/vector4.h>
-#include <dali/public-api/render-tasks/render-task.h>
-
-#ifdef DYNAMICS_SUPPORT
-#include <dali/internal/event/dynamics/dynamics-declarations.h>
-#include <dali/internal/event/dynamics/dynamics-notifier.h>
-#endif
+#include <dali/internal/event/render-tasks/render-task-impl.h>
 
 namespace Dali
 {
@@ -48,8 +43,7 @@ struct Vector2;
 
 namespace Integration
 {
-class SystemOverlay;
-class DynamicsFactory;
+class RenderController;
 }
 
 namespace Internal
@@ -64,38 +58,28 @@ class AnimationPlaylist;
 class PropertyNotificationManager;
 class Layer;
 class LayerList;
-class SystemOverlay;
 class CameraActor;
 class RenderTaskList;
+class Scene;
 
 /**
  * Implementation of Stage
  */
-class Stage : public BaseObject, public RenderTaskDefaults, public Integration::ContextNotifierInterface, public EventThreadServices
+class Stage : public BaseObject, public RenderTaskDefaults, public Integration::ContextNotifierInterface
 {
 public:
 
   /**
    * Create the stage
-   * @param[in] playlist for animations
-   * @param[in] propertyNotificationManager
    * @param[in] updateManager
-   * @param[in] notificationManager
    */
-  static StagePtr New( AnimationPlaylist& playlist,
-                       PropertyNotificationManager& propertyNotificationManager,
-                       SceneGraph::UpdateManager& updateManager,
-                       NotificationManager& notificationManager );
+  static StagePtr New( SceneGraph::UpdateManager& updateManager );
 
   /**
    * Initialize the stage.
+   * @param[in] scene The default scene (for main window).
    */
-  void Initialize();
-
-  /**
-   * Uninitialize the stage.
-   */
-  void Uninitialize();
+  void Initialize( Scene& scene );
 
   /**
    * @copydoc Dali::Stage::GetCurrent()
@@ -119,18 +103,6 @@ public:
    */
   Layer& GetRootActor();
 
-  /**
-   * Returns the animation playlist.
-   * @return reference to the animation playlist.
-   */
-  AnimationPlaylist& GetAnimationPlaylist();
-
-  /**
-   * Returns the property notification manager.
-   * @return reference to the property notification manager.
-   */
-  PropertyNotificationManager& GetPropertyNotificationManager();
-
   // Root actor accessors
 
   /**
@@ -144,13 +116,6 @@ public:
   void Remove( Actor& actor );
 
   /**
-   * Sets the size of the stage and indirectly, the root actor.
-   * @param [in] width  The new width.
-   * @param [in] height The new height.
-   */
-  void SetSize( float width, float height );
-
-  /**
    * Returns the size of the Stage in pixels as a Vector.
    * The x component will be the width of the Stage in pixels
    * The y component will be the height of the Stage in pixels
@@ -164,11 +129,6 @@ public:
   RenderTaskList& GetRenderTaskList() const;
 
   /**
-   * Create a default camera actor
-   */
-  void CreateDefaultCameraActor();
-
-  /**
    * From RenderTaskDefaults; retrieve the default root actor.
    * @return The default root actor.
    */
@@ -185,12 +145,12 @@ public:
   /**
    * @copydoc Dali::Stage::GetLayerCount()
    */
-  unsigned int GetLayerCount() const;
+  uint32_t GetLayerCount() const;
 
   /**
    * @copydoc Dali::Stage::GetLayer()
    */
-  Dali::Layer GetLayer( unsigned int depth ) const;
+  Dali::Layer GetLayer( uint32_t depth ) const;
 
   /**
    * @copydoc Dali::Stage::GetRootLayer()
@@ -203,62 +163,6 @@ public:
    */
   LayerList& GetLayerList();
 
-  // System-level overlay actors
-
-  /**
-   * @copydoc Dali::Integration::Core::GetSystemOverlay()
-   */
-  Integration::SystemOverlay& GetSystemOverlay();
-
-  /**
-   * Retrieve the internal implementation of the SystemOverlay.
-   * @return The implementation, or NULL if this has never been requested from Integration API.
-   */
-  SystemOverlay* GetSystemOverlayInternal();
-
-  // Stereoscopy
-
-  /**
-   * @copydoc Dali::Integration::Core::SetViewMode()
-   */
-  void SetViewMode( ViewMode viewMode );
-
-  /**
-   * @copydoc Dali::Integration::Core::GetViewMode()
-   */
-  ViewMode GetViewMode() const;
-
-  /**
-   * @copydoc Dali::Integration::Core::SetStereoBase()
-   */
-  void SetStereoBase( float stereoBase );
-
-  /**
-   * @copydoc Dali::Integration::Core::GetStereoBase()
-   */
-  float GetStereoBase() const;
-
-  // Keyboard stuff
-
-  /**
-   * As one virtual keyboard per stage, the stage will hold a pointer to the Actor currently
-   * set to receive keyboard input.
-   * @param[in] actor to receive keyboard input
-   */
-  void SetKeyboardFocusActor( Actor* actor );
-
-  /**
-   * Get the actor that is currently set to receive keyboard inputs
-   * @return Pointer to the actor set to receive keyboard inputs.
-   */
-  Actor* GetKeyboardFocusActor() const;
-
-  /**
-   * Removes the given actor from keyboard focus so it will no longer receive key events from keyboard.
-   * @param [in] actor which should be removed from focus.
-   */
-  void RemoveActorFromKeyFocus( Actor* actor );
-
   // Misc
 
   /**
@@ -277,51 +181,32 @@ public:
   Vector2 GetDpi() const;
 
   /**
-   * Sets horizontal and vertical pixels per inch value that is used by the display
-   * @param[in] dpi Horizontal and vertical dpi value
-   */
-  void SetDpi( Vector2 dpi );
-
-#ifdef DYNAMICS_SUPPORT
-
-  /**
-   * Return the Dynamics Simulation Notifier object
-   * @return The Dynamics Simulation Notifier object
+   * @copydoc Dali::Stage::KeepRendering()
    */
-  DynamicsNotifier& GetDynamicsNotifier();
+  void KeepRendering( float durationSeconds );
 
   /**
-   * @copydoc Dali::Stage::InitializeDynamics
+   * @copydoc Dali::DevelStage::SetRenderingBehavior()
    */
-  DynamicsWorldPtr InitializeDynamics(DynamicsWorldConfigPtr config);
+  void SetRenderingBehavior( DevelStage::Rendering renderingBehavior );
 
   /**
-   * @copydoc Dali::Stage::GetDynamicsWorld
+   * @copydoc Dali::DevelStage::GetRenderingBehavior()
    */
-  DynamicsWorldPtr GetDynamicsWorld();
+  DevelStage::Rendering GetRenderingBehavior() const;
 
   /**
-   * @copydoc Dali::Stage::TerminateDynamics
-   */
-  void TerminateDynamics();
-
-#endif // DYNAMICS_SUPPORT
-
-  NotificationManager& GetNotificationManager()
-  {
-    return mNotificationManager;
-  }
-
-  /**
-   * @copydoc Dali::Stage::KeepRendering()
+   * Used by the EventProcessor to emit key event signals.
+   * @param[in] event The key event.
    */
-  void KeepRendering( float durationSeconds );
+  void EmitKeyEventSignal(const KeyEvent& event);
 
   /**
-   * Used by the EventProcessor to emit key event signals.
+   * Used by the KeyEventProcessor to emit KeyEventGenerated signals.
    * @param[in] event The key event.
+   * @return The return is true if KeyEvent is consumed, otherwise false.
    */
-  void EmitKeyEventSignal(const KeyEvent& event);
+  bool EmitKeyEventGeneratedSignal(const KeyEvent& event);
 
   /**
    * Emits the event processing finished signal.
@@ -332,9 +217,16 @@ public:
 
   /**
    * Emits the touched signal.
+   * @param[in] touchEvent The touch event details (Old API).
    * @param[in] touch The touch event details.
    */
-  void EmitTouchedSignal( const TouchEvent& touch );
+  void EmitTouchedSignal( const TouchEvent& touchEvent, const Dali::TouchData& touch );
+
+  /**
+   * Used by the EventProcessor to emit wheel event signals.
+   * @param[in] event The wheel event.
+   */
+  void EmitWheelEventSignal( const WheelEvent& event );
 
   /**
    * Emits the scene created.
@@ -357,6 +249,16 @@ public:
   Dali::Stage::TouchedSignalType& TouchedSignal();
 
   /**
+    * @copydoc Dali::Stage::TouchSignal()
+    */
+  Dali::Stage::TouchSignalType& TouchSignal();
+
+  /**
+   * @copydoc Dali::Stage::WheelEventSignal()
+   */
+  Dali::Stage::WheelEventSignalType& WheelEventSignal();
+
+  /**
    * @copydoc Dali::Stage::ContextLostSignal()
    */
   Dali::Stage::ContextStatusSignal& ContextLostSignal();
@@ -372,6 +274,21 @@ public:
   Dali::Stage::SceneCreatedSignalType& SceneCreatedSignal();
 
   /**
+   * @copydoc Dali::DevelStage::KeyEventGeneratedSignal()
+   */
+  Dali::DevelStage::KeyEventGeneratedSignalType& KeyEventGeneratedSignal();
+
+  /**
+   * @copydoc Dali::DevelStage::AddFrameCallback()
+   */
+  void AddFrameCallback( FrameCallbackInterface& frameCallback, Actor& rootActor );
+
+  /**
+   * @copydoc Dali::DevelStage::RemoveFrameCallback()
+   */
+  void RemoveFrameCallback( FrameCallbackInterface& frameCallback );
+
+  /**
    * Connects a callback function with the object's signals.
    * @param[in] object The object providing the signal.
    * @param[in] tracker Used to disconnect the signal.
@@ -394,42 +311,12 @@ private: // Implementation of ContextNotificationInterface:
    */
   virtual void NotifyContextRegained();
 
-public: // Implementation of EventThreadServices
-
-  /**
-   * @copydoc EventThreadServices::RegisterObject
-   */
-  virtual void RegisterObject( BaseObject* object);
-
-  /**
-   * @copydoc EventThreadServices::UnregisterObject
-   */
-  virtual void UnregisterObject( BaseObject* object);
-
-  /**
-   * @copydoc EventThreadServices::GetUpdateManager
-   */
-  virtual SceneGraph::UpdateManager& GetUpdateManager();
-
-  /**
-   * @copydoc EventThreadServices::ReserveMessageSlot
-   */
-  virtual unsigned int* ReserveMessageSlot( std::size_t size, bool updateScene );
-
-  /**
-   * @copydoc EventThreadServices::GetEventBufferIndex
-   */
-  virtual BufferIndex GetEventBufferIndex() const;
-
 private:
 
   /**
    * Protected constructor; see also Stage::New()
    */
-  Stage( AnimationPlaylist& playlist,
-         PropertyNotificationManager& propertyNotificationManager,
-         SceneGraph::UpdateManager& updateManager,
-         NotificationManager& notificationManager );
+  Stage( SceneGraph::UpdateManager& updateManager );
 
   /**
    * A reference counted object may only be deleted by calling Unreference()
@@ -438,69 +325,30 @@ private:
 
 private:
 
-  // For 'Fire and forget' animation support
-  AnimationPlaylist& mAnimationPlaylist;
-
-  PropertyNotificationManager& mPropertyNotificationManager;
-
   SceneGraph::UpdateManager& mUpdateManager;
 
-  NotificationManager& mNotificationManager;
-
-  // The Actual size of the stage.
-  Vector2 mSize;
-
-  // Cached for public GetBackgroundColor()
-  Vector4 mBackgroundColor;
-
-  LayerPtr mRootLayer;
-
-  // Ordered list of currently on-stage layers
-  OwnerPointer<LayerList> mLayerList;
-
-  IntrusivePtr<CameraActor> mDefaultCamera;
-
-  ViewMode mViewMode;
-  float mStereoBase;
-
-  Vector2 mDpi;
-
-  // The object registry
-  ObjectRegistryPtr mObjectRegistry;
-
-#ifdef DYNAMICS_SUPPORT
-
-  DynamicsNotifier mDynamicsNotifier;
-
-  // The Dynamics simulation world object
-  Integration::DynamicsFactory* mDynamicsFactory;   // Not owned pointer to DynamicsFactory (PlatformAbstraction will clean up)
-  DynamicsWorldPtr mDynamicsWorld;
-
-#endif // DYNAMICS_SUPPORT
-
-  // The list of render-tasks
-  IntrusivePtr<RenderTaskList> mRenderTaskList;
-
-  Dali::RenderTask mRightRenderTask;
-  IntrusivePtr<CameraActor> mRightCamera;
-  Dali::RenderTask mLeftRenderTask;
-  IntrusivePtr<CameraActor> mLeftCamera;
-
-  Integration::SystemOverlay* mSystemOverlay; ///< SystemOverlay stage access
+  IntrusivePtr<Scene> mScene;
 
   // The key event signal
   Dali::Stage::KeyEventSignalType                 mKeyEventSignal;
+  Dali::DevelStage::KeyEventGeneratedSignalType   mKeyEventGeneratedSignal;
 
   // The event processing finished signal
   Dali::Stage::EventProcessingFinishedSignalType  mEventProcessingFinishedSignal;
 
-  // The touched signal
+  // The touched signals
   Dali::Stage::TouchedSignalType                  mTouchedSignal;
+  Dali::Stage::TouchSignalType                    mTouchSignal;
+
+  // The wheel event signal
+  Dali::Stage::WheelEventSignalType               mWheelEventSignal;
 
   Dali::Stage::ContextStatusSignal mContextLostSignal;
   Dali::Stage::ContextStatusSignal mContextRegainedSignal;
 
   Dali::Stage::SceneCreatedSignalType mSceneCreatedSignal;
+
+  DevelStage::Rendering mRenderingBehavior; ///< The rendering behavior
 };
 
 } // namespace Internal
@@ -527,4 +375,4 @@ inline const Internal::Stage& GetImplementation(const Dali::Stage& stage)
 
 } // namespace Dali
 
-#endif // __DALI_INTERNAL_STAGE_H__
+#endif // DALI_INTERNAL_STAGE_H