2 * Copyright (c) 2018 Samsung Electronics Co., Ltd.
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
19 #include <dali/internal/update/manager/frame-callback-processor.h>
25 #include <dali/devel-api/update/frame-callback-interface.h>
26 #include <dali/devel-api/update/update-proxy.h>
37 FrameCallbackProcessor::FrameCallbackProcessor( UpdateManager& updateManager, TransformManager& transformManager )
39 mUpdateManager( updateManager ),
40 mTransformManager( transformManager ),
41 mNodeHierarchyChanged( true )
45 FrameCallbackProcessor::~FrameCallbackProcessor()
49 void FrameCallbackProcessor::AddFrameCallback( OwnerPointer< FrameCallback >& frameCallback, const Node* rootNode )
51 Node& node = const_cast< Node& >( *rootNode ); // Was sent as const from event thread, we need to be able to use non-const version here.
53 frameCallback->ConnectToSceneGraph( mUpdateManager, mTransformManager, node );
55 mFrameCallbacks.emplace_back( frameCallback );
58 void FrameCallbackProcessor::RemoveFrameCallback( FrameCallbackInterface* frameCallback )
60 // Find and remove all frame-callbacks that use the given frame-callback-interface
61 auto iter = std::remove( mFrameCallbacks.begin(), mFrameCallbacks.end(), frameCallback );
62 mFrameCallbacks.erase( iter, mFrameCallbacks.end() );
65 void FrameCallbackProcessor::Update( BufferIndex bufferIndex, float elapsedSeconds )
67 // If any of the FrameCallback::Update calls returns false, then they are no longer required & can be removed.
68 auto iter = std::remove_if(
69 mFrameCallbacks.begin(), mFrameCallbacks.end(),
70 [ & ]( OwnerPointer< FrameCallback >& frameCallback )
72 return ! frameCallback->Update( bufferIndex, elapsedSeconds, mNodeHierarchyChanged );
75 mFrameCallbacks.erase( iter, mFrameCallbacks.end() );
77 mNodeHierarchyChanged = false;
80 } // namespace SceneGraph
82 } // namespace Internal