Revert "[Tizen] Revert "Support multiple window rendering""
[platform/core/uifw/dali-adaptor.git] / dali / internal / adaptor / common / adaptor-impl.cpp
old mode 100644 (file)
new mode 100755 (executable)
index 9d8adc1..daeb943
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2018 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.
 
 // CLASS HEADER
 #include <dali/internal/adaptor/common/adaptor-impl.h>
+#include <dali/internal/adaptor/common/adaptor-builder-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/public-api/object/any.h>
 #include <dali/devel-api/actors/actor-devel.h>
 #include <dali/integration-api/debug.h>
 #include <dali/integration-api/core.h>
 #include <dali/integration-api/profiling.h>
 #include <dali/integration-api/input-options.h>
 #include <dali/integration-api/events/touch-event-integ.h>
+#include <dali/integration-api/processor-interface.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>
 
+#include <dali/internal/graphics/gles/egl-graphics-factory.h>
+#include <dali/internal/graphics/gles/egl-graphics.h> // Temporary until Core is abstracted
+
 #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>
 #include <dali/internal/window-system/common/event-handler.h>
-#include <dali/internal/graphics/gles20/gl-proxy-implementation.h>
-#include <dali/internal/graphics/gles20/gl-implementation.h>
-#include <dali/internal/graphics/gles20/egl-sync-implementation.h>
+#include <dali/internal/graphics/gles/gl-proxy-implementation.h>
+#include <dali/internal/graphics/gles/gl-implementation.h>
+#include <dali/internal/graphics/gles/egl-sync-implementation.h>
 #include <dali/internal/graphics/common/egl-image-extensions.h>
-#include <dali/internal/graphics/gles20/egl-factory.h>
-#include <dali/internal/input/common/imf-manager-impl.h>
 #include <dali/internal/clipboard/common/clipboard-impl.h>
 #include <dali/internal/graphics/common/vsync-monitor.h>
 #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>
 
 #include <dali/internal/system/common/locale-utils.h>
+#include <dali/internal/imaging/common/image-loader-plugin-proxy.h>
+#include <dali/internal/imaging/common/image-loader.h>
+
 
 using Dali::TextAbstraction::FontClient;
 
@@ -76,13 +82,18 @@ namespace
 thread_local Adaptor* gThreadLocalAdaptor = NULL; // raw thread specific pointer to allow Adaptor::Get
 } // unnamed namespace
 
-Dali::Adaptor* Adaptor::New( Any nativeWindow, RenderSurface *surface, Dali::Configuration::ContextLoss configuration, EnvironmentOptions* environmentOptions )
+
+Dali::Adaptor* Adaptor::New( Any nativeWindow, Dali::RenderSurfaceInterface *surface, Dali::Configuration::ContextLoss configuration, EnvironmentOptions* environmentOptions )
 {
   Dali::Adaptor* adaptor = new Dali::Adaptor;
   Adaptor* impl = new Adaptor( nativeWindow, *adaptor, surface, environmentOptions );
   adaptor->mImpl = impl;
 
-  impl->Initialize(configuration);
+  Dali::Internal::Adaptor::AdaptorBuilder* mAdaptorBuilder = new AdaptorBuilder();
+  auto graphicsFactory = mAdaptorBuilder->GetGraphicsFactory();
+
+  impl->Initialize( graphicsFactory, configuration );
+  delete mAdaptorBuilder; // Not needed anymore as the graphics interface has now been created
 
   return adaptor;
 }
