// 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/stage.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/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/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/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;
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 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;
}
{
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, RenderSurface *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 );
{
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() )
{
mCallbackManager = CallbackManager::New();
- PositionSize size = mSurface->GetPositionSize();
+ WindowPane defaultWindow = mWindowFrame.front();
- mGestureManager = new GestureManager(*this, Vector2(size.width, size.height), mCallbackManager, *mEnvironmentOptions);
+ DALI_ASSERT_DEBUG( defaultWindow.surface && "Surface not initialized" );
- if( mEnvironmentOptions->GetGlesCallTime() > 0 )
- {
- mGLES = new GlProxyImplementation( *mEnvironmentOptions );
- }
- else
- {
- mGLES = new GlImplementation();
- }
+ PositionSize size = defaultWindow.surface->GetPositionSize();
- const Integration::DepthBufferAvailable depthBufferAvailable = static_cast< Integration::DepthBufferAvailable >( mEnvironmentOptions->DepthBufferRequired() );
- const Integration::StencilBufferAvailable stencilBufferAvailable = static_cast< Integration::StencilBufferAvailable >( mEnvironmentOptions->StencilBufferRequired() );
+ mGestureManager = new GestureManager(*this, Vector2(size.width, size.height), mCallbackManager, *mEnvironmentOptions);
+
+ mGraphics = &( graphicsFactory.Create() );
+ mGraphics->Initialize( mEnvironmentOptions );
- mEglFactory = new EglFactory( mEnvironmentOptions->GetMultiSamplingLevel(), depthBufferAvailable, stencilBufferAvailable );
+ auto eglGraphics = static_cast<EglGraphics *>( mGraphics ); // This interface is temporary until Core has been updated to match
- 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 )
mVSyncMonitor = new VSyncMonitor;
+ mDisplayConnection = Dali::DisplayConnection::New( *mGraphics, defaultWindow.surface->GetSurfaceType() );
+
mThreadController = new ThreadController( *this, *mEnvironmentOptions );
// Should be called after Core creation
// Set max texture size
if( mEnvironmentOptions->GetMaxTextureSize() > 0 )
{
- Dali::SetMaxTextureSize( mEnvironmentOptions->GetMaxTextureSize() );
+ Dali::TizenPlatform::ImageLoader::SetMaxTextureSize( mEnvironmentOptions->GetMaxTextureSize() );
}
SetupSystemInformation();
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();
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;
// 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 )
{
unsigned int dpiHor, dpiVer;
dpiHor = dpiVer = 0;
- mSurface->GetDpi( dpiHor, dpiVer );
+
+ defaultWindow.surface->GetDpi( dpiHor, dpiVer );
// tell core about the DPI value
mCore->SetDpi(dpiHor, dpiVer);
fontClient.SetDpi( dpiHor, dpiVer );
// Tell the core the size of the surface just before we start the render-thread
- PositionSize size = mSurface->GetPositionSize();
+ PositionSize size = defaultWindow.surface->GetPositionSize();
+
mCore->SurfaceResized( size.width, size.height );
// Initialize the thread controller
(*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
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++)
{
mEventHandler->FeedKeyEvent( keyEvent );
}
-void Adaptor::ReplaceSurface( Any nativeWindow, RenderSurface& surface )
+void Adaptor::ReplaceSurface( Any nativeWindow, RenderSurface& newSurface )
{
- PositionSize positionSize = surface.GetPositionSize();
+ PositionSize positionSize = newSurface.GetPositionSize();
- // let the core know the surface size has changed
+ // Let the core know the surface size has changed
mCore->SurfaceResized( positionSize.width, positionSize.height );
mResizedSignal.Emit( mAdaptor );
- mNativeWindow = nativeWindow;
- mSurface = &surface;
+ WindowPane newDefaultWindow;
+ newDefaultWindow.nativeWindow = nativeWindow;
+ newDefaultWindow.surface = &newSurface;
+
+ WindowPane oldDefaultWindow = mWindowFrame.front();
+
+ // 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
+ // 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
{
- 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)
mThreadController->SetPreRenderCallback( callback );
}
+bool Adaptor::AddWindow( Dali::Window* childWindow, const std::string& childWindowName, const std::string& childWindowClassName, const bool& childWindowMode )
+{
+ // 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;
+
+ // Add the new Window to the Frame - the order is not important
+ mWindowFrame.push_back( additionalWindow );
+
+ Window& windowImpl = Dali::GetImplementation( *childWindow );
+ windowImpl.SetAdaptor( Get() );
+
+ 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;
+}
+
Dali::Adaptor& Adaptor::Get()
{
DALI_ASSERT_ALWAYS( IsAvailable() && "Adaptor not instantiated" );
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()
return *mPlatformAbstraction;
}
-Dali::Integration::GlAbstraction& Adaptor::GetGlesInterface()
-{
- return *mGLES;
-}
-
TriggerEventInterface& Adaptor::GetProcessCoreEventsTrigger()
{
return *mNotificationTrigger;
RenderSurface* Adaptor::GetRenderSurfaceInterface()
{
- return mSurface;
+ if( !mWindowFrame.empty())
+ {
+ WindowPane defaultWindow = mWindowFrame.front();
+ return defaultWindow.surface;
+ }
+ else
+ {
+ return nullptr;
+ }
}
VSyncMonitorInterface* Adaptor::GetVSyncMonitorInterface()
Any Adaptor::GetNativeWindowHandle()
{
- return mNativeWindow;
+ WindowPane defaultWindow = mWindowFrame.front();
+ return defaultWindow.nativeWindow;
}
Any Adaptor::GetGraphicsDisplay()
{
Any display;
- if( mEglFactory )
+ if (mGraphics)
{
- EglInterface* egl = mEglFactory->GetImplementation();
- if( egl )
- {
- auto eglImpl = static_cast<EglImplementation*>(egl);
- display = eglImpl->GetDisplay();
- }
+ 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::SurfaceResizePrepare( SurfaceSize surfaceSize )
{
- // let the core know the surface size has changed
+ // Let the core know the surface size has changed
mCore->SurfaceResized( surfaceSize.GetWidth(), surfaceSize.GetHeight() );
mResizedSignal.Emit( mAdaptor );
void Adaptor::SurfaceResizeComplete( 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();
// 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;
void Adaptor::IndicatorSizeChanged(int height)
{
- // let the core know the indicator height is changed
+ // Let the core know the indicator height is changed
mCore->SetTopMargin(height);
}
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;
-void Adaptor::SetViewMode( ViewMode viewMode )
-{
- mSurface->SetViewMode( viewMode );
- mCore->SetViewMode( viewMode );
-}
-
-ViewMode Adaptor::GetViewMode() const
-{
- return mCore->GetViewMode();
-}
+ std::vector<WindowPane>::iterator iter = mWindowFrame.begin();
+ iter = mWindowFrame.insert( iter, defaultWindow );
-void Adaptor::SetStereoBase( float stereoBase )
-{
- mCore->SetStereoBase( stereoBase );
-}
-
-float Adaptor::GetStereoBase() const
-{
- return mCore->GetStereoBase();
+ gThreadLocalAdaptor = this;
}
void Adaptor::SetRootLayoutDirection( std::string locale )