605c76ddcc897892933abf73e9f8321e9881c926
[platform/core/uifw/dali-adaptor.git] / dali / internal / system / common / thread-controller.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
18 // CLASS HEADER
19 #include <dali/internal/system/common/thread-controller.h>
20
21 // INTERNAL INCLUDES
22 #include <dali/internal/system/common/environment-options.h>
23 #include <dali/internal/adaptor/common/thread-controller-interface.h>
24 #include <dali/internal/adaptor/common/combined-update-render-controller.h>
25
26 namespace Dali
27 {
28
29 namespace Internal
30 {
31
32 namespace Adaptor
33 {
34
35 ThreadController::ThreadController( AdaptorInternalServices& adaptorInterfaces, const EnvironmentOptions& environmentOptions )
36 : mThreadControllerInterface( NULL )
37 {
38   switch( environmentOptions.GetThreadingMode() )
39   {
40     case ThreadingMode::COMBINED_UPDATE_RENDER:
41     {
42       mThreadControllerInterface = new CombinedUpdateRenderController( adaptorInterfaces, environmentOptions );
43       break;
44     }
45   }
46 }
47
48 ThreadController::~ThreadController()
49 {
50   delete mThreadControllerInterface;
51 }
52
53 void ThreadController::Initialize()
54 {
55   mThreadControllerInterface->Initialize();
56 }
57
58 void ThreadController::Start()
59 {
60   mThreadControllerInterface->Start();
61 }
62
63 void ThreadController::Pause()
64 {
65   mThreadControllerInterface->Pause();
66 }
67
68 void ThreadController::Resume()
69 {
70   mThreadControllerInterface->Resume();
71 }
72
73 void ThreadController::Stop()
74 {
75   mThreadControllerInterface->Stop();
76 }
77
78 void ThreadController::RequestUpdate()
79 {
80   mThreadControllerInterface->RequestUpdate();
81 }
82
83 void ThreadController::RequestUpdateOnce(   UpdateMode updateMode )
84 {
85   mThreadControllerInterface->RequestUpdateOnce( updateMode );
86 }
87
88 void ThreadController::ReplaceSurface( Dali::RenderSurfaceInterface* newSurface )
89 {
90   mThreadControllerInterface->ReplaceSurface( newSurface );
91 }
92
93 void ThreadController::ResizeSurface()
94 {
95   mThreadControllerInterface->ResizeSurface();
96 }
97
98 void ThreadController::WaitForGraphicsInitialization()
99 {
100   mThreadControllerInterface->WaitForGraphicsInitialization();
101 }
102
103 void ThreadController::SetRenderRefreshRate(unsigned int numberOfVSyncsPerRender )
104 {
105   mThreadControllerInterface->SetRenderRefreshRate( numberOfVSyncsPerRender );
106 }
107
108 void ThreadController::SetPreRenderCallback( CallbackBase* callback )
109 {
110   mThreadControllerInterface->SetPreRenderCallback( callback );
111 }
112
113 void ThreadController::AddSurface( Dali::RenderSurfaceInterface* newSurface )
114 {
115   mThreadControllerInterface->AddSurface( newSurface );
116 }
117
118 bool ThreadController::IsRenderingWindows() const
119 {
120   return mThreadControllerInterface->IsRenderingWindows();
121 }
122
123 } // namespace Adaptor
124
125 } // namespace Internal
126
127 } // namespace Dali