Merge "Build and package Layer Management service binaries." into tizen
[profile/ivi/layer-management.git] / LayerManagerClient / ilmCommon / include / ilm_types.h
1 /***************************************************************************
2 *
3 * Copyright 2010,2011 BMW Car IT GmbH
4 * Copyright (C) 2012 DENSO CORPORATION and Robert Bosch Car Multimedia Gmbh
5 *
6 *
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
10 *
11 *        http://www.apache.org/licenses/LICENSE-2.0
12 *
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
18 *
19 ****************************************************************************/
20 #ifndef _ILM_TYPES_H_
21 #define _ILM_TYPES_H_
22
23 #include "ilm_platform.h"
24
25 /**
26  * convenience macro to access single bits of a bitmask
27  */
28 #define ILM_BIT(x) (1 << (x))
29
30
31 /**
32  * \brief Represent the logical true value
33  * \ingroup ilmClient
34  **/
35 #define ILM_TRUE     1u
36
37 /**
38  * \brief Represent the logical false value
39  * \ingroup ilmClient
40  **/
41 #define ILM_FALSE     0u
42
43 /**
44  * \brief Enumeration on possible error codes
45  * \ingroup ilmClient
46  **/
47 typedef enum e_ilmErrorTypes
48 {
49     ILM_SUCCESS = 0,                       /*!< ErrorCode if the method call was successful */
50     ILM_FAILED = 1,                        /*!< ErrorCode if the method call has failed */
51     ILM_ERROR_INVALID_ARGUMENTS = 2,       /*!< ErrorCode if the method was called with invalid arguments */
52     ILM_ERROR_ON_CONNECTION = 3,           /*!< ErrorCode if connection error has occured */
53     ILM_ERROR_RESOURCE_ALREADY_INUSE = 4,  /*!< ErrorCode if resource is already in use */
54     ILM_ERROR_RESOURCE_NOT_FOUND = 5,      /*!< ErrorCode if resource was not found */
55     ILM_ERROR_NOT_IMPLEMENTED = 6,         /*!< ErrorCode if feature is not implemented */
56     ILM_ERROR_UNEXPECTED_MESSAGE = 7       /*!< ErrorCode if received message has unexpected type */
57 } ilmErrorTypes;
58
59 /**
60  * \brief Macro to translate error codes into error description strings
61  * \ingroup ilmClient
62  **/
63 #define ILM_ERROR_STRING(x)                                                   \
64     ( (x) == ILM_SUCCESS                      ? "success"                     \
65     : (x) == ILM_FAILED                       ? "failed"                      \
66     : (x) == ILM_ERROR_INVALID_ARGUMENTS      ? "invalid arguments provided"  \
67     : (x) == ILM_ERROR_ON_CONNECTION          ? "connection error"            \
68     : (x) == ILM_ERROR_RESOURCE_ALREADY_INUSE ? "resource is already in use"  \
69     : (x) == ILM_ERROR_RESOURCE_NOT_FOUND     ? "resource was not found"      \
70     : (x) == ILM_ERROR_NOT_IMPLEMENTED        ? "feature is not implemented"  \
71     : (x) == ILM_ERROR_UNEXPECTED_MESSAGE     ? "unexpected message received" \
72     : "unknown error code"                                                    )
73
74
75 /**
76  * \brief Enumeration for supported pixelformats
77  * \ingroup ilmClient
78  **/
79 typedef enum e_ilmPixelFormat
80 {
81     ILM_PIXELFORMAT_R_8 = 0,           /*!< Pixelformat value, to describe a 8 bit luminance surface */
82     ILM_PIXELFORMAT_RGB_888 = 1,       /*!< Pixelformat value, to describe a 24 bit rgb surface */
83     ILM_PIXELFORMAT_RGBA_8888 = 2,      /*!< Pixelformat value, to describe a 24 bit rgb surface with 8 bit alpha */
84     ILM_PIXELFORMAT_RGB_565 = 3,       /*!< Pixelformat value, to describe a 16 bit rgb surface */
85     ILM_PIXELFORMAT_RGBA_5551 = 4,     /*!< Pixelformat value, to describe a 16 bit rgb surface, with binary mask */
86     ILM_PIXELFORMAT_RGBA_6661 = 5,     /*!< Pixelformat value, to describe a 18 bit rgb surface, with binars mask */
87     ILM_PIXELFORMAT_RGBA_4444 = 6,     /*!< Pixelformat value, to describe a 12 bit rgb surface, with 4 bit alpha */
88     ILM_PIXEL_FORMAT_UNKNOWN = 7       /*!< Pixelformat not known */
89 } ilmPixelFormat;
90
91 /**
92  * \brief Enumeration for supported layertypes
93  * \ingroup ilmControl
94  **/
95 typedef enum e_ilmLayerType
96 {
97     ILM_LAYERTYPE_UNKNOWN = 0,         /*!< LayerType not known */
98     ILM_LAYERTYPE_HARDWARE = 1,        /*!< LayerType value, to describe a hardware layer */
99     ILM_LAYERTYPE_SOFTWARE2D = 2,      /*!< LayerType value, to describe a redirected offscreen buffer layer */
100     ILM_LAYERTYPE_SOFTWARE2_5D = 3     /*!< LayerType value, to describe a redirected offscreen buffer layer,
101                                             which can be rotated in the 3d space */
102 } ilmLayerType;
103
104 /**
105  * \brief Enumeration for supported graphical objects
106  * \ingroup ilmControl
107  **/
108 typedef enum e_ilmObjectType
109 {
110     ILM_SURFACE = 0,                   /*!< Surface Object Type */
111     ILM_LAYER = 1                      /*!< Layer Object Type */
112 } ilmObjectType;
113
114 /**
115  * \brief Enumeration of renderer optimizations
116  * \ingroup ilmControl
117  **/
118 typedef enum e_ilmOptimization
119 {
120     ILM_OPT_MULTITEXTURE = 0,          /*!< Multi-texture optimization */
121     ILM_OPT_SKIP_CLEAR = 1             /*!< Skip clearing the screen */
122 } ilmOptimization;
123
124 /**
125  * \brief Enablement states for individual optimizations
126  * \ingroup ilmControl
127  **/
128 typedef enum e_ilmOptimizationMode
129 {
130     ILM_OPT_MODE_FORCE_OFF = 0,        /*!< Disable optimization */
131     ILM_OPT_MODE_FORCE_ON = 1,         /*!< Enable optimization */
132     ILM_OPT_MODE_HEURISTIC = 2,        /*!< Let renderer choose enablement */
133     ILM_OPT_MODE_TOGGLE = 3            /*!< Toggle on/and off rapidly for debugging */
134 } ilmOptimizationMode;
135
136 /**
137  * \brief Enumeration for supported orientations of booth, surface and layer
138  * \ingroup ilmControl
139  **/
140 typedef enum e_ilmOrientation
141 {
142     ILM_ZERO = 0,                       /*!< Orientation value, to describe 0 degree of rotation regarding the z-axis*/
143     ILM_NINETY = 1,                     /*!< Orientation value, to describe 90 degree of rotation regarding the z-axis*/
144     ILM_ONEHUNDREDEIGHTY = 2,           /*!< Orientation value, to describe 180 degree of rotation regarding the z-axis*/
145     ILM_TWOHUNDREDSEVENTY = 3           /*!< Orientation value, to describe 270 degree of rotation regarding the z-axis*/
146 } ilmOrientation;
147
148 /**
149  * \brief Identifier of different input device types. Can be used as a bitmask.
150  * \ingroup ilmClient
151  */
152 typedef unsigned int ilmInputDevice;
153 #define ILM_INPUT_DEVICE_KEYBOARD   ((ilmInputDevice) 1 << 0)
154 #define ILM_INPUT_DEVICE_POINTER    ((ilmInputDevice) 1 << 1)
155 #define ILM_INPUT_DEVICE_TOUCH      ((ilmInputDevice) 1 << 2)
156 #define ILM_INPUT_DEVICE_ALL        ((ilmInputDevice) ~0)
157
158
159 /**
160  * \brief Typedef for representing a layer
161  * \ingroup ilmClient
162  **/
163 typedef t_ilm_uint     t_ilm_layer;
164
165 /**
166  * \brief Typedef for representing a surface
167  * \ingroup ilmClient
168  **/
169 typedef t_ilm_uint     t_ilm_surface;
170
171 /**
172  * \brief Typedef for representing a display number
173  * \ingroup ilmClient
174  **/
175 typedef t_ilm_uint     t_ilm_display;
176
177 /**
178  * \brief Typedef for representing layer capabilities
179  * \ingroup ilmControl
180  **/
181 typedef t_ilm_uint     t_ilm_layercapabilities;
182
183 /**
184  * \brief Typedef for representing a native window handle
185  * \ingroup ilmClient
186  **/
187 typedef t_ilm_ulong    t_ilm_nativehandle;
188
189 /**
190  * \brief Typedef for representing a ascii string
191  * \ingroup ilmClient
192  **/
193 typedef t_ilm_char* t_ilm_string;
194
195 /**
196  * \brief Typedef for representing a const ascii string
197  * \ingroup ilmClient
198  **/
199 typedef t_ilm_const_char* t_ilm_const_string;
200
201 /**
202  * \brief Typedef for representing a the surface properties structure
203  * \ingroup ilmClient
204  **/
205 struct ilmSurfaceProperties
206 {
207     t_ilm_float opacity;                    /*!< opacity value of the surface */
208     t_ilm_uint sourceX;                     /*!< x source position value of the surface */
209     t_ilm_uint sourceY;                     /*!< y source position value of the surface */
210     t_ilm_uint sourceWidth;                 /*!< source width value of the surface */
211     t_ilm_uint sourceHeight;                /*!< source height value of the surface */
212     t_ilm_uint origSourceWidth;             /*!< original source width value of the surface */
213     t_ilm_uint origSourceHeight;            /*!< original source height value of the surface */
214     t_ilm_uint destX;                       /*!< x destination position value of the surface */
215     t_ilm_uint destY;                       /*!< y desitination position value of the surface */
216     t_ilm_uint destWidth;                   /*!< destination width value of the surface */
217     t_ilm_uint destHeight;                  /*!< destination height value of the surface */
218     ilmOrientation orientation;             /*!< orientation value of the surface */
219     t_ilm_bool visibility;                  /*!< visibility value of the surface */
220     t_ilm_uint frameCounter;                /*!< already rendered frames of surface */
221     t_ilm_uint drawCounter;                 /*!< content updates of surface */
222     t_ilm_uint updateCounter;               /*!< content updates of surface */
223     t_ilm_uint pixelformat;                 /*!< pixel format of surface */
224     t_ilm_uint nativeSurface;               /*!< native surface handle of surface */
225     ilmInputDevice inputDevicesAcceptance;  /*!< bitmask of ilmInputDevice from which the surface can accept input events */
226     t_ilm_bool chromaKeyEnabled;            /*!< chromakey validness of the surface */
227     t_ilm_uint chromaKeyRed;                /*!< chromakey's red value of the surface */
228     t_ilm_uint chromaKeyGreen;              /*!< chromakey's green value of the surface */
229     t_ilm_uint chromaKeyBlue;               /*!< chromakey's blue value of the surface */
230     t_ilm_int  creatorPid;                  /*!< process id of application that created this surface */
231 };
232
233 /**
234  * \brief Typedef for representing a the layer properties structure
235  * \ingroup ilmControl
236  **/
237 struct ilmLayerProperties
238 {
239     t_ilm_float opacity;         /*!< opacity value of the layer */
240     t_ilm_uint sourceX;          /*!< x source position value of the layer */
241     t_ilm_uint sourceY;          /*!< y source position value of the layer */
242     t_ilm_uint sourceWidth;      /*!< source width value of the layer */
243     t_ilm_uint sourceHeight;     /*!< source height value of the layer */
244     t_ilm_uint origSourceWidth;  /*!< original source width value of the layer */
245     t_ilm_uint origSourceHeight; /*!< original source height value of the layer */
246     t_ilm_uint destX;            /*!< x destination position value of the layer */
247     t_ilm_uint destY;            /*!< y desitination position value of the layer */
248     t_ilm_uint destWidth;        /*!< destination width value of the layer */
249     t_ilm_uint destHeight;       /*!< destination height value of the layer */
250     ilmOrientation orientation;  /*!< orientation value of the layer */
251     t_ilm_bool visibility;       /*!< visibility value of the layer */
252     t_ilm_uint type;             /*!< type of layer */
253     t_ilm_bool chromaKeyEnabled; /*!< chromakey validness of the layer */
254     t_ilm_uint chromaKeyRed;     /*!< chromakey's red value of the layer */
255     t_ilm_uint chromaKeyGreen;   /*!< chromakey's green value of the layer */
256     t_ilm_uint chromaKeyBlue;    /*!< chromakey's blue value of the layer */
257     t_ilm_int  creatorPid;       /*!< process id of application that created this layer */
258 };
259
260 /**
261  * \brief Typedef for representing a the screen properties structure
262  * \ingroup ilmControl
263  **/
264 struct ilmScreenProperties
265 {
266     t_ilm_uint layerCount;          /*!< number of layers displayed on the screen */
267     t_ilm_layer* layerIds;          /*!< array of layer ids */
268     t_ilm_uint harwareLayerCount;   /*!< number of hardware layers */
269     t_ilm_uint screenWidth;         /*!< width value of screen in pixels */
270     t_ilm_uint screenHeight;        /*!< height value of screen in pixels */
271 };
272
273 /**
274  * enum representing all possible incoming events for ilmClient and
275  * Communicator Plugin
276  */
277 typedef enum e_t_ilm_message_type
278 {
279     IpcMessageTypeNone = 0,
280     IpcMessageTypeCommand,
281     IpcMessageTypeConnect,
282     IpcMessageTypeDisconnect,
283     IpcMessageTypeNotification,
284     IpcMessageTypeError,
285     IpcMessageTypeTimeout,
286     IpcMessageTypeShutdown
287 } t_ilm_message_type;
288
289 /**
290  * Typedef for opaque handling of client handles within an IpcModule
291  */
292 typedef void* t_ilm_client_handle;
293
294 /**
295  * Typedef for opaque handling of messages from IpcModule
296  */
297 typedef void* t_ilm_message;
298
299 /**
300  * enum representing the possible flags for changed properties in notification callbacks.
301  */
302 typedef enum
303 {
304     ILM_NOTIFICATION_VISIBILITY = ILM_BIT(1),
305     ILM_NOTIFICATION_OPACITY = ILM_BIT(2),
306     ILM_NOTIFICATION_ORIENTATION = ILM_BIT(3),
307     ILM_NOTIFICATION_SOURCE_RECT = ILM_BIT(4),
308     ILM_NOTIFICATION_DEST_RECT = ILM_BIT(5),
309     ILM_NOTIFICATION_ALL = 0xffff
310 } t_ilm_notification_mask;
311
312 /**
313  * Typedef for notification callback on property changes of a layer
314  */
315 typedef void(*layerNotificationFunc)(t_ilm_layer layer,
316                                         struct ilmLayerProperties*,
317                                         t_ilm_notification_mask mask);
318
319 /**
320  * Typedef for notification callback on property changes of a surface
321  */
322 typedef void(*surfaceNotificationFunc)(t_ilm_surface surface,
323                                         struct ilmSurfaceProperties*,
324                                         t_ilm_notification_mask mask);
325
326 /**
327  * enum for identifying different health states
328  */
329 enum HealthCondition
330 {
331     HealthStopped,
332     HealthRunning,
333     HealthDead
334 };
335
336 /**
337  * enum for identifying plugin types and versions
338  *
339  * All plugins are started in the order defined by their value
340  * in this enum (lowest first, highest last).
341  * The plugins are stopped in opposite order (highest first,
342  * lowest last).
343  */
344 typedef enum PluginApi
345 {
346     Renderer_Api = 0x00010000,
347     Renderer_Api_v1,
348
349     SceneProvider_Api = 0x00020000,
350     SceneProvider_Api_v1,
351
352     Communicator_Api = 0x00040000,
353     Communicator_Api_v1,
354
355     HealthMonitor_Api = 0x00080000,
356     HealthMonitor_Api_v1
357 } ilmPluginApi;
358
359 #define PLUGIN_IS_COMMUNICATOR(x)  ((x) & Communicator_Api)
360 #define PLUGIN_IS_RENDERER(x)      ((x) & Renderer_Api)
361 #define PLUGIN_IS_SCENEPROVIDER(x) ((x) & SceneProvider_Api)
362 #define PLUGIN_IS_HEALTHMONITOR(x) ((x) & HealthMonitor_Api)
363
364 #endif /* _ILM_TYPES_H_*/