@@ -91,13 +102,34 @@ Dali::Adaptor* Adaptor::New( Dali::Window window, Dali::Configuration::ContextLo
 {
   Any winId = window.GetNativeHandle();
 
-  Window& windowImpl = Dali::GetImplementation(window);
+  Window& windowImpl = Dali::GetImplementation( window );
   Dali::Adaptor* adaptor = New( winId, windowImpl.GetSurface(), configuration, environmentOptions );
-  windowImpl.SetAdaptor(*adaptor);
+  windowImpl.SetAdaptor( *adaptor );
   return adaptor;
 }
 
-void Adaptor::Initialize( Dali::Configuration::ContextLoss configuration )
+Dali::Adaptor* Adaptor::New( GraphicsFactory& graphicsFactory, Any nativeWindow, Dali::RenderSurfaceInterface *surface, Dali::Configuration::ContextLoss configuration, EnvironmentOptions* environmentOptions )
+{
+  Dali::Adaptor* adaptor = new Dali::Adaptor; // Public adaptor
+  Adaptor* impl = new Adaptor( nativeWindow, *adaptor, surface, environmentOptions ); // Impl adaptor
+  adaptor->mImpl = impl;
+
+  impl->Initialize( graphicsFactory, configuration );
+
+  return adaptor;
+} // Called second
+
+Dali::Adaptor* Adaptor::New( GraphicsFactory& graphicsFactory, Dali::Window window, Dali::Configuration::ContextLoss configuration, EnvironmentOptions* environmentOptions )
+{
+  Any winId = window.GetNativeHandle();
+
+  Window& windowImpl = Dali::GetImplementation( window );
+  Dali::Adaptor* adaptor = New( graphicsFactory, winId, windowImpl.GetSurface(), configuration, environmentOptions );
+  windowImpl.SetAdaptor( *adaptor );
+  return adaptor;
+} // Called first
+
+void Adaptor::Initialize( GraphicsFactory& graphicsFactory, Dali::Configuration::ContextLoss configuration )
 {
   // all threads here (event, update, and render) will send their logs to TIZEN Platform's LogMessage handler.
   Dali::Integration::Log::LogFunction logFunction( Dali::TizenPlatform::LogMessage );
@@ -115,8 +147,8 @@ void Adaptor::Initialize( Dali::Configuration::ContextLoss configuration )
   {
     dataRetentionPolicy = ResourcePolicy::DALI_DISCARDS_ALL_DATA;
   }
-  // Note, Tizen does not use DALI_RETAINS_ALL_DATA, as it can reload images from
-  // files automatically.
+
+  // Note, Tizen does not use DALI_RETAINS_ALL_DATA, as it can reload images from files automatically.
 
   if( mEnvironmentOptions->PerformanceServerRequired() )
   {
@@ -128,35 +160,36 @@ void Adaptor::Initialize( Dali::Configuration::ContextLoss configuration )
 
   mCallbackManager = CallbackManager::New();
 
-  PositionSize size = mSurface->GetPositionSize();
+  WindowPane defaultWindow = mWindowFrame.front();
+
+  DALI_ASSERT_DEBUG( defaultWindow.surface && "Surface not initialized" );
+
+  PositionSize size = defaultWindow.surface->GetPositionSize();
+
+  defaultWindow.surface->SetAdaptor(*this);
 
   mGestureManager = new GestureManager(*this, Vector2(size.width, size.height), mCallbackManager, *mEnvironmentOptions);
 
-  if( mEnvironmentOptions->GetGlesCallTime() > 0 )
-  {
-    mGLES = new GlProxyImplementation( *mEnvironmentOptions );
-  }
-  else
-  {
-    mGLES = new GlImplementation();
-  }
+  mGraphics = &( graphicsFactory.Create() );
+  mGraphics->Initialize( mEnvironmentOptions );
 
-  const Integration::DepthBufferAvailable depthBufferAvailable = static_cast< Integration::DepthBufferAvailable >( mEnvironmentOptions->DepthBufferRequired() );
-  const Integration::StencilBufferAvailable stencilBufferAvailable = static_cast< Integration::StencilBufferAvailable >( mEnvironmentOptions->StencilBufferRequired() );
+  auto eglGraphics = static_cast<EglGraphics *>( mGraphics ); // This interface is temporary until Core has been updated to match
 
-  mEglFactory = new EglFactory( mEnvironmentOptions->GetMultiSamplingLevel(), depthBufferAvailable, stencilBufferAvailable );
+  // This will only be created once
+  eglGraphics->Create();
 
-  EglSyncImplementation* eglSyncImpl = mEglFactory->GetSyncImplementation();
+  GlImplementation& mGLES = eglGraphics->GetGlesInterface();
+  EglSyncImplementation& eglSyncImpl = eglGraphics->GetSyncImplementation();
 
   mCore = Integration::Core::New( *this,
                                   *mPlatformAbstraction,
-                                  *mGLES,
-                                  *eglSyncImpl,
+                                  mGLES,
+                                  eglSyncImpl,
                                   *mGestureManager,
                                   dataRetentionPolicy ,
                                   ( 0u != mEnvironmentOptions->GetRenderToFboInterval() ) ? Integration::RenderToFrameBuffer::TRUE : Integration::RenderToFrameBuffer::FALSE,
-                                  depthBufferAvailable,
-                                  stencilBufferAvailable );
+                                  mGraphics->GetDepthBufferRequired(),
+                                  mGraphics->GetStencilBufferRequired() );
 
   const unsigned int timeInterval = mEnvironmentOptions->GetObjectProfilerInterval();
   if( 0u < timeInterval )
@@ -168,6 +201,8 @@ void Adaptor::Initialize( Dali::Configuration::ContextLoss configuration )
 
   mVSyncMonitor = new VSyncMonitor;
 
+  mDisplayConnection = Dali::DisplayConnection::New( *mGraphics, defaultWindow.surface->GetSurfaceType() );
+
   mThreadController = new ThreadController( *this, *mEnvironmentOptions );
 
   // Should be called after Core creation
@@ -239,10 +274,8 @@ void Adaptor::Initialize( Dali::Configuration::ContextLoss configuration )
   // Set max texture size
   if( mEnvironmentOptions->GetMaxTextureSize() > 0 )
   {
-    Dali::SetMaxTextureSize( mEnvironmentOptions->GetMaxTextureSize() );
+    Dali::TizenPlatform::ImageLoader::SetMaxTextureSize( mEnvironmentOptions->GetMaxTextureSize() );
   }
-
-  SetupSystemInformation();
 }
 
 Adaptor::~Adaptor()
@@ -264,13 +297,15 @@ Adaptor::~Adaptor()
   delete mObjectProfiler;
 
   delete mCore;
-  delete mEglFactory;
-  delete mGLES;
+
   delete mGestureManager;
+  delete mDisplayConnection;
   delete mPlatformAbstraction;
   delete mCallbackManager;
   delete mPerformanceInterface;
 
+  mGraphics->Destroy();
+
   // uninstall it on this thread (main actor thread)
   Dali::Integration::Log::UninstallLogFunction();
 
@@ -283,18 +318,23 @@ Adaptor::~Adaptor()
 
 void Adaptor::Start()
 {
-  // it doesn't support restart after stop at this moment
-  // to support restarting, need more testing
+  // It doesn't support restart after stop at this moment to support restarting, need more testing
   if( READY != mState )
   {
     return;
   }
 
+  mCore->Initialize();
+
+  SetupSystemInformation();
+
   // Start the callback manager
   mCallbackManager->Start();
 
-  // create event handler
-  mEventHandler = new EventHandler( mSurface, *this, *mGestureManager, *this, mDragAndDropDetector );
+  WindowPane defaultWindow = mWindowFrame.front();
+
+  // Create event handler
+  mEventHandler = new EventHandler( defaultWindow.surface, *this, *mGestureManager, *this, mDragAndDropDetector );
 
   if( mDeferredRotationObserver != NULL )
   {
@@ -304,24 +344,24 @@ void Adaptor::Start()
 
   unsigned int dpiHor, dpiVer;
   dpiHor = dpiVer = 0;
-  Dali::DisplayConnection::GetDpi(dpiHor, dpiVer);
 
-  // tell core about the DPI value
-  mCore->SetDpi(dpiHor, dpiVer);
+  defaultWindow.surface->GetDpi( dpiHor, dpiVer );
 
   // set the DPI value for font rendering
   FontClient fontClient = FontClient::Get();
   fontClient.SetDpi( dpiHor, dpiVer );
 
   // Tell the core the size of the surface just before we start the render-thread
-  PositionSize size = mSurface->GetPositionSize();
-  mCore->SurfaceResized( size.width, size.height );
+  mCore->SurfaceResized( defaultWindow.surface );
 
   // Initialize the thread controller
   mThreadController->Initialize();
 
   ProcessCoreEvents(); // Ensure any startup messages are processed.
 
+  // Initialize the image loader plugin
+  Internal::Adaptor::ImageLoaderPluginProxy::Initialize();
+
   for ( ObserverContainer::iterator iter = mObservers.begin(), endIter = mObservers.end(); iter != endIter; ++iter )
   {
     (*iter)->OnStart();
@@ -374,7 +414,7 @@ void Adaptor::Resume()
       (*iter)->OnResume();
     }
 
-    // trigger processing of events queued up while paused
+    // Trigger processing of events queued up while paused
     mCore->ProcessEvents();
 
     // Do at end to ensure our first update/render after resumption includes the processed messages as well
@@ -395,6 +435,9 @@ void Adaptor::Stop()
 
     mThreadController->Stop();
 
+    // Clear out all the handles to Windows
+    mWindowFrame.clear();
+
     // Delete the TTS player
     for(int i =0; i < Dali::TtsPlayer::MODE_NUM; i++)
     {
@@ -404,6 +447,9 @@ void Adaptor::Stop()
       }
     }
 
+    // Destroy the image loader plugin
+    Internal::Adaptor::ImageLoaderPluginProxy::Destroy();
+
     delete mEventHandler;
     mEventHandler = NULL;
 
@@ -444,34 +490,46 @@ void Adaptor::FeedKeyEvent( KeyEvent& keyEvent )
   mEventHandler->FeedKeyEvent( keyEvent );
 }
 
-void Adaptor::ReplaceSurface( Any nativeWindow, RenderSurface& surface )
+void Adaptor::ReplaceSurface( Any nativeWindow, Dali::RenderSurfaceInterface& newSurface )
 {
-  PositionSize positionSize = surface.GetPositionSize();
-
-  // let the core know the surface size has changed
-  mCore->SurfaceResized( positionSize.width, positionSize.height );
+  // Let the core know the surface size has changed
+  mCore->SurfaceResized( &newSurface );
 
   mResizedSignal.Emit( mAdaptor );
 
-  mNativeWindow = nativeWindow;
-  mSurface = &surface;
+  WindowPane newDefaultWindow;
+  newDefaultWindow.nativeWindow = nativeWindow;
+  newDefaultWindow.surface = &newSurface;
+  newDefaultWindow.surface->SetAdaptor(*this);
+
+  WindowPane oldDefaultWindow = mWindowFrame.front();
 
-  // flush the event queue to give the update-render thread chance
+  // Update WindowFrame
+  std::vector<WindowPane>::iterator iter = mWindowFrame.begin();
+  iter = mWindowFrame.insert( iter, newDefaultWindow );
+
+  // Flush the event queue to give the update-render thread chance
   // to start processing messages for new camera setup etc as soon as possible
   ProcessCoreEvents();
 
-  // this method blocks until the render thread has completed the replace.
-  mThreadController->ReplaceSurface(mSurface);
+  // This method blocks until the render thread has completed the replace.
+  mThreadController->ReplaceSurface( newDefaultWindow.surface );
+
+  // Must delete the old Window only after the render thread has completed the replace
+  oldDefaultWindow.surface->DestroySurface();
+  oldDefaultWindow.surface = nullptr;
 }
 
-RenderSurface& Adaptor::GetSurface() const
+Dali::RenderSurfaceInterface& Adaptor::GetSurface() const
 {
-  return *mSurface;
+  WindowPane defaultWindow = mWindowFrame.front();
+  return *(defaultWindow.surface);
 }
 
 void Adaptor::ReleaseSurfaceLock()
 {
-  mSurface->ReleaseLock();
+  WindowPane defaultWindow = mWindowFrame.front();
+  defaultWindow.surface->ReleaseLock();
 }
 
 Dali::TtsPlayer Adaptor::GetTtsPlayer(Dali::TtsPlayer::Mode mode)
@@ -485,14 +543,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;
@@ -503,6 +561,73 @@ void Adaptor::RemoveIdle( CallbackBase* callback )
   mCallbackManager->RemoveIdleCallback( callback );
 }
 
