526919546cd3526d5f757588e0cae1e5256c6f4c
[platform/core/uifw/dali-adaptor.git] / adaptors / common / adaptor.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 <adaptor.h>
20
21 // EXTERNAL INCLUDES
22 #include <dali/integration-api/debug.h>
23
24 // INTERNAL INCLUDES
25 #include <accessibility-manager.h>
26 #include <imf-manager.h>
27 #include <style-monitor.h>
28 #include <window.h>
29 #include <render-surface.h>
30 #include <adaptor-impl.h>
31 #include <window-impl.h>
32
33 namespace Dali
34 {
35
36 Adaptor& Adaptor::New( Window window )
37 {
38   return New( window, DeviceLayout::DEFAULT_BASE_LAYOUT, Configuration::APPLICATION_DOES_NOT_HANDLE_CONTEXT_LOSS );
39 }
40
41 Adaptor& Adaptor::New( Window window, const DeviceLayout& baseLayout, Configuration::ContextLoss configuration )
42 {
43   Any winId = window.GetNativeHandle();
44
45   Internal::Adaptor::Window& windowImpl = GetImplementation(window);
46   Adaptor* adaptor = Internal::Adaptor::Adaptor::New( winId, windowImpl.GetSurface(), baseLayout, configuration );
47   windowImpl.SetAdaptor(*adaptor);
48   return *adaptor;
49 }
50
51 Adaptor& Adaptor::New( Any nativeWindow, const Dali::RenderSurface& surface )
52 {
53   return New( nativeWindow, surface, DeviceLayout::DEFAULT_BASE_LAYOUT, Configuration::APPLICATION_DOES_NOT_HANDLE_CONTEXT_LOSS );
54 }
55
56 Adaptor& Adaptor::New( Any nativeWindow, const Dali::RenderSurface& surface, const DeviceLayout& baseLayout, Configuration::ContextLoss configuration )
57 {
58   Dali::RenderSurface* pSurface = const_cast<Dali::RenderSurface *>(&surface);
59   Adaptor* adaptor = Internal::Adaptor::Adaptor::New( nativeWindow, pSurface, baseLayout, configuration );
60   return *adaptor;
61 }
62
63 Adaptor::~Adaptor()
64 {
65   delete mImpl;
66 }
67
68 void Adaptor::Start()
69 {
70   mImpl->Start();
71 }
72
73 void Adaptor::Pause()
74 {
75   mImpl->Pause();
76 }
77
78 void Adaptor::Resume()
79 {
80   mImpl->Resume();
81 }
82
83 void Adaptor::Stop()
84 {
85   mImpl->Stop();
86 }
87
88 bool Adaptor::AddIdle( CallbackBase* callback )
89 {
90   return mImpl->AddIdle( callback );
91 }
92
93 void Adaptor::ReplaceSurface( Any nativeWindow, Dali::RenderSurface& surface )
94 {
95   mImpl->ReplaceSurface(nativeWindow, surface);
96 }
97
98 Adaptor::AdaptorSignalType& Adaptor::ResizedSignal()
99 {
100   return mImpl->ResizedSignal();
101 }
102
103 Adaptor::AdaptorSignalType& Adaptor::LanguageChangedSignal()
104 {
105   return mImpl->LanguageChangedSignal();
106 }
107
108 RenderSurface& Adaptor::GetSurface()
109 {
110   return mImpl->GetSurface();
111 }
112
113 void Adaptor::ReleaseSurfaceLock()
114 {
115   mImpl->ReleaseSurfaceLock();
116 }
117
118 void Adaptor::SetRenderRefreshRate( unsigned int numberOfVSyncsPerRender )
119 {
120   mImpl->SetRenderRefreshRate( numberOfVSyncsPerRender );
121 }
122
123 void Adaptor::SetUseHardwareVSync(bool useHardware)
124 {
125   mImpl->SetUseHardwareVSync( useHardware );
126 }
127
128 Adaptor& Adaptor::Get()
129 {
130   return Internal::Adaptor::Adaptor::Get();
131 }
132
133 bool Adaptor::IsAvailable()
134 {
135   return Internal::Adaptor::Adaptor::IsAvailable();
136 }
137
138 void Adaptor::NotifyLanguageChanged()
139 {
140   mImpl->NotifyLanguageChanged();
141 }
142
143 void Adaptor::SetMinimumPinchDistance(float distance)
144 {
145   mImpl->SetMinimumPinchDistance(distance);
146 }
147
148 void Adaptor::FeedTouchPoint( TouchPoint& point, int timeStamp )
149 {
150   mImpl->FeedTouchPoint(point, timeStamp);
151 }
152
153 void Adaptor::FeedWheelEvent( MouseWheelEvent& wheelEvent )
154 {
155   mImpl->FeedWheelEvent(wheelEvent);
156 }
157
158 void Adaptor::FeedKeyEvent( KeyEvent& keyEvent )
159 {
160   mImpl->FeedKeyEvent(keyEvent);
161 }
162
163 Adaptor::Adaptor()
164 : mImpl( NULL )
165 {
166 }
167
168 } // namespace Dali