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=00769102b30a1472b09dfe36ef42fdea349e3174;hpb=078a6810ed0701920edb0d9d3f88e892dc441b71;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 0076910..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,15 +23,15 @@ #include // INTERNAL INCLUDES -#include -#include -#include -#include -#include +#include #include +#include +#include #include #include #include +#include +#include namespace Dali { @@ -91,6 +91,7 @@ CombinedUpdateRenderController::CombinedUpdateRenderController( AdaptorInternalS : mFpsTracker( environmentOptions ), mUpdateStatusLogger( environmentOptions ), mEventThreadSemaphore(), + mGraphicsInitializeSemaphore(), mUpdateRenderThreadWaitCondition(), mAdaptorInterfaces( adaptorInterfaces ), mPerformanceInterface( adaptorInterfaces.GetPerformanceInterface() ), @@ -116,7 +117,8 @@ CombinedUpdateRenderController::CombinedUpdateRenderController( AdaptorInternalS mPostRendering( FALSE ), mSurfaceResized( FALSE ), mForceClear( FALSE ), - mUploadWithoutRendering( FALSE ) + mUploadWithoutRendering( FALSE ), + mFirstFrameAfterResume( FALSE ) { LOG_EVENT_TRACE; @@ -133,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() @@ -216,6 +220,7 @@ void CombinedUpdateRenderController::Resume() mRunning = TRUE; mForceClear = TRUE; + mFirstFrameAfterResume = TRUE; DALI_LOG_RELEASE_INFO( "CombinedUpdateRenderController::Resume\n" ); } @@ -341,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; @@ -455,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(); @@ -546,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(); } @@ -635,6 +660,14 @@ void CombinedUpdateRenderController::UpdateRenderThread() eglImpl.MakeContextCurrent( EGL_NO_SURFACE, eglImpl.GetContext() ); } + if( mFirstFrameAfterResume ) + { + // mFirstFrameAfterResume is set to true when the thread is resumed + // Let eglImplementation know the first frame after thread initialized or resumed. + eglImpl.SetFirstFrameAfterResume(); + mFirstFrameAfterResume = FALSE; + } + Integration::RenderStatus renderStatus; AddPerformanceMarker( PerformanceInterface::RENDER_START ); @@ -837,6 +870,11 @@ void CombinedUpdateRenderController::NotifyThreadInitialised() sem_post( &mEventThreadSemaphore ); } +void CombinedUpdateRenderController::NotifyGraphicsInitialised() +{ + sem_post( &mGraphicsInitializeSemaphore ); +} + void CombinedUpdateRenderController::AddPerformanceMarker( PerformanceInterface::MarkerType type ) { if( mPerformanceInterface ) @@ -872,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 );