Fix flickering issue when the window is resized
[platform/core/uifw/dali-adaptor.git] / dali / internal / adaptor / common / adaptor-impl.cpp
index af6b0be..b660e43 100755 (executable)
@@ -19,7 +19,6 @@
 #include <dali/internal/adaptor/common/adaptor-impl.h>
 
 // EXTERNAL INCLUDES
-#include <dali/public-api/common/dali-common.h>
 #include <dali/public-api/common/stage.h>
 #include <dali/public-api/actors/layer.h>
 #include <dali/devel-api/actors/actor-devel.h>
@@ -31,6 +30,7 @@
 #include <dali/integration-api/events/touch-event-integ.h>
 
 // INTERNAL INCLUDES
+#include <dali/public-api/dali-adaptor-common.h>
 #include <dali/internal/system/common/thread-controller.h>
 #include <dali/internal/system/common/performance-interface-factory.h>
 #include <dali/internal/adaptor/common/lifecycle-observer.h>
@@ -38,7 +38,6 @@
 #include <dali/devel-api/text-abstraction/font-client.h>
 
 #include <dali/internal/system/common/callback-manager.h>
-#include <dali/devel-api/adaptor-framework/render-surface.h>
 #include <dali/internal/accessibility/common/tts-player-impl.h>
 #include <dali/internal/accessibility/common/accessibility-adaptor-impl.h>
 #include <dali/internal/input/common/gesture-manager.h>
@@ -53,6 +52,7 @@
 #include <dali/internal/system/common/object-profiler.h>
 #include <dali/internal/window-system/common/display-connection.h>
 #include <dali/internal/window-system/common/window-impl.h>
+#include <dali/internal/window-system/common/window-render-surface.h>
 
 #include <dali/internal/system/common/logging.h>
 #include <dali/devel-api/adaptor-framework/image-loading.h>
@@ -303,7 +303,7 @@ void Adaptor::Start()
 
   unsigned int dpiHor, dpiVer;
   dpiHor = dpiVer = 0;
-  Dali::DisplayConnection::GetDpi(dpiHor, dpiVer);
+  mSurface->GetDpi( dpiHor, dpiVer );
 
   // tell core about the DPI value
   mCore->SetDpi(dpiHor, dpiVer);
@@ -484,14 +484,14 @@ Dali::TtsPlayer Adaptor::GetTtsPlayer(Dali::TtsPlayer::Mode mode)
   return mTtsPlayers[mode];
 }
 
-bool Adaptor::AddIdle( CallbackBase* callback, bool forceAdd )
+bool Adaptor::AddIdle( CallbackBase* callback, bool hasReturnValue, bool forceAdd )
 {
   bool idleAdded(false);
 
   // Only add an idle if the Adaptor is actually running
   if( RUNNING == mState || READY == mState || forceAdd )
   {
-    idleAdded = mCallbackManager->AddIdleCallback( callback );
+    idleAdded = mCallbackManager->AddIdleCallback( callback, hasReturnValue );
   }
 
   return idleAdded;
@@ -735,7 +735,7 @@ void Adaptor::RequestProcessEventsOnIdle( bool forceProcess )
   // and we haven't installed the idle notification
   if( ( ! mNotificationOnIdleInstalled ) && ( RUNNING == mState || READY == mState || forceProcess ) )
   {
-    mNotificationOnIdleInstalled = AddIdle( MakeCallback( this, &Adaptor::ProcessCoreEventsFromIdle ), forceProcess );
+    mNotificationOnIdleInstalled = AddIdleEnterer( MakeCallback( this, &Adaptor::ProcessCoreEventsFromIdle ), forceProcess );
   }
 }
 
@@ -785,7 +785,6 @@ void Adaptor::SurfaceResizeComplete( SurfaceSize surfaceSize )
   // to start processing messages for new camera setup etc as soon as possible
   ProcessCoreEvents();
 
-  // this method blocks until the render thread has completed the resizing.
   mThreadController->ResizeSurface();
 }
 
@@ -831,12 +830,14 @@ void Adaptor::IndicatorSizeChanged(int height)
   mCore->SetTopMargin(height);
 }
 
-void Adaptor::ProcessCoreEventsFromIdle()
+bool Adaptor::ProcessCoreEventsFromIdle()
 {
   ProcessCoreEvents();
 
   // the idle handle automatically un-installs itself
   mNotificationOnIdleInstalled = false;
+
+  return false;
 }
 
 Adaptor::Adaptor(Any nativeWindow, Dali::Adaptor& adaptor, RenderSurface* surface, EnvironmentOptions* environmentOptions)
@@ -909,6 +910,24 @@ void Adaptor::SetRootLayoutDirection( std::string locale )
                                     static_cast< LayoutDirection::Type >( Internal::Adaptor::Locale::GetDirection( std::string( locale ) ) ) );
 }
 
+bool Adaptor::AddIdleEnterer( CallbackBase* callback, bool forceAdd )
+{
+  bool idleAdded( false );
+
+  // Only add an idle if the Adaptor is actually running
+  if( RUNNING == mState || READY == mState || forceAdd )
+  {
+    idleAdded = mCallbackManager->AddIdleEntererCallback( callback );
+  }
+
+  return idleAdded;
+}
+
+void Adaptor::RemoveIdleEnterer( CallbackBase* callback )
+{
+  mCallbackManager->RemoveIdleEntererCallback( callback );
+}
+
 } // namespace Adaptor
 
 } // namespace Internal