+void Adaptor::SetPreRenderCallback( CallbackBase* callback )
+{
+  mThreadController->SetPreRenderCallback( callback );
+}
+
+bool Adaptor::AddWindow( Dali::Window* childWindow, const std::string& childWindowName, const std::string& childWindowClassName, const bool& childWindowMode )
+{
+  Window& windowImpl = Dali::GetImplementation( *childWindow );
+  windowImpl.SetAdaptor( Get() );
+
+  // This is any Window that is not the main (default) one
+  WindowPane additionalWindow;
+  additionalWindow.instance = childWindow;
+  additionalWindow.window_name = childWindowName;
+  additionalWindow.class_name = childWindowClassName;
+  additionalWindow.window_mode = childWindowMode;
+  additionalWindow.surface = windowImpl.GetSurface();
+  additionalWindow.id = windowImpl.GetId();
+
+  // Add the new Window to the Frame - the order is not important
+  mWindowFrame.push_back( additionalWindow );
+
+  return true;
+}
+
+bool Adaptor::RemoveWindow( Dali::Window* childWindow )
+{
+  for ( WindowFrames::iterator iter = mWindowFrame.begin(); iter != mWindowFrame.end(); ++iter )
+  {
+    if( iter->instance == childWindow )
+    {
+      mWindowFrame.erase( iter );
+      return true;
+    }
+  }
+
+  return false;
+}
+
+bool Adaptor::RemoveWindow( std::string childWindowName )
+{
+  for ( WindowFrames::iterator iter = mWindowFrame.begin(); iter != mWindowFrame.end(); ++iter )
+  {
+    if( iter->window_name == childWindowName )
+    {
+      mWindowFrame.erase( iter );
+      return true;
+    }
+  }
+
+  return false;
+}
+
+bool Adaptor::RemoveWindow( Window* childWindow )
+{
+  for ( WindowFrames::iterator iter = mWindowFrame.begin(); iter != mWindowFrame.end(); ++iter )
+  {
+    if( iter->id == childWindow->GetId() )
+    {
+      mWindowFrame.erase( iter );
+      return true;
+    }
+  }
+
+  return false;
+}
+
 Dali::Adaptor& Adaptor::Get()
 {
   DALI_ASSERT_ALWAYS( IsAvailable() && "Adaptor not instantiated" );
@@ -534,21 +659,16 @@ void Adaptor::SetUseHardwareVSync( bool useHardware )
   mVSyncMonitor->SetUseHardwareVSync( useHardware );
 }
 
