Moved thread control functionality into a separate folder & added threading mode...
[platform/core/uifw/dali-adaptor.git] / adaptors / base / thread-controller.cpp
1 /*
2  * Copyright (c) 2015 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 "thread-controller.h"
20
21 // INTERNAL INCLUDES
22 #include <base/environment-options.h>
23 #include <base/thread-controller-interface.h>
24 #include <base/separate-update-render/separate-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::SEPARATE_UPDATE_RENDER:
41     case ThreadingMode::COMBINED_UPDATE_RENDER:
42     case ThreadingMode::SINGLE_THREADED:
43     {
44       mThreadControllerInterface = new SeparateUpdateRenderController( adaptorInterfaces, environmentOptions );
45     }
46   }
47 }
48
49 ThreadController::~ThreadController()
50 {
51   delete mThreadControllerInterface;
52 }
53
54 void ThreadController::Initialize()
55 {
56   mThreadControllerInterface->Initialize();
57 }
58
59 void ThreadController::Start()
60 {
61   mThreadControllerInterface->Start();
62 }
63
64 void ThreadController::Pause()
65 {
66   mThreadControllerInterface->Pause();
67 }
68
69 void ThreadController::Resume()
70 {
71   mThreadControllerInterface->Resume();
72 }
73
74 void ThreadController::Stop()
75 {
76   mThreadControllerInterface->Stop();
77 }
78
79 void ThreadController::RequestUpdate()
80 {
81   mThreadControllerInterface->RequestUpdate();
82 }
83
84 void ThreadController::RequestUpdateOnce()
85 {
86   mThreadControllerInterface->RequestUpdateOnce();
87 }
88
89 void ThreadController::ReplaceSurface( RenderSurface* newSurface )
90 {
91   mThreadControllerInterface->ReplaceSurface( newSurface );
92 }
93
94 void ThreadController::SetRenderRefreshRate(unsigned int numberOfVSyncsPerRender )
95 {
96   mThreadControllerInterface->SetRenderRefreshRate( numberOfVSyncsPerRender );
97 }
98
99 } // namespace Adaptor
100
101 } // namespace Internal
102
103 } // namespace Dali