3182d31378e5b90ff4aff600d10cff5ca1fe575f
[profile/ivi/wayland-ivi-extension.git] / ivi-layermanagement-api / ilmControl / src / ilm_control.c
1 /**************************************************************************
2  *
3  * Copyright (C) 2013 DENSO CORPORATION
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  *        http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  *
17  ****************************************************************************/
18 #include <stdio.h>
19 #include <stdlib.h>
20 #include <string.h>
21 #include <memory.h>
22 #include <unistd.h>
23 #include <pthread.h>
24 #include <signal.h>
25 #include "ilm_common.h"
26 #include "ilm_control_platform.h"
27
28 /* GCC visibility */
29 #if defined(__GNUC__) && __GNUC__ >= 4
30 #define ILM_EXPORT __attribute__ ((visibility("default")))
31 #else
32 #define ILM_EXPORT
33 #endif
34
35 ILM_EXPORT ilmErrorTypes
36 ilmControl_init(t_ilm_nativedisplay nativedisplay)
37 {
38     init_ilmControlPlatformTable();
39
40     return gIlmControlPlatformFunc.init(nativedisplay);
41 }
42
43 ILM_EXPORT void
44 ilmControl_destroy(void)
45 {
46     gIlmControlPlatformFunc.destroy();
47 }
48
49 ILM_EXPORT ilmErrorTypes
50 ilm_getPropertiesOfLayer(t_ilm_uint layerID,
51                          struct ilmLayerProperties* pLayerProperties)
52 {
53     return gIlmControlPlatformFunc.getPropertiesOfLayer(
54                layerID, pLayerProperties);
55 }
56
57 ILM_EXPORT ilmErrorTypes
58 ilm_getPropertiesOfScreen(t_ilm_display screenID,
59                           struct ilmScreenProperties* pScreenProperties)
60 {
61     return gIlmControlPlatformFunc.getPropertiesOfScreen(
62                screenID, pScreenProperties);
63 }
64
65 ILM_EXPORT ilmErrorTypes
66 ilm_getNumberOfHardwareLayers(t_ilm_uint screenID,
67                               t_ilm_uint* pNumberOfHardwareLayers)
68 {
69     return gIlmControlPlatformFunc.getNumberOfHardwareLayers(
70                screenID, pNumberOfHardwareLayers);
71 }
72
73 ILM_EXPORT ilmErrorTypes
74 ilm_getScreenIDs(t_ilm_uint* pNumberOfIDs, t_ilm_uint** ppIDs)
75 {
76     return gIlmControlPlatformFunc.getScreenIDs(pNumberOfIDs, ppIDs);
77 }
78
79 ILM_EXPORT ilmErrorTypes
80 ilm_getLayerIDs(t_ilm_int* pLength, t_ilm_layer** ppArray)
81 {
82     return gIlmControlPlatformFunc.getLayerIDs(pLength, ppArray);
83 }
84
85 ILM_EXPORT ilmErrorTypes
86 ilm_getLayerIDsOnScreen(t_ilm_uint screenId, t_ilm_int* pLength,
87                         t_ilm_layer** ppArray)
88 {
89     return gIlmControlPlatformFunc.getLayerIDsOnScreen(
90                screenId, pLength, ppArray);
91 }
92
93 ILM_EXPORT ilmErrorTypes
94 ilm_getSurfaceIDs(t_ilm_int* pLength, t_ilm_surface** ppArray)
95 {
96     return gIlmControlPlatformFunc.getSurfaceIDs(pLength, ppArray);
97 }
98
99 ILM_EXPORT ilmErrorTypes
100 ilm_getSurfaceIDsOnLayer(t_ilm_layer layer, t_ilm_int* pLength,
101                          t_ilm_surface** ppArray)
102 {
103     return gIlmControlPlatformFunc.getSurfaceIDsOnLayer(
104                layer, pLength, ppArray);
105 }
106
107 ILM_EXPORT ilmErrorTypes
108 ilm_layerCreateWithDimension(t_ilm_layer* pLayerId,
109                              t_ilm_uint width, t_ilm_uint height)
110 {
111     return gIlmControlPlatformFunc.layerCreateWithDimension(
112                pLayerId, width, height);
113 }
114
115 ILM_EXPORT ilmErrorTypes
116 ilm_layerRemove(t_ilm_layer layerId)
117 {
118     return gIlmControlPlatformFunc.layerRemove(layerId);
119 }
120
121 ILM_EXPORT ilmErrorTypes
122 ilm_layerGetType(t_ilm_layer layerId, ilmLayerType* pLayerType)
123 {
124     return gIlmControlPlatformFunc.layerGetType(layerId, pLayerType);
125 }
126
127 ILM_EXPORT ilmErrorTypes
128 ilm_layerSetVisibility(t_ilm_layer layerId, t_ilm_bool newVisibility)
129 {
130     return gIlmControlPlatformFunc.layerSetVisibility(layerId, newVisibility);
131 }
132
133 ILM_EXPORT ilmErrorTypes
134 ilm_layerGetVisibility(t_ilm_layer layerId, t_ilm_bool *pVisibility)
135 {
136     return gIlmControlPlatformFunc.layerGetVisibility(layerId, pVisibility);
137 }
138
139 ILM_EXPORT ilmErrorTypes
140 ilm_layerSetOpacity(t_ilm_layer layerId, t_ilm_float opacity)
141 {
142     return gIlmControlPlatformFunc.layerSetOpacity(layerId, opacity);
143 }
144
145 ILM_EXPORT ilmErrorTypes
146 ilm_layerGetOpacity(t_ilm_layer layerId, t_ilm_float *pOpacity)
147 {
148     return gIlmControlPlatformFunc.layerGetOpacity(layerId, pOpacity);
149 }
150
151 ILM_EXPORT ilmErrorTypes
152 ilm_layerSetSourceRectangle(t_ilm_layer layerId,
153                             t_ilm_uint x, t_ilm_uint y,
154                             t_ilm_uint width, t_ilm_uint height)
155 {
156     return gIlmControlPlatformFunc.layerSetSourceRectangle(
157                layerId, x, y, width, height);
158 }
159
160 ILM_EXPORT ilmErrorTypes
161 ilm_layerSetDestinationRectangle(t_ilm_layer layerId,
162                                  t_ilm_int x, t_ilm_int y,
163                                  t_ilm_int width, t_ilm_int height)
164 {
165     return gIlmControlPlatformFunc.layerSetDestinationRectangle(
166                layerId, x, y, width, height);
167 }
168
169 ILM_EXPORT ilmErrorTypes
170 ilm_layerGetDimension(t_ilm_layer layerId, t_ilm_uint *pDimension)
171 {
172     return gIlmControlPlatformFunc.layerGetDimension(layerId, pDimension);
173 }
174
175 ILM_EXPORT ilmErrorTypes
176 ilm_layerSetDimension(t_ilm_layer layerId, t_ilm_uint *pDimension)
177 {
178     return gIlmControlPlatformFunc.layerSetDimension(layerId, pDimension);
179 }
180
181 ILM_EXPORT ilmErrorTypes
182 ilm_layerGetPosition(t_ilm_layer layerId, t_ilm_uint *pPosition)
183 {
184     return gIlmControlPlatformFunc.layerGetPosition(layerId, pPosition);
185 }
186
187 ILM_EXPORT ilmErrorTypes
188 ilm_layerSetPosition(t_ilm_layer layerId, t_ilm_uint *pPosition)
189 {
190     return gIlmControlPlatformFunc.layerSetPosition(layerId, pPosition);
191 }
192
193 ILM_EXPORT ilmErrorTypes
194 ilm_layerSetOrientation(t_ilm_layer layerId, ilmOrientation orientation)
195 {
196     return gIlmControlPlatformFunc.layerSetOrientation(layerId, orientation);
197 }
198
199 ILM_EXPORT ilmErrorTypes
200 ilm_layerGetOrientation(t_ilm_layer layerId, ilmOrientation *pOrientation)
201 {
202     return gIlmControlPlatformFunc.layerGetOrientation(layerId, pOrientation);
203 }
204
205 ILM_EXPORT ilmErrorTypes
206 ilm_layerSetChromaKey(t_ilm_layer layerId, t_ilm_int* pColor)
207 {
208     return gIlmControlPlatformFunc.layerSetChromaKey(layerId, pColor);
209 }
210
211 ILM_EXPORT ilmErrorTypes
212 ilm_layerSetRenderOrder(t_ilm_layer layerId,
213                         t_ilm_layer *pSurfaceId,
214                         t_ilm_int number)
215 {
216     return gIlmControlPlatformFunc.layerSetRenderOrder(
217                layerId, pSurfaceId, number);
218 }
219
220 ILM_EXPORT ilmErrorTypes
221 ilm_layerGetCapabilities(t_ilm_layer layerId,
222                          t_ilm_layercapabilities *pCapabilities)
223 {
224     return gIlmControlPlatformFunc.layerGetCapabilities(layerId, pCapabilities);
225 }
226
227 ILM_EXPORT ilmErrorTypes
228 ilm_layerTypeGetCapabilities(ilmLayerType layerType,
229                              t_ilm_layercapabilities *pCapabilities)
230 {
231     return gIlmControlPlatformFunc.layerTypeGetCapabilities(
232                layerType, pCapabilities);
233 }
234
235 ILM_EXPORT ilmErrorTypes
236 ilm_surfaceSetVisibility(t_ilm_surface surfaceId, t_ilm_bool newVisibility)
237 {
238     return gIlmControlPlatformFunc.surfaceSetVisibility(
239                surfaceId, newVisibility);
240 }
241
242 ILM_EXPORT ilmErrorTypes
243 ilm_surfaceSetOpacity(t_ilm_surface surfaceId, t_ilm_float opacity)
244 {
245     return gIlmControlPlatformFunc.surfaceSetOpacity(surfaceId, opacity);
246 }
247
248 ILM_EXPORT ilmErrorTypes
249 ilm_surfaceGetOpacity(t_ilm_surface surfaceId, t_ilm_float *pOpacity)
250 {
251     return gIlmControlPlatformFunc.surfaceGetOpacity(surfaceId, pOpacity);
252 }
253
254 ILM_EXPORT ilmErrorTypes
255 ilm_SetKeyboardFocusOn(t_ilm_surface surfaceId)
256 {
257     return gIlmControlPlatformFunc.SetKeyboardFocusOn(surfaceId);
258 }
259
260 ILM_EXPORT ilmErrorTypes
261 ilm_GetKeyboardFocusSurfaceId(t_ilm_surface* pSurfaceId)
262 {
263     return gIlmControlPlatformFunc.GetKeyboardFocusSurfaceId(pSurfaceId);
264 }
265
266 ILM_EXPORT ilmErrorTypes
267 ilm_surfaceSetDestinationRectangle(t_ilm_surface surfaceId,
268                                    t_ilm_int x, t_ilm_int y,
269                                    t_ilm_int width, t_ilm_int height)
270 {
271     return gIlmControlPlatformFunc.surfaceSetDestinationRectangle(
272                surfaceId, x, y, width, height);
273 }
274
275 ILM_EXPORT ilmErrorTypes
276 ilm_surfaceSetDimension(t_ilm_surface surfaceId, t_ilm_uint *pDimension)
277 {
278     return gIlmControlPlatformFunc.surfaceSetDimension(surfaceId, pDimension);
279 }
280
281 ILM_EXPORT ilmErrorTypes
282 ilm_surfaceGetPosition(t_ilm_surface surfaceId, t_ilm_uint *pPosition)
283 {
284     return gIlmControlPlatformFunc.surfaceGetPosition(surfaceId, pPosition);
285 }
286
287 ILM_EXPORT ilmErrorTypes
288 ilm_surfaceSetPosition(t_ilm_surface surfaceId, t_ilm_uint *pPosition)
289 {
290     return gIlmControlPlatformFunc.surfaceSetPosition(surfaceId, pPosition);
291 }
292
293 ILM_EXPORT ilmErrorTypes
294 ilm_surfaceSetOrientation(t_ilm_surface surfaceId, ilmOrientation orientation)
295 {
296     return gIlmControlPlatformFunc.surfaceSetOrientation(
297                surfaceId, orientation);
298 }
299
300 ILM_EXPORT ilmErrorTypes
301 ilm_surfaceGetOrientation(t_ilm_surface surfaceId, ilmOrientation *pOrientation)
302 {
303     return gIlmControlPlatformFunc.surfaceGetOrientation(
304                surfaceId, pOrientation);
305 }
306
307 ILM_EXPORT ilmErrorTypes
308 ilm_surfaceGetPixelformat(t_ilm_layer surfaceId, ilmPixelFormat *pPixelformat)
309 {
310     return gIlmControlPlatformFunc.surfaceGetPixelformat(
311                surfaceId, pPixelformat);
312 }
313
314 ILM_EXPORT ilmErrorTypes
315 ilm_surfaceSetChromaKey(t_ilm_surface surfaceId, t_ilm_int* pColor)
316 {
317     return gIlmControlPlatformFunc.surfaceSetChromaKey(surfaceId, pColor);
318 }
319
320 ILM_EXPORT ilmErrorTypes
321 ilm_displaySetRenderOrder(t_ilm_display display,
322                           t_ilm_layer *pLayerId, const t_ilm_uint number)
323 {
324     return gIlmControlPlatformFunc.displaySetRenderOrder(
325                display, pLayerId, number);
326 }
327
328 ILM_EXPORT ilmErrorTypes
329 ilm_takeScreenshot(t_ilm_uint screen, t_ilm_const_string filename)
330 {
331     return gIlmControlPlatformFunc.takeScreenshot(screen, filename);
332 }
333
334 ILM_EXPORT ilmErrorTypes
335 ilm_takeLayerScreenshot(t_ilm_const_string filename, t_ilm_layer layerid)
336 {
337     return gIlmControlPlatformFunc.takeLayerScreenshot(filename, layerid);
338 }
339
340 ILM_EXPORT ilmErrorTypes
341 ilm_takeSurfaceScreenshot(t_ilm_const_string filename, t_ilm_surface surfaceid)
342 {
343     return gIlmControlPlatformFunc.takeSurfaceScreenshot(filename, surfaceid);
344 }
345
346 ILM_EXPORT ilmErrorTypes
347 ilm_SetOptimizationMode(ilmOptimization id, ilmOptimizationMode mode)
348 {
349     return gIlmControlPlatformFunc.SetOptimizationMode(id, mode);
350 }
351
352 ILM_EXPORT ilmErrorTypes
353 ilm_GetOptimizationMode(ilmOptimization id, ilmOptimizationMode* pMode)
354 {
355     return gIlmControlPlatformFunc.GetOptimizationMode(id, pMode);
356 }
357
358 ILM_EXPORT ilmErrorTypes
359 ilm_layerAddNotification(t_ilm_layer layer, layerNotificationFunc callback)
360 {
361     return gIlmControlPlatformFunc.layerAddNotification(layer, callback);
362 }
363
364 ILM_EXPORT ilmErrorTypes
365 ilm_layerRemoveNotification(t_ilm_layer layer)
366 {
367     return gIlmControlPlatformFunc.layerRemoveNotification(layer);
368 }
369
370 ILM_EXPORT ilmErrorTypes
371 ilm_surfaceAddNotification(t_ilm_surface surface, surfaceNotificationFunc callback)
372 {
373     return gIlmControlPlatformFunc.surfaceAddNotification(surface, callback);
374 }
375
376 ILM_EXPORT ilmErrorTypes
377 ilm_surfaceRemoveNotification(t_ilm_surface surface)
378 {
379     return gIlmControlPlatformFunc.surfaceRemoveNotification(surface);
380 }
381
382 ILM_EXPORT ilmErrorTypes
383 ilm_getNativeHandle(t_ilm_uint pid, t_ilm_const_char *p_window_title,
384                     t_ilm_int *p_handle, t_ilm_nativehandle **p_handles)
385 {
386     return gIlmControlPlatformFunc.getNativeHandle(pid, p_handle, p_handles);
387 }
388
389 ILM_EXPORT ilmErrorTypes
390 ilm_getPropertiesOfSurface(t_ilm_uint surfaceID,
391                            struct ilmSurfaceProperties* pSurfaceProperties)
392 {
393     return gIlmControlPlatformFunc.getPropertiesOfSurface(
394                surfaceID, pSurfaceProperties);
395 }
396
397 ILM_EXPORT ilmErrorTypes
398 ilm_layerAddSurface(t_ilm_layer layerId, t_ilm_surface surfaceId)
399 {
400     return gIlmControlPlatformFunc.layerAddSurface(layerId, surfaceId);
401 }
402
403 ILM_EXPORT ilmErrorTypes
404 ilm_layerRemoveSurface(t_ilm_layer layerId, t_ilm_surface surfaceId)
405 {
406     return gIlmControlPlatformFunc.layerRemoveSurface(layerId, surfaceId);
407 }
408
409 ILM_EXPORT ilmErrorTypes
410 ilm_surfaceGetDimension(t_ilm_surface surfaceId, t_ilm_uint *pDimension)
411 {
412     return gIlmControlPlatformFunc.surfaceGetDimension(surfaceId, pDimension);
413 }
414
415 ILM_EXPORT ilmErrorTypes
416 ilm_surfaceGetVisibility(t_ilm_surface surfaceId, t_ilm_bool *pVisibility)
417 {
418     return gIlmControlPlatformFunc.surfaceGetVisibility(surfaceId, pVisibility);
419 }
420
421 ILM_EXPORT ilmErrorTypes
422 ilm_surfaceSetSourceRectangle(t_ilm_surface surfaceId,
423                               t_ilm_int x, t_ilm_int y,
424                               t_ilm_int width, t_ilm_int height)
425 {
426     return gIlmControlPlatformFunc.surfaceSetSourceRectangle(
427                surfaceId, x, y, width, height);
428 }
429
430 ILM_EXPORT ilmErrorTypes
431 ilm_commitChanges(void)
432 {
433     return gIlmControlPlatformFunc.commitChanges();
434 }