[4.0] Supports screen rotation.
[platform/core/uifw/dali-core.git] / dali / internal / common / core-impl.cpp
old mode 100644 (file)
new mode 100755 (executable)
index d176f70..ae5a35a
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2016 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.
@@ -78,12 +78,17 @@ using Integration::Event;
 using Integration::UpdateStatus;
 using Integration::RenderStatus;
 
-Core::Core( RenderController& renderController, PlatformAbstraction& platform,
-            GlAbstraction& glAbstraction, GlSyncAbstraction& glSyncAbstraction,
-            GestureManager& gestureManager, ResourcePolicy::DataRetention dataRetentionPolicy)
+Core::Core( RenderController& renderController,
+            PlatformAbstraction& platform,
+            GlAbstraction& glAbstraction,
+            GlSyncAbstraction& glSyncAbstraction,
+            GestureManager& gestureManager,
+            ResourcePolicy::DataRetention dataRetentionPolicy,
+            Integration::RenderToFrameBuffer renderToFboEnabled,
+            Integration::DepthBufferAvailable depthBufferAvailable,
+            Integration::StencilBufferAvailable stencilBufferAvailable )
 : mRenderController( renderController ),
   mPlatform(platform),
-  mIsActive(true),
   mProcessingEvent(false)
 {
   // Create the thread local storage
@@ -100,7 +105,7 @@ Core::Core( RenderController& renderController, PlatformAbstraction& platform,
 
   mRenderTaskProcessor = new SceneGraph::RenderTaskProcessor();
 
-  mRenderManager = RenderManager::New( glAbstraction, glSyncAbstraction );
+  mRenderManager = RenderManager::New( glAbstraction, glSyncAbstraction, depthBufferAvailable, stencilBufferAvailable );
 
   RenderQueue& renderQueue = mRenderManager->GetRenderQueue();
 
@@ -117,12 +122,12 @@ Core::Core( RenderController& renderController, PlatformAbstraction& platform,
 
   mRenderManager->SetShaderSaver( *mUpdateManager );
 
-  mStage = IntrusivePtr<Stage>( Stage::New( *mAnimationPlaylist, *mPropertyNotificationManager, *mUpdateManager, *mNotificationManager ) );
+  mStage = IntrusivePtr<Stage>( Stage::New( *mAnimationPlaylist, *mPropertyNotificationManager, *mUpdateManager, *mNotificationManager, mRenderController ) );
 
   // This must be called after stage is created but before stage initialization
   mRelayoutController = IntrusivePtr< RelayoutController >( new RelayoutController( mRenderController ) );
 
-  mStage->Initialize();
+  mStage->Initialize( renderToFboEnabled == Integration::RenderToFrameBuffer::TRUE );
 
   mGestureEventProcessor = new GestureEventProcessor( *mStage, *mUpdateManager, gestureManager, mRenderController );
   mEventProcessor = new EventProcessor( *mStage, *mNotificationManager, *mGestureEventProcessor );
@@ -191,6 +196,15 @@ void Core::SurfaceResized( unsigned int width, unsigned int height )
   mRelayoutController->SetStageSize( size.width, size.height );
 }
 
+void Core::SurfaceResized( unsigned int width, unsigned int height, int orientation )
+{
+  mStage->SurfaceResized( width, height, orientation );
+
+  // The stage-size may be less than surface-size (reduced by top-margin)
+  Vector2 size = mStage->GetSize();
+  mRelayoutController->SetStageSize( size.width, size.height );
+}
+
 void Core::SetTopMargin( unsigned int margin )
 {
   mStage->SetTopMargin( margin );
@@ -205,7 +219,7 @@ void Core::SetDpi( unsigned int dpiHorizontal, unsigned int dpiVertical )
   mStage->SetDpi( Vector2( dpiHorizontal , dpiVertical) );
 }
 
-void Core::Update( float elapsedSeconds, unsigned int lastVSyncTimeMilliseconds, unsigned int nextVSyncTimeMilliseconds, Integration::UpdateStatus& status )
+void Core::Update( float elapsedSeconds, unsigned int lastVSyncTimeMilliseconds, unsigned int nextVSyncTimeMilliseconds, Integration::UpdateStatus& status, bool renderToFboEnabled, bool isRenderingToFbo )
 {
   // set the time delta so adaptor can easily print FPS with a release build with 0 as
   // it is cached by frametime
@@ -215,11 +229,16 @@ void Core::Update( float elapsedSeconds, unsigned int lastVSyncTimeMilliseconds,
   // Use the estimated time diff till we render as the elapsed time.
   status.keepUpdating = mUpdateManager->Update( elapsedSeconds,
                                                 lastVSyncTimeMilliseconds,
-                                                nextVSyncTimeMilliseconds );
+                                                nextVSyncTimeMilliseconds,
+                                                renderToFboEnabled,
+                                                isRenderingToFbo );
 
   // Check the Notification Manager message queue to set needsNotification
   status.needsNotification = mNotificationManager->MessagesToProcess();
 
+  // Check if the default surface is changed
+  status.surfaceRectChanged = mUpdateManager->IsDefaultSurfaceRectChanged();
+
   // No need to keep update running if there are notifications to process.
   // Any message to update will wake it up anyways
 }
@@ -229,19 +248,6 @@ void Core::Render( RenderStatus& status )
   mRenderManager->Render( status );
 }
 
-void Core::Suspend()
-{
-  mIsActive = false;
-}
-
-void Core::Resume()
-{
-  mIsActive = true;
-
-  // trigger processing of events queued up while paused
-  ProcessEvents();
-}
-
 void Core::SceneCreated()
 {
   mStage->EmitSceneCreatedSignal();
@@ -260,7 +266,7 @@ void Core::ProcessEvents()
   if( mProcessingEvent )
   {
     DALI_LOG_ERROR( "ProcessEvents should not be called from within ProcessEvents!\n" );
-    mRenderController.RequestProcessEventsOnIdle();
+    mRenderController.RequestProcessEventsOnIdle( false );
     return;
   }
 
@@ -274,29 +280,27 @@ void Core::ProcessEvents()
 
   mNotificationManager->ProcessMessages();
 
-  // Avoid allocating MessageBuffers, triggering size-negotiation or sending any other spam whilst paused
-  if( mIsActive )
-  {
-    // Emit signal here to inform listeners that event processing has finished.
-    mStage->EmitEventProcessingFinishedSignal();
+  // Emit signal here to inform listeners that event processing has finished.
+  mStage->EmitEventProcessingFinishedSignal();
 
-    // Run the size negotiation after event processing finished signal
-    mRelayoutController->Relayout();
+  // Run the size negotiation after event processing finished signal
+  mRelayoutController->Relayout();
 
-    // Rebuild depth tree after event processing has finished
-    mStage->RebuildDepthTree();
+  // Rebuild depth tree after event processing has finished
+  mStage->RebuildDepthTree();
 
-    // Flush any queued messages for the update-thread
-    const bool messagesToProcess = mUpdateManager->FlushQueue();
+  // Flush any queued messages for the update-thread
+  const bool messagesToProcess = mUpdateManager->FlushQueue();
 
-    // Check if the touch or gestures require updates.
-    const bool gestureNeedsUpdate = mGestureEventProcessor->NeedsUpdate();
+  // Check if the touch or gestures require updates.
+  const bool gestureNeedsUpdate = mGestureEventProcessor->NeedsUpdate();
+  // Check if the next update is forced.
+  const bool forceUpdate = mStage->IsNextUpdateForced();
 
-    if( messagesToProcess || gestureNeedsUpdate )
-    {
-      // tell the render controller to keep update thread running
-      mRenderController.RequestUpdate();
-    }
+  if( messagesToProcess || gestureNeedsUpdate || forceUpdate )
+  {
+    // tell the render controller to keep update thread running
+    mRenderController.RequestUpdate( forceUpdate );
   }
 
   mRelayoutController->SetProcessingCoreEvents( false );