#include <errno.h>
#include <dali/integration-api/platform-abstraction.h>
#include <unistd.h>
+#include "dali/public-api/common/dali-common.h"
// INTERNAL INCLUDES
#include <dali/integration-api/adaptor-framework/trigger-event-factory.h>
CombinedUpdateRenderController::CombinedUpdateRenderController( AdaptorInternalServices& adaptorInterfaces, const EnvironmentOptions& environmentOptions, ThreadMode threadMode )
: mFpsTracker( environmentOptions ),
mUpdateStatusLogger( environmentOptions ),
- mEventThreadSemaphore(),
- mGraphicsInitializeSemaphore(),
+ mEventThreadSemaphore(0),
+ mSurfaceSemaphore(0),
mUpdateRenderThreadWaitCondition(),
mAdaptorInterfaces( adaptorInterfaces ),
mPerformanceInterface( adaptorInterfaces.GetPerformanceInterface() ),
}
mSleepTrigger = TriggerEventFactory::CreateTriggerEvent( MakeCallback( this, &CombinedUpdateRenderController::ProcessSleepRequest ), TriggerEventInterface::KEEP_ALIVE_AFTER_TRIGGER );
-
- // 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()
DALI_ASSERT_ALWAYS( ! mUpdateRenderThread );
// Create Update/Render Thread
+ ConditionalWait::ScopedLock lock(mGraphicsInitializeWait);
mUpdateRenderThread = new pthread_t();
int error = pthread_create( mUpdateRenderThread, NULL, InternalUpdateRenderThreadEntryFunc, this );
DALI_ASSERT_ALWAYS( !error && "Return code from pthread_create() when creating UpdateRenderThread" );
// Wait until all threads created in Initialise are up and running
for( unsigned int i = 0; i < CREATED_THREAD_COUNT; ++i )
{
- sem_wait( &mEventThreadSemaphore );
- }
-
- Dali::RenderSurfaceInterface* currentSurface = mAdaptorInterfaces.GetRenderSurfaceInterface();
- if( currentSurface )
- {
- currentSurface->StartRender();
+ mEventThreadSemaphore.Acquire();
}
mRunning = TRUE;
RunUpdateRenderThread( CONTINUOUS, AnimationProgression::NONE, UpdateMode::NORMAL );
+ Dali::RenderSurfaceInterface* currentSurface = mAdaptorInterfaces.GetRenderSurfaceInterface();
+ if( currentSurface )
+ {
+ currentSurface->StartRender();
+ }
+
DALI_LOG_RELEASE_INFO( "CombinedUpdateRenderController::Start\n" );
}
}
// Wait until the surface has been replaced
- sem_wait( &mEventThreadSemaphore );
+ mSurfaceSemaphore.Acquire();
LOG_EVENT( "Surface replaced, event-thread continuing" );
}
}
// Wait until the surface has been deleted
- sem_wait( &mEventThreadSemaphore );
+ mSurfaceSemaphore.Acquire();
LOG_EVENT( "Surface deleted, event-thread continuing" );
}
void CombinedUpdateRenderController::WaitForGraphicsInitialization()
{
+ ConditionalWait::ScopedLock lk(mGraphicsInitializeWait);
LOG_EVENT_TRACE;
if( mUpdateRenderThread )
LOG_EVENT( "Waiting for graphics initialisation, event-thread blocked" );
// Wait until the graphics has been initialised
- sem_wait( &mGraphicsInitializeSemaphore );
+ mGraphicsInitializeWait.Wait(lk);
LOG_EVENT( "graphics initialised, event-thread continuing" );
}
}
}
- eglGraphics->GetGlesInterface().ContextCreated();
+ GlImplementation& gles = eglGraphics->GetGlesInterface();
+ gles.ContextCreated();
+ eglGraphics->SetGlesVersion( gles.GetGlesVersion() );
// Tell core it has a context
mCore.ContextCreated();
// clear previous frame damaged render items rects, buffer history is tracked on surface level
mDamagedRects.clear();
- // If user damaged areas are not set
- if (!eglImpl.DamageAreasSet())
- {
- // Collect damage rects
- mCore.PreRender( scene, mDamagedRects );
- }
+ // Collect damage rects
+ mCore.PreRender( scene, mDamagedRects );
// Render off-screen frame buffers first if any
mCore.RenderScene( windowRenderStatus, scene, true );
void CombinedUpdateRenderController::SurfaceReplaced()
{
// Just increment the semaphore
- sem_post( &mEventThreadSemaphore );
+ mSurfaceSemaphore.Release(1);
}
Dali::RenderSurfaceInterface* CombinedUpdateRenderController::ShouldSurfaceBeDeleted()
void CombinedUpdateRenderController::SurfaceDeleted()
{
// Just increment the semaphore
- sem_post( &mEventThreadSemaphore );
+ mSurfaceSemaphore.Release(1);
}
bool CombinedUpdateRenderController::ShouldSurfaceBeResized()
void CombinedUpdateRenderController::NotifyThreadInitialised()
{
// Just increment the semaphore
- sem_post( &mEventThreadSemaphore );
+ mEventThreadSemaphore.Release(1);
}
void CombinedUpdateRenderController::NotifyGraphicsInitialised()
{
- sem_post( &mGraphicsInitializeSemaphore );
+ mGraphicsInitializeWait.Notify();
}
void CombinedUpdateRenderController::AddPerformanceMarker( PerformanceInterface::MarkerType type )