Merge "Klockwork: remove unreachable code, check iterators" into tizen
[platform/core/uifw/dali-core.git] / dali / integration-api / core.cpp
1 /*
2  * Copyright (c) 2014 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/integration-api/core.h>
20
21 // EXTERNAL INCLUDES
22 #include <iostream>
23 #include <stdarg.h>
24
25 // INTERNAL INCLUDES
26 #include <dali/public-api/common/dali-common.h>
27 #include <dali/integration-api/events/event.h>
28 #include <dali/integration-api/gl-sync-abstraction.h>
29 #include <dali/internal/common/core-impl.h>
30
31 namespace Dali
32 {
33
34 namespace Integration
35 {
36
37 namespace KeepUpdating
38 {
39
40 const unsigned int NOT_REQUESTED = 0x00; ///< Zero means that no further updates are required
41
42 // Bit-field values
43 const unsigned int STAGE_KEEP_RENDERING   = 0x01;  ///< Stage::KeepRendering() is being used
44 const unsigned int INCOMING_MESSAGES      = 0x02;  ///< Event-thread is sending messages to update-thread
45 const unsigned int ANIMATIONS_RUNNING     = 0x04;  ///< Animations are ongoing
46 const unsigned int DYNAMICS_CHANGED       = 0x08;  ///< A dynamics simulation is running
47 const unsigned int LOADING_RESOURCES      = 0x10;  ///< Resources are being loaded
48 const unsigned int MONITORING_PERFORMANCE = 0x20;  ///< The --enable-performance-monitor option is being used
49 const unsigned int RENDER_TASK_SYNC       = 0x40;  ///< The refresh once render task is waiting for render sync
50
51 } // namespace KeepUpdating
52
53 Core* Core::New(RenderController& renderController, PlatformAbstraction& platformAbstraction,
54                 GlAbstraction& glAbstraction, GlSyncAbstraction& glSyncAbstraction, GestureManager& gestureManager, ResourcePolicy::DataRetention policy )
55 {
56   Core* instance = new Core;
57   instance->mImpl = new Internal::Core( renderController, platformAbstraction, glAbstraction, glSyncAbstraction, gestureManager, policy );
58
59   return instance;
60 }
61
62 Core::~Core()
63 {
64   delete mImpl;
65 }
66
67 ContextNotifierInterface* Core::GetContextNotifier()
68 {
69   return mImpl->GetContextNotifier();
70 }
71
72 // @todo Rename to ResetGlContext
73 void Core::ContextCreated()
74 {
75   mImpl->ContextCreated();
76 }
77
78 // @todo Replace with StopRendering that prevents RenderManager from rendering
79 // until we get ResetGLContext again, change ContextCreated to reset gpu buffer cache,
80 // gl texture id's
81 void Core::ContextDestroyed()
82 {
83   mImpl->ContextDestroyed();
84 }
85
86 void Core::RecoverFromContextLoss()
87 {
88   mImpl->RecoverFromContextLoss();
89 }
90
91 void Core::SurfaceResized(unsigned int width, unsigned int height)
92 {
93   mImpl->SurfaceResized(width, height);
94 }
95
96 void Core::SetDpi(unsigned int dpiHorizontal, unsigned int dpiVertical)
97 {
98   mImpl->SetDpi(dpiHorizontal, dpiVertical);
99 }
100
101 void Core::Suspend()
102 {
103   mImpl->Suspend();
104 }
105
106 void Core::Resume()
107 {
108   mImpl->Resume();
109 }
110
111 void Core::QueueEvent(const Event& event)
112 {
113   mImpl->QueueEvent(event);
114 }
115
116 void Core::ProcessEvents()
117 {
118   mImpl->ProcessEvents();
119 }
120
121 void Core::UpdateTouchData(const TouchData& touch)
122 {
123   mImpl->UpdateTouchData(touch);
124 }
125
126 unsigned int Core::GetMaximumUpdateCount() const
127 {
128   return mImpl->GetMaximumUpdateCount();
129 }
130
131 void Core::Update( float elapsedSeconds, unsigned int lastVSyncTimeMilliseconds, unsigned int nextVSyncTimeMilliseconds, UpdateStatus& status )
132 {
133   mImpl->Update( elapsedSeconds, lastVSyncTimeMilliseconds, nextVSyncTimeMilliseconds, status );
134 }
135
136 void Core::Render( RenderStatus& status )
137 {
138   mImpl->Render( status );
139 }
140
141 SystemOverlay& Core::GetSystemOverlay()
142 {
143   return mImpl->GetSystemOverlay();
144 }
145
146 void Core::SetViewMode( ViewMode viewMode )
147 {
148   mImpl->SetViewMode( viewMode );
149 }
150
151 ViewMode Core::GetViewMode() const
152 {
153   return mImpl->GetViewMode();
154 }
155
156 void Core::SetStereoBase( float stereoBase )
157 {
158   mImpl->SetStereoBase( stereoBase );
159 }
160
161 float Core::GetStereoBase() const
162 {
163   return mImpl->GetStereoBase();
164 }
165
166 Core::Core()
167 : mImpl( NULL )
168 {
169 }
170
171 } // namespace Integration
172
173 } // namespace Dali