CombinedUpdateRenderController::CombinedUpdateRenderController( AdaptorInternalServices& adaptorInterfaces, const EnvironmentOptions& environmentOptions )
: mFpsTracker( environmentOptions ),
mUpdateStatusLogger( environmentOptions ),
- mRenderHelper( adaptorInterfaces ),
mEventThreadSemaphore(),
mUpdateRenderThreadWaitCondition(),
mAdaptorInterfaces( adaptorInterfaces ),
mEnvironmentOptions( environmentOptions ),
mNotificationTrigger( adaptorInterfaces.GetProcessCoreEventsTrigger() ),
mSleepTrigger( NULL ),
+ mPreRenderCallback( NULL ),
mUpdateRenderThread( NULL ),
mDefaultFrameDelta( 0.0f ),
mDefaultFrameDurationMilliseconds( 0u ),
Stop();
+ delete mPreRenderCallback;
delete mSleepTrigger;
}
int error = pthread_create( mUpdateRenderThread, NULL, InternalUpdateRenderThreadEntryFunc, this );
DALI_ASSERT_ALWAYS( !error && "Return code from pthread_create() when creating UpdateRenderThread" );
- // The Update/Render thread will now run and initialise EGL etc. and will then wait for Start to be called
+ // The Update/Render thread will now run and initialise the graphics interface etc. and will then wait for Start to be called
// When this function returns, the application initialisation on the event thread should occur
}
sem_wait( &mEventThreadSemaphore );
}
- mRenderHelper.Start();
+ RenderSurface* currentSurface = mAdaptorInterfaces.GetRenderSurfaceInterface();
+ if( currentSurface )
+ {
+ currentSurface->StartRender();
+ }
mRunning = TRUE;
LOG_EVENT_TRACE;
// Stop Rendering and the Update/Render Thread
- mRenderHelper.Stop();
+ RenderSurface* currentSurface = mAdaptorInterfaces.GetRenderSurfaceInterface();
+ if( currentSurface )
+ {
+ currentSurface->StopRender();
+ }
StopUpdateRenderThread();
LOG_EVENT( "mDefaultFrameDelta(%.6f), mDefaultFrameDurationMilliseconds(%lld), mDefaultFrameDurationNanoseconds(%lld)", mDefaultFrameDelta, mDefaultFrameDurationMilliseconds, mDefaultFrameDurationNanoseconds );
}
+void CombinedUpdateRenderController::SetPreRenderCallback( CallbackBase* callback )
+{
+ LOG_EVENT_TRACE;
+ LOG_EVENT( "Set PreRender Callback" );
+
+ ConditionalWait::ScopedLock updateLock( mUpdateRenderThreadWaitCondition );
+ if( mPreRenderCallback )
+ {
+ delete mPreRenderCallback;
+ }
+ mPreRenderCallback = callback;
+}
+
///////////////////////////////////////////////////////////////////////////////////////////////////
// EVENT THREAD
///////////////////////////////////////////////////////////////////////////////////////////////////
LOG_UPDATE_RENDER( "THREAD CREATED" );
- mRenderHelper.InitializeEgl();
+ RenderSurface* currentSurface = mAdaptorInterfaces.GetRenderSurfaceInterface();
+ if( currentSurface )
+ {
+ currentSurface->InitializeGraphics( mAdaptorInterfaces.GetGraphicsInterface(), mAdaptorInterfaces.GetDisplayConnectionInterface() );
+ }
- // tell core it has a context
+ // Tell core it has a context
mCore.ContextCreated();
NotifyThreadInitialised();
if( DALI_UNLIKELY( newSurface ) )
{
LOG_UPDATE_RENDER_TRACE_FMT( "Replacing Surface" );
- mRenderHelper.ReplaceSurface( newSurface );
+
+ // This is designed for replacing pixmap surfaces, but should work for window as well
+ // we need to delete the surface and renderable (pixmap / window)
+ // Then create a new pixmap/window and new surface
+ // If the new surface has a different display connection, then the context will be lost
+
+ mAdaptorInterfaces.GetDisplayConnectionInterface().Initialize();
+ newSurface->InitializeGraphics( mAdaptorInterfaces.GetGraphicsInterface(), mAdaptorInterfaces.GetDisplayConnectionInterface() );
+ newSurface->ReplaceGraphicsSurface();
SurfaceReplaced();
}
}
// Check resize
- bool surfaceResized = ShouldSurfaceBeResized();
- if( DALI_UNLIKELY( surfaceResized ) )
+ bool surfaceResized = false;
+ bool shouldSurfaceBeResized = ShouldSurfaceBeResized();
+ if( DALI_UNLIKELY( shouldSurfaceBeResized ) )
{
- // RenderHelper::ResizeSurface() should be called right after a viewport is changed.
if( updateStatus.SurfaceRectChanged() )
{
LOG_UPDATE_RENDER_TRACE_FMT( "Resizing Surface" );
- mRenderHelper.ResizeSurface();
SurfaceResized();
+ surfaceResized = true;
}
}
// RENDER
//////////////////////////////
- mRenderHelper.ConsumeEvents();
- mRenderHelper.PreRender();
+ mAdaptorInterfaces.GetDisplayConnectionInterface().ConsumeEvents();
+
+ if( mPreRenderCallback != NULL )
+ {
+ bool keepCallback = CallbackBase::ExecuteReturn<bool>(*mPreRenderCallback);
+ if( ! keepCallback )
+ {
+ delete mPreRenderCallback;
+ mPreRenderCallback = NULL;
+ }
+ }
+
+ currentSurface = mAdaptorInterfaces.GetRenderSurfaceInterface();
+ if( currentSurface )
+ {
+ currentSurface->PreRender( surfaceResized );
+ }
Integration::RenderStatus renderStatus;
if( renderStatus.NeedsPostRender() )
{
- mRenderHelper.PostRender( isRenderingToFbo );
+ if( currentSurface )
+ {
+ currentSurface->PostRender( isRenderingToFbo, ( mNewSurface != NULL ), surfaceResized );
+ }
}
// Trigger event thread to request Update/Render thread to sleep if update not required
- if( ( Integration::KeepUpdating::NOT_REQUESTED == keepUpdatingStatus ) &&
- ! renderStatus.NeedsUpdate() )
+ if( ( Integration::KeepUpdating::NOT_REQUESTED == keepUpdatingStatus ) && !renderStatus.NeedsUpdate() )
{
mSleepTrigger->Trigger();
updateRequired = false;
// Inform core of context destruction & shutdown EGL
mCore.ContextDestroyed();
- mRenderHelper.ShutdownEgl();
+ currentSurface = mAdaptorInterfaces.GetRenderSurfaceInterface();
+ if( currentSurface )
+ {
+ currentSurface->DestroySurface();
+ currentSurface = nullptr;
+ }
LOG_UPDATE_RENDER( "THREAD DESTROYED" );