projects
/
platform
/
core
/
uifw
/
dali-core.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Revert "[Tizen] Add screen and client rotation itself function"
[platform/core/uifw/dali-core.git]
/
dali
/
internal
/
event
/
common
/
scene-impl.cpp
diff --git
a/dali/internal/event/common/scene-impl.cpp
b/dali/internal/event/common/scene-impl.cpp
index
0a065e9
..
c14470d
100644
(file)
--- a/
dali/internal/event/common/scene-impl.cpp
+++ b/
dali/internal/event/common/scene-impl.cpp
@@
-48,21
+48,20
@@
const Vector4 DEFAULT_BACKGROUND_COLOR(0.0f, 0.0f, 0.0f, 1.0f); // Default backg
} //Unnamed namespace
} //Unnamed namespace
-ScenePtr Scene::New(
const Size& siz
e )
+ScenePtr Scene::New(
Integration::RenderSurface& surfac
e )
{
{
- ScenePtr scene = new Scene
( size )
;
+ ScenePtr scene = new Scene;
// Second-phase construction
// Second-phase construction
- scene->Initialize();
+ scene->Initialize(
surface
);
return scene;
}
return scene;
}
-Scene::Scene(
const Size& size
)
+Scene::Scene()
: mSurface( nullptr ),
: mSurface( nullptr ),
- mSize( size ),
- mSurfaceSize( Vector2::ZERO ),
- mDpi( Vector2::ZERO ),
+ mSize(), // Don't set the proper value here, this will be set when the surface is set later
+ mDpi(),
mBackgroundColor( DEFAULT_BACKGROUND_COLOR ),
mDepthTreeDirty( false ),
mEventProcessor( *this, ThreadLocalStorage::GetInternal()->GetGestureEventProcessor() )
mBackgroundColor( DEFAULT_BACKGROUND_COLOR ),
mDepthTreeDirty( false ),
mEventProcessor( *this, ThreadLocalStorage::GetInternal()->GetGestureEventProcessor() )
@@
-90,14
+89,16
@@
Scene::~Scene()
mRenderTaskList.Reset();
}
mRenderTaskList.Reset();
}
- if
( ThreadLocalStorage::Created()
)
+ if
( mFrameBuffer
)
{
{
- ThreadLocalStorage* tls = ThreadLocalStorage::GetInternal();
- tls->RemoveScene( this );
+ mFrameBuffer.Reset();
}
}
+
+ // No need to discard this Scene from Core, as Core stores an intrusive_ptr to this scene
+ // When this destructor is called, the scene has either already been removed from Core or Core has already been destroyed
}
}
-void Scene::Initialize()
+void Scene::Initialize(
Integration::RenderSurface& surface
)
{
ThreadLocalStorage* tls = ThreadLocalStorage::GetInternal();
{
ThreadLocalStorage* tls = ThreadLocalStorage::GetInternal();
@@
-111,7
+112,7
@@
void Scene::Initialize()
mLayerList = LayerList::New( updateManager );
// The scene owns the default layer
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 );
mRootLayer->SetName("RootLayer");
mRootLayer->SetScene( *this );
@@
-123,7
+124,9
@@
void Scene::Initialize()
// Create the default camera actor first; this is needed by the RenderTaskList
// The default camera attributes and position is such that children of the default layer,
// can be positioned at (0,0) and be at the top-left of the viewport.
// Create the default camera actor first; this is needed by the RenderTaskList
// The default camera attributes and position is such that children of the default layer,
// can be positioned at (0,0) and be at the top-left of the viewport.
- mDefaultCamera = CameraActor::New( mSize );
+ const PositionSize positionSize = surface.GetPositionSize();
+ const Vector2 surfaceSize( static_cast< float >( positionSize.width ), static_cast< float >( positionSize.height ) );
+ mDefaultCamera = CameraActor::New( surfaceSize );
mDefaultCamera->SetParentOrigin(ParentOrigin::CENTER);
Add(*(mDefaultCamera.Get()));
mDefaultCamera->SetParentOrigin(ParentOrigin::CENTER);
Add(*(mDefaultCamera.Get()));
@@
-132,6
+135,9
@@
void Scene::Initialize()
// Create the default render-task
mRenderTaskList->CreateTask( mRootLayer.Get(), mDefaultCamera.Get() );
// Create the default render-task
mRenderTaskList->CreateTask( mRootLayer.Get(), mDefaultCamera.Get() );
+
+ // Set the surface
+ SetSurface( surface );
}
void Scene::Add(Actor& actor)
}
void Scene::Add(Actor& actor)
@@
-196,9
+202,10
@@
Actor& Scene::GetDefaultRootActor()
void Scene::SetSurface( Integration::RenderSurface& surface )
{
void Scene::SetSurface( Integration::RenderSurface& surface )
{
- mSurface = &surface;
- if ( mSurface )
+ if( mSurface != &surface )
{
{
+ mSurface = &surface;
+
RenderTaskPtr defaultRenderTask = mRenderTaskList->GetTask( 0u );
mFrameBuffer = Dali::Internal::FrameBuffer::New( surface, Dali::FrameBuffer::Attachment::NONE );
RenderTaskPtr defaultRenderTask = mRenderTaskList->GetTask( 0u );
mFrameBuffer = Dali::Internal::FrameBuffer::New( surface, Dali::FrameBuffer::Attachment::NONE );
@@
-212,49
+219,58
@@
void Scene::SurfaceResized()
{
if( mSurface )
{
{
if( mSurface )
{
- const float fWidth = static_cast<float>( mSurface->GetPositionSize().width );
- const float fHeight = static_cast<float>( mSurface->GetPositionSize().height );
+ const PositionSize surfacePositionSize = mSurface->GetPositionSize();
+ const float fWidth = static_cast< float >( surfacePositionSize.width );
+ const float fHeight = static_cast< float >( surfacePositionSize.height );
- if( ( fabsf( mS
urfaceSize.width - fWidth ) > Math::MACHINE_EPSILON_1 ) || ( fabsf( mSurface
Size.height - fHeight ) > Math::MACHINE_EPSILON_1 ) )
+ if( ( fabsf( mS
ize.width - fWidth ) > Math::MACHINE_EPSILON_1 ) || ( fabsf( m
Size.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 ) );
+ Rect<
int32_t > newSize( 0, 0, static_cast< int32_t >( surfacePositionSize.width ), static_cast< int32_t >( surfacePositionSize.height ) ); // truncated
- mSurfaceSize.width = fWidth;
- mSurfaceSize.height = fHeight;
-
- mSize.width = mSurfaceSize.width;
- mSize.height = mSurfaceSize.height;
+ mSize.width = fWidth;
+ mSize.height = fHeight;
// Calculates the aspect ratio, near and far clipping planes, field of view and camera Z position.
// Calculates the aspect ratio, near and far clipping planes, field of view and camera Z position.
- mDefaultCamera->SetPerspectiveProjection( mS
urfaceS
ize );
+ mDefaultCamera->SetPerspectiveProjection( mSize );
mRootLayer->SetSize( mSize.width, mSize.height );
ThreadLocalStorage* tls = ThreadLocalStorage::GetInternal();
SceneGraph::UpdateManager& updateManager = tls->GetUpdateManager();
mRootLayer->SetSize( mSize.width, mSize.height );
ThreadLocalStorage* tls = ThreadLocalStorage::GetInternal();
SceneGraph::UpdateManager& updateManager = tls->GetUpdateManager();
- SetDefaultSurfaceRectMessage( updateManager, newSize );
// truncated
+ SetDefaultSurfaceRectMessage( updateManager, newSize );
+ // set default render-task viewport parameters
RenderTaskPtr defaultRenderTask = mRenderTaskList->GetTask( 0u );
RenderTaskPtr defaultRenderTask = mRenderTaskList->GetTask( 0u );
-
- // if single render task to screen then set its viewport parameters
- if( 1 == mRenderTaskList->GetTaskCount() )
- {
- if( !defaultRenderTask->GetTargetFrameBuffer() )
- {
- defaultRenderTask->SetViewport( newSize ); // truncated
- }
- }
-
+ defaultRenderTask->SetViewport( newSize );
defaultRenderTask->GetFrameBuffer()->SetSize( static_cast<uint32_t>( newSize.width ), static_cast<uint32_t>( newSize.height ) );
}
}
}
defaultRenderTask->GetFrameBuffer()->SetSize( static_cast<uint32_t>( newSize.width ), static_cast<uint32_t>( newSize.height ) );
}
}
}
+void Scene::SurfaceDeleted()
+{
+ mSurface = nullptr;
+ if ( mFrameBuffer )
+ {
+ // The frame buffer doesn't have a valid render surface any more.
+ mFrameBuffer->MarkSurfaceAsInvalid();
+ }
+}
+
Integration::RenderSurface* Scene::GetSurface() const
{
return mSurface;
}
Integration::RenderSurface* Scene::GetSurface() const
{
return mSurface;
}
+void Scene::Discard()
+{
+ if( ThreadLocalStorage::Created() )
+ {
+ ThreadLocalStorage* tls = ThreadLocalStorage::GetInternal();
+ tls->RemoveScene( this );
+ }
+}
+
void Scene::RequestRebuildDepthTree()
{
mDepthTreeDirty = true;
void Scene::RequestRebuildDepthTree()
{
mDepthTreeDirty = true;
@@
-298,7
+314,11
@@
Vector4 Scene::GetBackgroundColor() const
void Scene::EmitKeyEventSignal(const KeyEvent& event)
{
void Scene::EmitKeyEventSignal(const KeyEvent& event)
{
- mKeyEventSignal.Emit( event );
+ if ( !mKeyEventSignal.Empty() )
+ {
+ Dali::Integration::Scene handle( this );
+ mKeyEventSignal.Emit( event );
+ }
}
bool Scene::EmitKeyEventGeneratedSignal(const KeyEvent& event)
}
bool Scene::EmitKeyEventGeneratedSignal(const KeyEvent& event)
@@
-309,18
+329,33
@@
bool Scene::EmitKeyEventGeneratedSignal(const KeyEvent& event)
void Scene::EmitEventProcessingFinishedSignal()
{
void Scene::EmitEventProcessingFinishedSignal()
{
- mEventProcessingFinishedSignal.Emit();
+ if ( !mEventProcessingFinishedSignal.Empty() )
+ {
+ Dali::Integration::Scene handle( this );
+ mEventProcessingFinishedSignal.Emit();
+ }
}
void Scene::EmitTouchedSignal( const TouchEvent& touchEvent, const Dali::TouchData& touch )
{
}
void Scene::EmitTouchedSignal( const TouchEvent& touchEvent, const Dali::TouchData& touch )
{
- mTouchedSignal.Emit( touchEvent );
- mTouchSignal.Emit( touch );
+ Dali::Integration::Scene handle( this );
+ if ( !mTouchedSignal.Empty() )
+ {
+ mTouchedSignal.Emit( touchEvent );
+ }
+ if ( !mTouchSignal.Empty() )
+ {
+ mTouchSignal.Emit( touch );
+ }
}
void Scene::EmitWheelEventSignal(const WheelEvent& event)
{
}
void Scene::EmitWheelEventSignal(const WheelEvent& event)
{
- mWheelEventSignal.Emit( event );
+ if ( !mWheelEventSignal.Empty() )
+ {
+ Dali::Integration::Scene handle( this );
+ mWheelEventSignal.Emit( event );
+ }
}
Integration::Scene::KeyEventSignalType& Scene::KeyEventSignal()
}
Integration::Scene::KeyEventSignalType& Scene::KeyEventSignal()