[Tizen] Implement partial update
[platform/core/uifw/dali-core.git] / dali / internal / event / actors / layer-impl.cpp
index fb7675f..5d184b0 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2018 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2019 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.
@@ -26,7 +26,8 @@
 #include <dali/public-api/object/type-registry.h>
 #include <dali/internal/event/actors/layer-list.h>
 #include <dali/internal/event/common/property-helper.h>
-#include <dali/internal/event/common/stage-impl.h>
+#include <dali/internal/event/common/scene-impl.h>
+#include <dali/internal/event/common/event-thread-services.h>
 
 using Dali::Internal::SceneGraph::UpdateManager;
 
@@ -39,7 +40,7 @@ namespace
 typedef Layer::Behavior Behavior;
 
 DALI_ENUM_TO_STRING_TABLE_BEGIN( BEHAVIOR )
-DALI_ENUM_TO_STRING_WITH_SCOPE( Layer, LAYER_2D )
+DALI_ENUM_TO_STRING_WITH_SCOPE( Layer, LAYER_UI )
 DALI_ENUM_TO_STRING_WITH_SCOPE( Layer, LAYER_3D )
 DALI_ENUM_TO_STRING_TABLE_END( BEHAVIOR )
 
@@ -87,7 +88,7 @@ LayerPtr Layer::New()
   // create node, nodes are owned by UpdateManager
   SceneGraph::Layer* layerNode = SceneGraph::Layer::New();
   OwnerPointer< SceneGraph::Node > transferOwnership( layerNode );
-  AddNodeMessage( Stage::GetCurrent()->GetUpdateManager(), transferOwnership );
+  AddNodeMessage( EventThreadServices::Get().GetUpdateManager(), transferOwnership );
   LayerPtr layer( new Layer( Actor::LAYER, *layerNode ) );
 
   // Second-phase construction
@@ -96,12 +97,12 @@ LayerPtr Layer::New()
   return layer;
 }
 
-LayerPtr Layer::NewRoot( LayerList& layerList, UpdateManager& manager )
+LayerPtr Layer::NewRoot( LayerList& layerList )
 {
   // create node, nodes are owned by UpdateManager
   SceneGraph::Layer* rootLayer = SceneGraph::Layer::New();
   OwnerPointer< SceneGraph::Layer > transferOwnership( rootLayer );
-  InstallRootMessage( manager, transferOwnership );
+  InstallRootMessage( EventThreadServices::Get().GetUpdateManager(), transferOwnership );
 
   LayerPtr root( new Layer( Actor::ROOT_LAYER, *rootLayer ) );
 
@@ -124,7 +125,7 @@ Layer::Layer( Actor::DerivedType type, const SceneGraph::Layer& layer )
   mLayerList( NULL ),
   mClippingBox( 0, 0, 0, 0 ),
   mSortFunction( Layer::ZValue ),
-  mBehavior( Dali::Layer::LAYER_2D ),
+  mBehavior( Dali::Layer::LAYER_UI ),
   mIsClipping( false ),
   mDepthTestDisabled( true ),
   mTouchConsumed( false ),
@@ -138,6 +139,16 @@ void Layer::OnInitialize()
 
 Layer::~Layer()
 {
+  if ( mIsRoot )
+  {
+    // Guard to allow handle destruction after Core has been destroyed
+    if( EventThreadServices::IsCoreRunning() )
+    {
+      UninstallRootMessage( GetEventThreadServices().GetUpdateManager(), &GetSceneLayerOnStage() );
+
+      GetEventThreadServices().UnregisterObject( this );
+    }
+  }
 }
 
 unsigned int Layer::GetDepth() const
@@ -229,8 +240,8 @@ void Layer::SetBehavior( Dali::Layer::Behavior behavior )
 
   // Notify update side object.
   SetBehaviorMessage( GetEventThreadServices(), GetSceneLayerOnStage(), behavior );
-  // By default, disable depth test for LAYER_2D, and enable for LAYER_3D.
-  SetDepthTestDisabled( mBehavior == Dali::Layer::LAYER_2D );
+  // By default, disable depth test for LAYER_UI, and enable for LAYER_3D.
+  SetDepthTestDisabled( mBehavior == Dali::Layer::LAYER_UI );
 }
 
 void Layer::SetClipping(bool enabled)
@@ -257,10 +268,9 @@ void Layer::SetClippingBox(int x, int y, int width, int height)
     // Convert mClippingBox to GL based coordinates (from bottom-left)
     ClippingBox clippingBox( mClippingBox );
 
-    StagePtr stage = Stage::GetCurrent();
-    if( stage )
+    if( mScene )
     {
-      clippingBox.y = static_cast<int32_t>( stage->GetSize().height ) - clippingBox.y - clippingBox.height;
+      clippingBox.y = static_cast<int32_t>( mScene->GetSize().height ) - clippingBox.y - clippingBox.height;
 
       // layerNode is being used in a separate thread; queue a message to set the value
       SetClippingBoxMessage( GetEventThreadServices(), GetSceneLayerOnStage(), clippingBox );
@@ -323,7 +333,6 @@ void Layer::OnStageConnectionInternal()
     DALI_ASSERT_DEBUG( NULL == mLayerList );
 
     // Find the ordered layer-list
-    // This is different for Layers added via Integration::GetSystemOverlay()
     for ( Actor* parent = mParent; parent != NULL; parent = parent->GetParent() )
     {
       if( parent->IsLayer() )
@@ -374,7 +383,7 @@ void Layer::SetDefaultProperty( Property::Index index, const Property::Value& pr
       }
       case Dali::Layer::Property::BEHAVIOR:
       {
-        Behavior behavior(Dali::Layer::LAYER_2D);
+        Behavior behavior(Dali::Layer::LAYER_UI);
         if( Scripting::GetEnumeration< Behavior >( propertyValue.Get< std::string >().c_str(), BEHAVIOR_TABLE, BEHAVIOR_TABLE_COUNT, behavior ) )
         {
           SetBehavior( behavior );