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( TransformManager& transformManager )
39 mTransformManager( transformManager ),
40 mNodeHierarchyChanged( true )
44 FrameCallbackProcessor::~FrameCallbackProcessor()
48 void FrameCallbackProcessor::AddFrameCallback( OwnerPointer< FrameCallback >& frameCallback, const Node* rootNode )
50 Node& node = const_cast< Node& >( *rootNode ); // Was sent as const from event thread, we need to be able to use non-const version here.
52 frameCallback->ConnectToSceneGraph( mTransformManager, node );
54 mFrameCallbacks.emplace_back( frameCallback );
57 void FrameCallbackProcessor::RemoveFrameCallback( FrameCallbackInterface* frameCallback )
59 // Find and remove all frame-callbacks that use the given frame-callback-interface
60 auto iter = std::remove( mFrameCallbacks.begin(), mFrameCallbacks.end(), frameCallback );
61 mFrameCallbacks.erase( iter, mFrameCallbacks.end() );
64 void FrameCallbackProcessor::Update( BufferIndex bufferIndex, float elapsedSeconds )
66 // If any of the FrameCallback::Update calls returns false, then they are no longer required & can be removed.
67 auto iter = std::remove_if(
68 mFrameCallbacks.begin(), mFrameCallbacks.end(),
69 [ & ]( OwnerPointer< FrameCallback >& frameCallback )
71 return ! frameCallback->Update( bufferIndex, elapsedSeconds, mNodeHierarchyChanged );
74 mFrameCallbacks.erase( iter, mFrameCallbacks.end() );
76 mNodeHierarchyChanged = false;
79 } // namespace SceneGraph
81 } // namespace Internal