X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=dali%2Finternal%2Fevent%2Fcommon%2Fstage-impl.cpp;h=b54e34f36199a850dfb5c0ddb501552bff943b8f;hb=cc17e51c101f23c848fa2348f6097473fff41f33;hp=c036a5d77c28c6b0b9fe712dde12e0fb8bc80e59;hpb=bdb01cd9c3193f11be1c3a138d0ed4ee44bcdbc0;p=platform%2Fcore%2Fuifw%2Fdali-core.git diff --git a/dali/internal/event/common/stage-impl.cpp b/dali/internal/event/common/stage-impl.cpp index c036a5d..b54e34f 100644 --- a/dali/internal/event/common/stage-impl.cpp +++ b/dali/internal/event/common/stage-impl.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016 Samsung Electronics Co., Ltd. + * Copyright (c) 2017 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. @@ -39,9 +39,17 @@ #include #include #include +#include using Dali::Internal::SceneGraph::Node; +namespace +{ +#if defined(DEBUG_ENABLED) +Debug::Filter* gLogFilter = Debug::Filter::New(Debug::NoLogging, false, "LOG_DEPTH_TIMER" ); +#endif +} + namespace Dali { @@ -82,13 +90,15 @@ SignalConnectorType signalConnector9( mType, SIGNAL_TOUCH, & StagePtr Stage::New( AnimationPlaylist& playlist, PropertyNotificationManager& propertyNotificationManager, SceneGraph::UpdateManager& updateManager, - NotificationManager& notificationManager ) + NotificationManager& notificationManager, + Integration::RenderController& renderController ) { - return StagePtr( new Stage( playlist, propertyNotificationManager, updateManager, notificationManager ) ); + return StagePtr( new Stage( playlist, propertyNotificationManager, updateManager, notificationManager, renderController ) ); } -void Stage::Initialize() +void Stage::Initialize( bool renderToFbo ) { + mRenderToFbo = renderToFbo; mObjectRegistry = ObjectRegistry::New(); // Create the ordered list of layers @@ -190,44 +200,56 @@ void Stage::Remove( Actor& actor ) mRootLayer->Remove( actor ); } -void Stage::SurfaceResized(float width, float height) +void Stage::SurfaceResized( float width, float height ) { - mSurfaceSize.width = width; - mSurfaceSize.height = height; + if( ( fabs( width - mSurfaceSize.width ) > Math::MACHINE_EPSILON_1000 ) || ( fabs( height - mSurfaceSize.height ) > Math::MACHINE_EPSILON_1000 ) ) + { + mSurfaceSize.width = width; + mSurfaceSize.height = height; - // Internally we want to report the actual size of the stage. - mSize.width = width; - mSize.height = height - mTopMargin; + // Internally we want to report the actual size of the stage. + mSize.width = width; + mSize.height = height - mTopMargin; - // Calculates the aspect ratio, near and far clipping planes, field of view and camera Z position. - mDefaultCamera->SetPerspectiveProjection( mSurfaceSize ); + // Calculates the aspect ratio, near and far clipping planes, field of view and camera Z position. + mDefaultCamera->SetPerspectiveProjection( mSurfaceSize ); - // Adjust the camera height to allow for top-margin - SetDefaultCameraPosition(); + // Adjust the camera height to allow for top-margin + SetDefaultCameraPosition(); - mRootLayer->SetSize( mSize.width, mSize.height ); + mRootLayer->SetSize( mSize.width, mSize.height ); - // Repeat for SystemOverlay actors - if( mSystemOverlay ) - { - // Note that the SystemOverlay has a separate camera, configured for the full surface-size. - // This will remain unaffected by changes in SetDefaultCameraPosition() - mSystemOverlay->GetImpl()->SetSize( width, height ); - } + // Repeat for SystemOverlay actors + if( mSystemOverlay ) + { + // Note that the SystemOverlay has a separate camera, configured for the full surface-size. + // This will remain unaffected by changes in SetDefaultCameraPosition() + mSystemOverlay->GetImpl()->SetSize( width, height ); + } - SetDefaultSurfaceRectMessage( mUpdateManager, Rect( 0, 0, width, height ) ); + SetDefaultSurfaceRectMessage( mUpdateManager, Rect( 0, 0, width, height ) ); - // if single render task to screen then set its viewport parameters - if( 1 == mRenderTaskList->GetTaskCount() ) - { - Dali::RenderTask mDefaultRenderTask = mRenderTaskList->GetTask(0); + // if single render task to screen then set its viewport parameters + if( 1 == mRenderTaskList->GetTaskCount() ) + { + Dali::RenderTask defaultRenderTask = mRenderTaskList->GetTask( 0u ); + + if(!defaultRenderTask.GetTargetFrameBuffer()) + { + defaultRenderTask.SetViewport( Viewport(0, 0, width, height) ); + } + } - if(!mDefaultRenderTask.GetTargetFrameBuffer()) + if( mRenderToFbo ) { - mDefaultRenderTask.SetViewport( Viewport(0, 0, width, height) ); + Dali::FrameBuffer frameBuffer = Dali::FrameBuffer::New( width, height, Dali::FrameBuffer::Attachment::NONE ); + Dali::Texture texture = Dali::Texture::New( Dali::TextureType::TEXTURE_2D, Dali::Pixel::RGB888, width, height ); + frameBuffer.AttachColorTexture( texture ); + + Dali::RenderTask defaultRenderTask = mRenderTaskList->GetTask( 0u ); + defaultRenderTask.SetFrameBuffer( frameBuffer ); } } - } Vector2 Stage::GetSize() const @@ -664,20 +686,46 @@ void Stage::NotifyContextRegained() mContextRegainedSignal.Emit(); } + +void Stage::RequestRebuildDepthTree() +{ + DALI_LOG_INFO(gLogFilter, Debug::General, "RequestRebuildDepthTree()\n"); + mDepthTreeDirty = true; +} + +void Stage::RebuildDepthTree() +{ + // If the depth tree needs rebuilding, do it in this frame only. + if( mDepthTreeDirty ) + { + DALI_LOG_INFO(gLogFilter, Debug::Concise, "RebuildDepthTree() dirty:T\n"); + + ActorPtr actor( mRootLayer.Get() ); + actor->RebuildDepthTree(); + mDepthTreeDirty = false; + } +} + + Stage::Stage( AnimationPlaylist& playlist, PropertyNotificationManager& propertyNotificationManager, SceneGraph::UpdateManager& updateManager, - NotificationManager& notificationManager ) + NotificationManager& notificationManager, + Integration::RenderController& renderController ) : mAnimationPlaylist( playlist ), - mPropertyNotificationManager(propertyNotificationManager), - mUpdateManager(updateManager), - mNotificationManager(notificationManager), - mSize(Vector2::ZERO), - mBackgroundColor(Dali::Stage::DEFAULT_BACKGROUND_COLOR), + mPropertyNotificationManager( propertyNotificationManager ), + mUpdateManager( updateManager ), + mNotificationManager( notificationManager ), + mRenderController( renderController ), + mSize( Vector2::ZERO ), + mBackgroundColor( Dali::Stage::DEFAULT_BACKGROUND_COLOR ), mViewMode( MONO ), mStereoBase( DEFAULT_STEREO_BASE ), mTopMargin( 0 ), - mSystemOverlay(NULL) + mSystemOverlay( NULL ), + mDepthTreeDirty( false ), + mForceNextUpdate( false ), + mRenderToFbo( false ) { } @@ -686,6 +734,11 @@ SceneGraph::UpdateManager& Stage::GetUpdateManager() return mUpdateManager; } +Integration::RenderController& Stage::GetRenderController() +{ + return mRenderController; +} + unsigned int* Stage::ReserveMessageSlot( std::size_t size, bool updateScene ) { return mUpdateManager.ReserveMessageSlot( size, updateScene ); @@ -696,6 +749,18 @@ BufferIndex Stage::GetEventBufferIndex() const return mUpdateManager.GetEventBufferIndex(); } +void Stage::ForceNextUpdate() +{ + mForceNextUpdate = true; +} + +bool Stage::IsNextUpdateForced() +{ + bool nextUpdateForced = mForceNextUpdate; + mForceNextUpdate = false; + return nextUpdateForced; +} + Stage::~Stage() { delete mSystemOverlay;