mSize( size ),
mSurfaceSize( Vector2::ZERO ),
mDpi( Vector2::ZERO ),
+ mBackgroundColor( DEFAULT_BACKGROUND_COLOR ),
mDepthTreeDirty( false ),
mEventProcessor( *this, ThreadLocalStorage::GetInternal()->GetGestureEventProcessor() )
{
mRenderTaskList.Reset();
}
- if( ThreadLocalStorage::Created() )
- {
- ThreadLocalStorage* tls = ThreadLocalStorage::GetInternal();
- tls->RemoveScene( this );
- }
+ // Discard this Scene from the Core
+ Discard();
}
void Scene::Initialize()
mLayerList = LayerList::New( updateManager );
// The scene owns the default layer
- mRootLayer = Layer::NewRoot( *mLayerList, updateManager );
+ mRootLayer = Layer::NewRoot( *mLayerList );
mRootLayer->SetName("RootLayer");
mRootLayer->SetScene( *this );
mSurface = &surface;
if ( mSurface )
{
- mSurfaceSize.width = static_cast<float>( mSurface->GetPositionSize().width );
- mSurfaceSize.height = static_cast<float>( mSurface->GetPositionSize().height );
+ RenderTaskPtr defaultRenderTask = mRenderTaskList->GetTask( 0u );
- mSize.width = mSurfaceSize.width;
- mSize.height = mSurfaceSize.height;
+ mFrameBuffer = Dali::Internal::FrameBuffer::New( surface, Dali::FrameBuffer::Attachment::NONE );
+ defaultRenderTask->SetFrameBuffer( mFrameBuffer );
- // Calculates the aspect ratio, near and far clipping planes, field of view and camera Z position.
- mDefaultCamera->SetPerspectiveProjection( mSurfaceSize );
+ SurfaceResized();
+ }
+}
- mRootLayer->SetSize( mSize.width, mSize.height );
+void Scene::SurfaceResized()
+{
+ if( mSurface )
+ {
+ const float fWidth = static_cast<float>( mSurface->GetPositionSize().width );
+ const float fHeight = static_cast<float>( mSurface->GetPositionSize().height );
- ThreadLocalStorage* tls = ThreadLocalStorage::GetInternal();
- SceneGraph::UpdateManager& updateManager = tls->GetUpdateManager();
- SetDefaultSurfaceRectMessage( updateManager, Rect<int32_t>( 0, 0, static_cast<int32_t>( mSurfaceSize.width ), static_cast<int32_t>( mSurfaceSize.height ) ) ); // truncated
+ if( ( fabsf( mSurfaceSize.width - fWidth ) > Math::MACHINE_EPSILON_1 ) || ( fabsf( mSurfaceSize.height - fHeight ) > Math::MACHINE_EPSILON_1 ) )
+ {
+ Rect<int32_t> newSize( 0, 0, static_cast<int32_t>( mSurface->GetPositionSize().width ), static_cast<int32_t>( mSurface->GetPositionSize().height ) );
- RenderTaskPtr defaultRenderTask = mRenderTaskList->GetTask( 0u );
+ mSurfaceSize.width = fWidth;
+ mSurfaceSize.height = fHeight;
- // if single render task to screen then set its viewport parameters
- if( 1 == mRenderTaskList->GetTaskCount() )
- {
- if( !defaultRenderTask->GetTargetFrameBuffer() )
+ mSize.width = mSurfaceSize.width;
+ mSize.height = mSurfaceSize.height;
+
+ // Calculates the aspect ratio, near and far clipping planes, field of view and camera Z position.
+ mDefaultCamera->SetPerspectiveProjection( mSurfaceSize );
+
+ mRootLayer->SetSize( mSize.width, mSize.height );
+
+ ThreadLocalStorage* tls = ThreadLocalStorage::GetInternal();
+ SceneGraph::UpdateManager& updateManager = tls->GetUpdateManager();
+ SetDefaultSurfaceRectMessage( updateManager, newSize ); // truncated
+
+ RenderTaskPtr defaultRenderTask = mRenderTaskList->GetTask( 0u );
+
+ // if single render task to screen then set its viewport parameters
+ if( 1 == mRenderTaskList->GetTaskCount() )
{
- defaultRenderTask->SetViewport( Viewport( 0, 0, static_cast<int32_t>( mSurfaceSize.width ), static_cast<int32_t>( mSurfaceSize.height ) ) ); // truncated
+ if( !defaultRenderTask->GetTargetFrameBuffer() )
+ {
+ defaultRenderTask->SetViewport( newSize ); // truncated
+ }
}
- }
- mFrameBuffer = Dali::Internal::FrameBuffer::New( surface, Dali::FrameBuffer::Attachment::NONE );
- defaultRenderTask->SetFrameBuffer( mFrameBuffer );
+ defaultRenderTask->GetFrameBuffer()->SetSize( static_cast<uint32_t>( newSize.width ), static_cast<uint32_t>( newSize.height ) );
+ }
}
}
return mSurface;
}
+void Scene::Discard()
+{
+ if( ThreadLocalStorage::Created() )
+ {
+ ThreadLocalStorage* tls = ThreadLocalStorage::GetInternal();
+ tls->RemoveScene( this );
+ }
+}
+
void Scene::RequestRebuildDepthTree()
{
mDepthTreeDirty = true;
}
}
-void Scene::SetBackgroundColor(Vector4 color)
+void Scene::SetBackgroundColor( const Vector4& color )
{
+ mBackgroundColor = color;
+
if( mSurface )
{
- mSurface->SetBackgroundColor( color );
+ mRenderTaskList->GetTask( 0u )->GetFrameBuffer()->SetBackgroundColor( color );
}
}
Vector4 Scene::GetBackgroundColor() const
{
- return mSurface ? mSurface->GetBackgroundColor() : DEFAULT_BACKGROUND_COLOR;
+ return mBackgroundColor;
}
void Scene::EmitKeyEventSignal(const KeyEvent& event)
mKeyEventSignal.Emit( event );
}
+bool Scene::EmitKeyEventGeneratedSignal(const KeyEvent& event)
+{
+ // Emit the KeyEventGenerated signal when KeyEvent is generated
+ return mKeyEventGeneratedSignal.Emit( event );
+}
+
void Scene::EmitEventProcessingFinishedSignal()
{
mEventProcessingFinishedSignal.Emit();
return mKeyEventSignal;
}
+Integration::Scene::KeyEventGeneratedSignalType& Scene::KeyEventGeneratedSignal()
+{
+ return mKeyEventGeneratedSignal;
+}
+
Integration::Scene::EventProcessingFinishedSignalType& Scene::EventProcessingFinishedSignal()
{
return mEventProcessingFinishedSignal;