-EglFactory& Adaptor::GetEGLFactory() const
-{
-  DALI_ASSERT_DEBUG( mEglFactory && "EGL Factory not created" );
-  return *mEglFactory;
-}
-
-EglFactoryInterface& Adaptor::GetEGLFactoryInterface() const
+Dali::DisplayConnection& Adaptor::GetDisplayConnectionInterface()
 {
-  return *mEglFactory;
+  DALI_ASSERT_DEBUG( mDisplayConnection && "Display connection not created" );
+  return *mDisplayConnection;
 }
 
-Integration::GlAbstraction& Adaptor::GetGlAbstraction() const
+GraphicsInterface& Adaptor::GetGraphicsInterface()
 {
-  DALI_ASSERT_DEBUG( mGLES && "GLImplementation not created" );
-  return *mGLES;
+  DALI_ASSERT_DEBUG( mGraphics && "Graphics interface not created" );
+  return *mGraphics;
 }
 
 Dali::Integration::PlatformAbstraction& Adaptor::GetPlatformAbstractionInterface()
@@ -556,11 +676,6 @@ Dali::Integration::PlatformAbstraction& Adaptor::GetPlatformAbstractionInterface
   return *mPlatformAbstraction;
 }
 
-Dali::Integration::GlAbstraction& Adaptor::GetGlesInterface()
-{
-  return *mGLES;
-}
-
 TriggerEventInterface& Adaptor::GetProcessCoreEventsTrigger()
 {
   return *mNotificationTrigger;
@@ -576,9 +691,17 @@ SocketFactoryInterface& Adaptor::GetSocketFactoryInterface()
   return mSocketFactory;
 }
 
