X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=dali%2Finternal%2Fadaptor%2Fcommon%2Fcombined-update-render-controller.cpp;h=4b794ce41a4bbf66a28a0c04d6d0c3b818486cea;hb=3382101c1ce68b0b4f1a3398d977b210bcb58e2f;hp=36fc1331b1af2999b8a2ebf53392bf0581afbaf1;hpb=d0703c50e4cbf4401ee39c6ac9c4e8875761a662;p=platform%2Fcore%2Fuifw%2Fdali-adaptor.git diff --git a/dali/internal/adaptor/common/combined-update-render-controller.cpp b/dali/internal/adaptor/common/combined-update-render-controller.cpp index 36fc133..4b794ce 100644 --- a/dali/internal/adaptor/common/combined-update-render-controller.cpp +++ b/dali/internal/adaptor/common/combined-update-render-controller.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019 Samsung Electronics Co., Ltd. + * Copyright (c) 2020 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. @@ -23,7 +23,7 @@ #include // INTERNAL INCLUDES -#include +#include #include #include #include @@ -91,6 +91,7 @@ CombinedUpdateRenderController::CombinedUpdateRenderController( AdaptorInternalS : mFpsTracker( environmentOptions ), mUpdateStatusLogger( environmentOptions ), mEventThreadSemaphore(), + mGraphicsInitializeSemaphore(), mUpdateRenderThreadWaitCondition(), mAdaptorInterfaces( adaptorInterfaces ), mPerformanceInterface( adaptorInterfaces.GetPerformanceInterface() ), @@ -134,7 +135,9 @@ CombinedUpdateRenderController::CombinedUpdateRenderController( AdaptorInternalS TriggerEventFactoryInterface& triggerFactory = mAdaptorInterfaces.GetTriggerEventFactoryInterface(); mSleepTrigger = triggerFactory.CreateTriggerEvent( MakeCallback( this, &CombinedUpdateRenderController::ProcessSleepRequest ), TriggerEventInterface::KEEP_ALIVE_AFTER_TRIGGER ); - sem_init( &mEventThreadSemaphore, 0, 0 ); // Initialize to 0 so that it just waits if sem_post has not been called + // Initialize to 0 so that it just waits if sem_post has not been called + sem_init( &mEventThreadSemaphore, 0, 0 ); + sem_init( &mGraphicsInitializeSemaphore, 0, 0 ); } CombinedUpdateRenderController::~CombinedUpdateRenderController() @@ -343,6 +346,21 @@ void CombinedUpdateRenderController::DeleteSurface( Dali::RenderSurfaceInterface } } +void CombinedUpdateRenderController::WaitForGraphicsInitialization() +{ + LOG_EVENT_TRACE; + + if( mUpdateRenderThread ) + { + LOG_EVENT( "Waiting for graphics initialisation, event-thread blocked" ); + + // Wait until the graphics has been initialised + sem_wait( &mGraphicsInitializeSemaphore ); + + LOG_EVENT( "graphics initialised, event-thread continuing" ); + } +} + void CombinedUpdateRenderController::ResizeSurface() { LOG_EVENT_TRACE; @@ -457,6 +475,9 @@ void CombinedUpdateRenderController::UpdateRenderThread() Dali::DisplayConnection& displayConnection = mAdaptorInterfaces.GetDisplayConnectionInterface(); displayConnection.Initialize(); + // EGL has been initialised at this point + NotifyGraphicsInitialised(); + RenderSurfaceInterface* currentSurface = nullptr; GraphicsInterface& graphics = mAdaptorInterfaces.GetGraphicsInterface(); @@ -548,15 +569,17 @@ void CombinedUpdateRenderController::UpdateRenderThread() if( DALI_UNLIKELY( newSurface ) ) { LOG_UPDATE_RENDER_TRACE_FMT( "Replacing Surface" ); - // 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(); - newSurface->ReplaceGraphicsSurface(); + newSurface->MakeContextCurrent(); + // TODO: ReplaceGraphicsSurface doesn't work, InitializeGraphics() + // already creates new surface window, the surface and the context. + // We probably don't need ReplaceGraphicsSurface at all. + // newSurface->ReplaceGraphicsSurface(); SurfaceReplaced(); } @@ -847,6 +870,11 @@ void CombinedUpdateRenderController::NotifyThreadInitialised() sem_post( &mEventThreadSemaphore ); } +void CombinedUpdateRenderController::NotifyGraphicsInitialised() +{ + sem_post( &mGraphicsInitializeSemaphore ); +} + void CombinedUpdateRenderController::AddPerformanceMarker( PerformanceInterface::MarkerType type ) { if( mPerformanceInterface ) @@ -882,7 +910,6 @@ void CombinedUpdateRenderController::PostRenderWaitForCompletion() while( mPostRendering && ! mNewSurface && // We should NOT wait if we're replacing the surface ! mDeletedSurface && // We should NOT wait if we're deleting the surface - ! mSurfaceResized && // We should NOT wait if we're resizing the surface ! mDestroyUpdateRenderThread ) { mUpdateRenderThreadWaitCondition.Wait( lock );