[Tizen] Support Client Rotation and Screen Rotation
[platform/core/uifw/dali-core.git] / dali / internal / common / core-impl.cpp
index 4ddbc04..7412b9a 100644 (file)
@@ -74,7 +74,6 @@ namespace Internal
 using Integration::RenderController;
 using Integration::PlatformAbstraction;
 using Integration::GlSyncAbstraction;
-using Integration::GestureManager;
 using Integration::GlAbstraction;
 using Integration::Event;
 using Integration::UpdateStatus;
@@ -84,7 +83,6 @@ Core::Core( RenderController& renderController,
             PlatformAbstraction& platform,
             GlAbstraction& glAbstraction,
             GlSyncAbstraction& glSyncAbstraction,
-            GestureManager& gestureManager,
             ResourcePolicy::DataRetention dataRetentionPolicy,
             Integration::RenderToFrameBuffer renderToFboEnabled,
             Integration::DepthBufferAvailable depthBufferAvailable,
@@ -132,8 +130,7 @@ Core::Core( RenderController& renderController,
   // This must be called after stage is created but before stage initialization
   mRelayoutController = IntrusivePtr< RelayoutController >( new RelayoutController( mRenderController ) );
 
-  mGestureEventProcessor = new GestureEventProcessor( *mStage, *mUpdateManager, gestureManager, mRenderController );
-  mEventProcessor = new EventProcessor( *mStage, *mNotificationManager, *mGestureEventProcessor );
+  mGestureEventProcessor = new GestureEventProcessor( *mUpdateManager, mRenderController );
 
   mShaderFactory = new ShaderFactory();
   mUpdateManager->SetShaderSaver( *mShaderFactory );
@@ -194,13 +191,25 @@ void Core::ContextDestroyed()
   mRenderManager->ContextDestroyed();
 }
 
-void Core::SurfaceResized( Integration::RenderSurface* surface )
+void Core::SurfaceResized( Integration::RenderSurface* surface, bool forceUpdate )
 {
   for( auto iter = mScenes.begin(); iter != mScenes.end(); ++iter )
   {
     if( (*iter)->GetSurface() == surface )
     {
-      (*iter)->SetSurface( *surface );
+      (*iter)->SurfaceResized( forceUpdate );
+    }
+  }
+}
+
+void Core::SurfaceDeleted( Integration::RenderSurface* surface )
+{
+  for( auto scene : mScenes )
+  {
+    if( scene->GetSurface() == surface )
+    {
+      scene->SurfaceDeleted();
+      break;
     }
   }
 }
@@ -249,7 +258,10 @@ void Core::SceneCreated()
 
 void Core::QueueEvent( const Integration::Event& event )
 {
-  mEventProcessor->QueueEvent( event );
+  if (mScenes.size() != 0)
+  {
+    mScenes.front()->QueueEvent( event );
+  }
 }
 
 void Core::ProcessEvents()
@@ -268,12 +280,23 @@ void Core::ProcessEvents()
   // Signal that any messages received will be flushed soon
   mUpdateManager->EventProcessingStarted();
 
-  mEventProcessor->ProcessEvents();
+  // Scene could be added or removed while processing the events
+  // Copy the Scene container locally to avoid possibly invalid iterator
+  SceneContainer scenes = mScenes;
+
+  // process events in all scenes
+  for( auto scene : scenes )
+  {
+    scene->ProcessEvents();
+  }
 
   mNotificationManager->ProcessMessages();
 
   // Emit signal here to inform listeners that event processing has finished.
-  mStage->EmitEventProcessingFinishedSignal();
+  for( auto scene : scenes )
+  {
+    scene->EmitEventProcessingFinishedSignal();
+  }
 
   // Run any registered processors
   RunProcessors();
@@ -281,11 +304,10 @@ void Core::ProcessEvents()
   // Run the size negotiation after event processing finished signal
   mRelayoutController->Relayout();
 
-
   // Rebuild depth tree after event processing has finished
-  for( auto iter = mScenes.begin(); iter != mScenes.end(); ++iter )
+  for( auto scene : scenes )
   {
-    (*iter)->RebuildDepthTree();
+    scene->RebuildDepthTree();
   }
 
   // Flush any queued messages for the update-thread