-RenderSurface* Adaptor::GetRenderSurfaceInterface()
+Dali::RenderSurfaceInterface* Adaptor::GetRenderSurfaceInterface()
 {
-  return mSurface;
+  if( !mWindowFrame.empty())
+  {
+    WindowPane defaultWindow = mWindowFrame.front();
+    return defaultWindow.surface;
+  }
+  else
+  {
+    return nullptr;
+  }
 }
 
 VSyncMonitorInterface* Adaptor::GetVSyncMonitorInterface()
@@ -648,7 +771,23 @@ void Adaptor::SetMinimumPinchDistance(float distance)
 
 Any Adaptor::GetNativeWindowHandle()
 {
-  return mNativeWindow;
+  WindowPane defaultWindow = mWindowFrame.front();
+  return defaultWindow.nativeWindow;
+}
+
+Any Adaptor::GetGraphicsDisplay()
+{
+  Any display;
+
+  if (mGraphics)
+  {
+    auto eglGraphics = static_cast<EglGraphics *>( mGraphics ); // This interface is temporary until Core has been updated to match
+
+    EglImplementation& eglImpl = eglGraphics->GetEglImplementation();
+    display = eglImpl.GetDisplay();
+  }
+
+  return display;
 }
 
 void Adaptor::SetUseRemoteSurface(bool useRemoteSurface)
