Revert "[Tizen] Implement partial update"
[platform/core/uifw/dali-core.git] / dali / internal / update / manager / scene-graph-frame-callback.cpp
1 /*
2  * Copyright (c) 2018 Samsung Electronics Co., Ltd.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *
16  */
17
18 // CLASS HEADER
19 #include <dali/internal/update/manager/scene-graph-frame-callback.h>
20
21 // INTERNAL INCLUDES
22 #include <dali/devel-api/threading/mutex.h>
23 #include <dali/devel-api/update/frame-callback-interface.h>
24 #include <dali/devel-api/update/update-proxy.h>
25 #include <dali/internal/event/update/frame-callback-interface-impl.h>
26
27 namespace Dali
28 {
29
30 namespace Internal
31 {
32
33 namespace SceneGraph
34 {
35
36 FrameCallback* FrameCallback::New( FrameCallbackInterface& frameCallbackInterface )
37 {
38   return new FrameCallback( &frameCallbackInterface );
39 }
40
41 FrameCallback::~FrameCallback()
42 {
43   if( mUpdateProxy )
44   {
45     mUpdateProxy->GetRootNode().RemoveObserver( *this );
46   }
47
48   {
49     Mutex::ScopedLock lock( mMutex );
50     if( mFrameCallbackInterface )
51     {
52       FrameCallbackInterface::Impl::Get( *mFrameCallbackInterface ).DisconnectFromSceneGraphObject();
53     }
54   }
55 }
56
57 void FrameCallback::ConnectToSceneGraph( UpdateManager& updateManager, TransformManager& transformManager, Node& rootNode )
58 {
59   mUpdateProxy = std::unique_ptr< UpdateProxy >( new UpdateProxy( updateManager, transformManager, rootNode ) );
60   rootNode.AddObserver( *this );
61 }
62
63 bool FrameCallback::Update( BufferIndex bufferIndex, float elapsedSeconds, bool nodeHierarchyChanged )
64 {
65   bool continueCalling = false;
66   if( mUpdateProxy )
67   {
68     mUpdateProxy->SetCurrentBufferIndex( bufferIndex );
69
70     if( nodeHierarchyChanged )
71     {
72       mUpdateProxy->NodeHierarchyChanged();
73     }
74
75     Mutex::ScopedLock lock( mMutex );
76     if( mFrameCallbackInterface )
77     {
78       Dali::UpdateProxy updateProxy( *mUpdateProxy );
79       mFrameCallbackInterface->Update( updateProxy, elapsedSeconds );
80       continueCalling = true;
81     }
82   }
83   return continueCalling;
84 }
85
86 void FrameCallback::Invalidate()
87 {
88   Mutex::ScopedLock lock( mMutex );
89   if( mFrameCallbackInterface )
90   {
91     FrameCallbackInterface::Impl::Get( *mFrameCallbackInterface ).DisconnectFromSceneGraphObject();
92     mFrameCallbackInterface = nullptr;
93   }
94 }
95
96 void FrameCallback::PropertyOwnerDestroyed( PropertyOwner& owner )
97 {
98   Invalidate();
99 }
100
101 FrameCallback::FrameCallback( FrameCallbackInterface* frameCallbackInterface )
102 : mMutex(),
103   mFrameCallbackInterface( frameCallbackInterface )
104 {
105   if( frameCallbackInterface )
106   {
107     FrameCallbackInterface::Impl::Get( *mFrameCallbackInterface ).ConnectToSceneGraphObject( *this );
108   }
109 }
110
111 } // namespace SceneGraph
112
113 } // namespace Internal
114
115 } // namespace Dali