9b7ddcc436202f9e082a6d8d7da7807e1b1d0260
[platform/core/uifw/dali-core.git] / dali / internal / update / common / scene-graph-scene.cpp
1 /*
2  * Copyright (c) 2020 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 // CLASS HEADER
18 #include <dali/internal/update/common/scene-graph-scene.h>
19
20 // INTERNAL INCLUDES
21 #include <dali/internal/update/render-tasks/scene-graph-render-task-list.h>
22 #include <dali/internal/render/gl-resources/context.h>
23
24 namespace Dali
25 {
26 namespace Internal
27 {
28 namespace SceneGraph
29 {
30
31 Scene::Scene()
32 : mContext( nullptr ),
33   mFrameRenderedCallbacks(),
34   mFramePresentedCallbacks()
35 {
36 }
37
38 Scene::~Scene()
39 {
40   mFrameRenderedCallbacks.clear();
41   mFramePresentedCallbacks.clear();
42 }
43
44 void Scene::Initialize( Context& context )
45 {
46   mContext = &context;
47 }
48
49 Context* Scene::GetContext()
50 {
51   return mContext;
52 }
53
54 RenderInstructionContainer& Scene::GetRenderInstructions()
55 {
56   return mInstructions;
57 }
58
59 void Scene::AddFrameRenderedCallback( CallbackBase* callback, int32_t frameId )
60 {
61   mFrameRenderedCallbacks.push_back( std::make_pair( std::unique_ptr< CallbackBase >( callback ), frameId ) );
62 }
63
64 void Scene::AddFramePresentedCallback( CallbackBase* callback, int32_t frameId )
65 {
66   mFramePresentedCallbacks.push_back( std::make_pair( std::unique_ptr< CallbackBase >( callback ), frameId ) );
67 }
68
69 void Scene::GetFrameRenderedCallback( Dali::Integration::Scene::FrameCallbackContainer& callbacks )
70 {
71   // Transfer owership of the callbacks
72   for( auto&& iter : mFrameRenderedCallbacks )
73   {
74     callbacks.push_back( std::make_pair( std::move( iter.first ), iter.second ) );
75   }
76
77   mFrameRenderedCallbacks.clear();
78 }
79
80 void Scene::GetFramePresentedCallback( Dali::Integration::Scene::FrameCallbackContainer& callbacks )
81 {
82   // Transfer owership of the callbacks
83   for( auto&& iter : mFramePresentedCallbacks )
84   {
85     callbacks.push_back( std::make_pair( std::move( iter.first ), iter.second ) );
86   }
87
88   mFramePresentedCallbacks.clear();
89 }
90
91 } //SceneGraph
92
93 } //Internal
94
95 } //Dali