@@ -736,7 +875,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 );
   }
 }
 
@@ -772,21 +911,20 @@ void Adaptor::OnDamaged( const DamageArea& area )
   RequestUpdate( false );
 }
 
-void Adaptor::SurfaceResizePrepare( SurfaceSize surfaceSize )
+void Adaptor::SurfaceResizePrepare( Dali::RenderSurfaceInterface* surface, SurfaceSize surfaceSize )
 {
-  // let the core know the surface size has changed
-  mCore->SurfaceResized( surfaceSize.GetWidth(), surfaceSize.GetHeight() );
+  // Let the core know the surface size has changed
+  mCore->SurfaceResized( surface );
 
   mResizedSignal.Emit( mAdaptor );
 }
 
-void Adaptor::SurfaceResizeComplete( SurfaceSize surfaceSize )
+void Adaptor::SurfaceResizeComplete( Dali::RenderSurfaceInterface* surface, SurfaceSize surfaceSize )
 {
-  // flush the event queue to give the update-render thread chance
+  // Flush the event queue to give the update-render thread chance
   // 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();
 }
 
@@ -797,7 +935,7 @@ void Adaptor::NotifySceneCreated()
   // Start thread controller after the scene has been created
   mThreadController->Start();
 
-  // process after surface is created (registering to remote surface provider if required)
+  // Process after surface is created (registering to remote surface provider if required)
   SurfaceInitialized();
 
   mState = RUNNING;
@@ -818,6 +956,16 @@ const LogFactoryInterface& Adaptor::GetLogFactory()
   return *mEnvironmentOptions;
 }
 
+void Adaptor::RegisterProcessor( Integration::Processor& processor )
+{
+  GetCore().RegisterProcessor(processor);
+}
+
+void Adaptor::UnregisterProcessor( Integration::Processor& processor )
+{
+  GetCore().UnregisterProcessor(processor);
+}
+
 void Adaptor::RequestUpdateOnce()
 {
   if( mThreadController )
@@ -826,88 +974,86 @@ void Adaptor::RequestUpdateOnce()
   }
 }
 
-void Adaptor::IndicatorSizeChanged(int height)
-{
-  // let the core know the indicator height is changed
-  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)
+Adaptor::Adaptor(Any nativeWindow, Dali::Adaptor& adaptor, Dali::RenderSurfaceInterface* surface, EnvironmentOptions* environmentOptions)
 : mResizedSignal(),
   mLanguageChangedSignal(),
   mAdaptor( adaptor ),
   mState( READY ),
