X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=dali%2Finternal%2Fcommon%2Fcore-impl.cpp;h=12dbec6b6cdcf363ff0b38b68f493f1b29f6ab0f;hb=9697546f6395000a500259997c415d9ff3c2e337;hp=d176f707b2f187ed274eec8940e07fb35cb36829;hpb=918e3a5c8ce61fa37b2d8b8df63676a4379f8a94;p=platform%2Fcore%2Fuifw%2Fdali-core.git diff --git a/dali/internal/common/core-impl.cpp b/dali/internal/common/core-impl.cpp index d176f70..12dbec6 100644 --- a/dali/internal/common/core-impl.cpp +++ b/dali/internal/common/core-impl.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016 Samsung Electronics Co., Ltd. + * Copyright (c) 2018 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. @@ -56,7 +56,7 @@ using Dali::Internal::SceneGraph::RenderQueue; namespace { // The Update for frame N+1 may be processed whilst frame N is being rendered. -const unsigned int MAXIMUM_UPDATE_COUNT = 2u; +const uint32_t MAXIMUM_UPDATE_COUNT = 2u; #if defined(DEBUG_ENABLED) Debug::Filter* gCoreFilter = Debug::Filter::New(Debug::Concise, false, "LOG_CORE"); @@ -78,12 +78,17 @@ using Integration::Event; using Integration::UpdateStatus; using Integration::RenderStatus; -Core::Core( RenderController& renderController, PlatformAbstraction& platform, - GlAbstraction& glAbstraction, GlSyncAbstraction& glSyncAbstraction, - GestureManager& gestureManager, ResourcePolicy::DataRetention dataRetentionPolicy) +Core::Core( RenderController& renderController, + PlatformAbstraction& platform, + GlAbstraction& glAbstraction, + GlSyncAbstraction& glSyncAbstraction, + GestureManager& gestureManager, + ResourcePolicy::DataRetention dataRetentionPolicy, + Integration::RenderToFrameBuffer renderToFboEnabled, + Integration::DepthBufferAvailable depthBufferAvailable, + Integration::StencilBufferAvailable stencilBufferAvailable ) : mRenderController( renderController ), mPlatform(platform), - mIsActive(true), mProcessingEvent(false) { // Create the thread local storage @@ -100,7 +105,7 @@ Core::Core( RenderController& renderController, PlatformAbstraction& platform, mRenderTaskProcessor = new SceneGraph::RenderTaskProcessor(); - mRenderManager = RenderManager::New( glAbstraction, glSyncAbstraction ); + mRenderManager = RenderManager::New( glAbstraction, glSyncAbstraction, depthBufferAvailable, stencilBufferAvailable ); RenderQueue& renderQueue = mRenderManager->GetRenderQueue(); @@ -117,12 +122,12 @@ Core::Core( RenderController& renderController, PlatformAbstraction& platform, mRenderManager->SetShaderSaver( *mUpdateManager ); - mStage = IntrusivePtr( Stage::New( *mAnimationPlaylist, *mPropertyNotificationManager, *mUpdateManager, *mNotificationManager ) ); + mStage = IntrusivePtr( Stage::New( *mAnimationPlaylist, *mPropertyNotificationManager, *mUpdateManager, *mNotificationManager, mRenderController ) ); // This must be called after stage is created but before stage initialization mRelayoutController = IntrusivePtr< RelayoutController >( new RelayoutController( mRenderController ) ); - mStage->Initialize(); + mStage->Initialize( renderToFboEnabled == Integration::RenderToFrameBuffer::TRUE ); mGestureEventProcessor = new GestureEventProcessor( *mStage, *mUpdateManager, gestureManager, mRenderController ); mEventProcessor = new EventProcessor( *mStage, *mNotificationManager, *mGestureEventProcessor ); @@ -182,30 +187,30 @@ void Core::ContextDestroyed() mRenderManager->ContextDestroyed(); } -void Core::SurfaceResized( unsigned int width, unsigned int height ) +void Core::SurfaceResized( uint32_t width, uint32_t height ) { - mStage->SurfaceResized( width, height ); + mStage->SurfaceResized( static_cast( width ), static_cast( height ) ); // The stage-size may be less than surface-size (reduced by top-margin) Vector2 size = mStage->GetSize(); - mRelayoutController->SetStageSize( size.width, size.height ); + mRelayoutController->SetStageSize( static_cast( size.width ), static_cast( size.height ) ); // values get truncated } -void Core::SetTopMargin( unsigned int margin ) +void Core::SetTopMargin( uint32_t margin ) { mStage->SetTopMargin( margin ); // The stage-size may be less than surface-size (reduced by top-margin) Vector2 size = mStage->GetSize(); - mRelayoutController->SetStageSize( size.width, size.height ); + mRelayoutController->SetStageSize( static_cast( size.width ), static_cast( size.height ) ); // values get truncated } -void Core::SetDpi( unsigned int dpiHorizontal, unsigned int dpiVertical ) +void Core::SetDpi( uint32_t dpiHorizontal, uint32_t dpiVertical ) { - mStage->SetDpi( Vector2( dpiHorizontal , dpiVertical) ); + mStage->SetDpi( Vector2( static_cast( dpiHorizontal ), static_cast( dpiVertical ) ) ); } -void Core::Update( float elapsedSeconds, unsigned int lastVSyncTimeMilliseconds, unsigned int nextVSyncTimeMilliseconds, Integration::UpdateStatus& status ) +void Core::Update( float elapsedSeconds, uint32_t lastVSyncTimeMilliseconds, uint32_t nextVSyncTimeMilliseconds, Integration::UpdateStatus& status, bool renderToFboEnabled, bool isRenderingToFbo ) { // set the time delta so adaptor can easily print FPS with a release build with 0 as // it is cached by frametime @@ -215,31 +220,23 @@ void Core::Update( float elapsedSeconds, unsigned int lastVSyncTimeMilliseconds, // Use the estimated time diff till we render as the elapsed time. status.keepUpdating = mUpdateManager->Update( elapsedSeconds, lastVSyncTimeMilliseconds, - nextVSyncTimeMilliseconds ); + nextVSyncTimeMilliseconds, + renderToFboEnabled, + isRenderingToFbo ); // Check the Notification Manager message queue to set needsNotification status.needsNotification = mNotificationManager->MessagesToProcess(); + // Check if the default surface is changed + status.surfaceRectChanged = mUpdateManager->IsDefaultSurfaceRectChanged(); + // No need to keep update running if there are notifications to process. // Any message to update will wake it up anyways } -void Core::Render( RenderStatus& status ) -{ - mRenderManager->Render( status ); -} - -void Core::Suspend() +void Core::Render( RenderStatus& status, bool forceClear ) { - mIsActive = false; -} - -void Core::Resume() -{ - mIsActive = true; - - // trigger processing of events queued up while paused - ProcessEvents(); + mRenderManager->Render( status, forceClear ); } void Core::SceneCreated() @@ -260,7 +257,7 @@ void Core::ProcessEvents() if( mProcessingEvent ) { DALI_LOG_ERROR( "ProcessEvents should not be called from within ProcessEvents!\n" ); - mRenderController.RequestProcessEventsOnIdle(); + mRenderController.RequestProcessEventsOnIdle( false ); return; } @@ -274,29 +271,31 @@ void Core::ProcessEvents() mNotificationManager->ProcessMessages(); - // Avoid allocating MessageBuffers, triggering size-negotiation or sending any other spam whilst paused - if( mIsActive ) - { - // Emit signal here to inform listeners that event processing has finished. - mStage->EmitEventProcessingFinishedSignal(); + // Emit signal here to inform listeners that event processing has finished. + mStage->EmitEventProcessingFinishedSignal(); - // Run the size negotiation after event processing finished signal - mRelayoutController->Relayout(); + // Run any registered processors + RunProcessors(); - // Rebuild depth tree after event processing has finished - mStage->RebuildDepthTree(); + // Run the size negotiation after event processing finished signal + mRelayoutController->Relayout(); - // Flush any queued messages for the update-thread - const bool messagesToProcess = mUpdateManager->FlushQueue(); - // Check if the touch or gestures require updates. - const bool gestureNeedsUpdate = mGestureEventProcessor->NeedsUpdate(); + // Rebuild depth tree after event processing has finished + mStage->RebuildDepthTree(); - if( messagesToProcess || gestureNeedsUpdate ) - { - // tell the render controller to keep update thread running - mRenderController.RequestUpdate(); - } + // Flush any queued messages for the update-thread + const bool messagesToProcess = mUpdateManager->FlushQueue(); + + // Check if the touch or gestures require updates. + const bool gestureNeedsUpdate = mGestureEventProcessor->NeedsUpdate(); + // Check if the next update is forced. + const bool forceUpdate = mStage->IsNextUpdateForced(); + + if( messagesToProcess || gestureNeedsUpdate || forceUpdate ) + { + // tell the render controller to keep update thread running + mRenderController.RequestUpdate( forceUpdate ); } mRelayoutController->SetProcessingCoreEvents( false ); @@ -305,7 +304,7 @@ void Core::ProcessEvents() mProcessingEvent = false; } -unsigned int Core::GetMaximumUpdateCount() const +uint32_t Core::GetMaximumUpdateCount() const { return MAXIMUM_UPDATE_COUNT; } @@ -330,6 +329,34 @@ void Core::SetStereoBase( float stereoBase ) mStage->SetStereoBase( stereoBase ); } +void Core::RegisterProcessor( Integration::Processor& processor ) +{ + mProcessors.PushBack(&processor); +} + +void Core::UnregisterProcessor( Integration::Processor& processor ) +{ + auto iter = std::find( mProcessors.Begin(), mProcessors.End(), &processor ); + if( iter != mProcessors.End() ) + { + mProcessors.Erase( iter ); + } +} + +void Core::RunProcessors() +{ + // Copy processor pointers to prevent changes to vector affecting loop iterator. + Dali::Vector processors( mProcessors ); + + for( auto processor : processors ) + { + if( processor ) + { + processor->Process(); + } + } +} + float Core::GetStereoBase() const { return mStage->GetStereoBase();