-  mCore( NULL ),
-  mThreadController( NULL ),
-  mVSyncMonitor( NULL ),
-  mGLES( NULL ),
-  mGlSync( NULL ),
-  mEglFactory( NULL ),
-  mNativeWindow( nativeWindow ),
-  mSurface( surface ),
-  mPlatformAbstraction( NULL ),
-  mEventHandler( NULL ),
-  mCallbackManager( NULL ),
+  mCore( nullptr ),
+  mThreadController( nullptr ),
+  mVSyncMonitor( nullptr ),
+  mGraphics( nullptr ),
+  mDisplayConnection( nullptr ),
+  mWindowFrame(),
+  mPlatformAbstraction( nullptr ),
+  mEventHandler( nullptr ),
+  mCallbackManager( nullptr ),
   mNotificationOnIdleInstalled( false ),
-  mNotificationTrigger( NULL ),
-  mGestureManager( NULL ),
+  mNotificationTrigger( nullptr ),
+  mGestureManager( nullptr ),
   mDaliFeedbackPlugin(),
-  mFeedbackController( NULL ),
+  mFeedbackController( nullptr ),
   mTtsPlayers(),
   mObservers(),
   mDragAndDropDetector(),
-  mDeferredRotationObserver( NULL ),
+  mDeferredRotationObserver( nullptr ),
   mEnvironmentOptions( environmentOptions ? environmentOptions : new EnvironmentOptions /* Create the options if not provided */),
-  mPerformanceInterface( NULL ),
+  mPerformanceInterface( nullptr ),
   mKernelTracer(),
   mSystemTracer(),
   mTriggerEventFactory(),
-  mObjectProfiler( NULL ),
+  mObjectProfiler( nullptr ),
   mSocketFactory(),
   mEnvironmentOptionsOwned( environmentOptions ? false : true /* If not provided then we own the object */ ),
   mUseRemoteSurface( false )
 {
   DALI_ASSERT_ALWAYS( !IsAvailable() && "Cannot create more than one Adaptor per thread" );
-  gThreadLocalAdaptor = this;
-}
 
-// Stereoscopy
+  WindowPane defaultWindow;
+  defaultWindow.nativeWindow = nativeWindow;
+  defaultWindow.surface = surface;
+  defaultWindow.id = 0;
 
-void Adaptor::SetViewMode( ViewMode viewMode )
-{
-  mSurface->SetViewMode( viewMode );
-  mCore->SetViewMode( viewMode );
-}
+  std::vector<WindowPane>::iterator iter = mWindowFrame.begin();
+  iter = mWindowFrame.insert( iter, defaultWindow );
 
-ViewMode Adaptor::GetViewMode() const
-{
-  return mCore->GetViewMode();
+  gThreadLocalAdaptor = this;
 }
 
-void Adaptor::SetStereoBase( float stereoBase )
+void Adaptor::SetRootLayoutDirection( std::string locale )
 {
-  mCore->SetStereoBase( stereoBase );
+  Dali::Stage stage = Dali::Stage::GetCurrent();
+
+  stage.GetRootLayer().SetProperty( Dali::Actor::Property::LAYOUT_DIRECTION,
+                                    static_cast< LayoutDirection::Type >( Internal::Adaptor::Locale::GetDirection( std::string( locale ) ) ) );
 }
 
-float Adaptor::GetStereoBase() const
+bool Adaptor::AddIdleEnterer( CallbackBase* callback, bool forceAdd )
 {
-  return mCore->GetStereoBase();
+  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::SetRootLayoutDirection( std::string locale )
+void Adaptor::RemoveIdleEnterer( CallbackBase* callback )
 {
-  Dali::Stage stage = Dali::Stage::GetCurrent();
-
-  stage.GetRootLayer().SetProperty( Dali::Actor::Property::LAYOUT_DIRECTION,
-                                    static_cast< LayoutDirection::Type >( Internal::Adaptor::Locale::GetDirection( std::string( locale ) ) ) );
+  mCallbackManager->RemoveIdleEntererCallback( callback );
 }
 
 } // namespace Adaptor