ilmClient: split into ilmCommon, ilmClient, ilmControl
[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_client_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, which can be rotated in the 3d space */
101 } ilmLayerType;
102
103 /**
104  * \brief Enumeration for supported graphical objects
105  * \ingroup ilmControl
106  **/
107 typedef enum e_ilmObjectType
108 {
109     ILM_SURFACE = 0,                   /*!< Surface Object Type */
110     ILM_LAYER = 1                      /*!< Layer Object Type */
111 } ilmObjectType;
112
113 /**
114  * \brief Enumeration of renderer optimizations
115  * \ingroup ilmControl
116  **/
117 typedef enum e_ilmOptimization
118 {
119     ILM_OPT_MULTITEXTURE = 0,          /*!< Multi-texture optimization */
120     ILM_OPT_SKIP_CLEAR = 1             /*!< Skip clearing the screen */
121 } ilmOptimization;
122
123 /**
124  * \brief Enablement states for individual optimizations
125  * \ingroup ilmControl
126  **/
127 typedef enum e_ilmOptimizationMode
128 {
129     ILM_OPT_MODE_FORCE_OFF = 0,        /*!< Disable optimization */
130     ILM_OPT_MODE_FORCE_ON = 1,         /*!< Enable optimization */
131     ILM_OPT_MODE_HEURISTIC = 2,        /*!< Let renderer choose enablement */
132     ILM_OPT_MODE_TOGGLE = 3            /*!< Toggle on/and off rapidly for debugging */
133 } ilmOptimizationMode;
134
135 /**
136  * \brief Enumeration for supported orientations of booth, surface and layer
137  * \ingroup ilmControl
138  **/
139 typedef enum e_ilmOrientation
140 {
141     ILM_ZERO = 0,                       /*!< Orientation value, to describe 0 degree of rotation regarding the z-axis*/
142     ILM_NINETY = 1,                     /*!< Orientation value, to describe 90 degree of rotation regarding the z-axis*/
143     ILM_ONEHUNDREDEIGHTY = 2,           /*!< Orientation value, to describe 180 degree of rotation regarding the z-axis*/
144     ILM_TWOHUNDREDSEVENTY = 3           /*!< Orientation value, to describe 270 degree of rotation regarding the z-axis*/
145 } ilmOrientation;
146
147 /**
148  * \brief Identifier of different input device types. Can be used as a bitmask.
149  * \ingroup ilmClient
150  */
151 typedef unsigned int ilmInputDevice;
152 #define ILM_INPUT_DEVICE_KEYBOARD   ((ilmInputDevice) 1 << 0)
153 #define ILM_INPUT_DEVICE_POINTER    ((ilmInputDevice) 1 << 1)
154 #define ILM_INPUT_DEVICE_TOUCH      ((ilmInputDevice) 1 << 2)
155 #define ILM_INPUT_DEVICE_ALL        ((ilmInputDevice) ~0)
156
157
158 /**
159  * \brief Typedef for representing a layer
160  * \ingroup ilmClient
161  **/
162 typedef t_ilm_uint     t_ilm_layer;
163
164 /**
165  * \brief Typedef for representing a surface
166  * \ingroup ilmClient
167  **/
168 typedef t_ilm_uint     t_ilm_surface;
169
170 /**
171  * \brief Typedef for representing a display number
172  * \ingroup ilmClient
173  **/
174 typedef t_ilm_uint     t_ilm_display;
175
176 /**
177  * \brief Typedef for representing layer capabilities
178  * \ingroup ilmControl
179  **/
180 typedef t_ilm_uint     t_ilm_layercapabilities;
181
182 /**
183  * \brief Typedef for representing a native window handle
184  * \ingroup ilmClient
185  **/
186 typedef t_ilm_ulong    t_ilm_nativehandle;
187
188 /**
189  * \brief Typedef for representing a ascii string
190  * \ingroup ilmClient
191  **/
192 typedef t_ilm_char* t_ilm_string;
193
194 /**
195  * \brief Typedef for representing a const ascii string
196  * \ingroup ilmClient
197  **/
198 typedef t_ilm_const_char* t_ilm_const_string;
199
200 /**
201  * \brief Typedef for representing a the surface properties structure
202  * \ingroup ilmClient
203  **/
204 struct ilmSurfaceProperties
205 {
206     t_ilm_float opacity;                    /*!< opacity value of the surface */
207     t_ilm_uint sourceX;                     /*!< x source position value of the surface */
208     t_ilm_uint sourceY;                     /*!< y source position value of the surface */
209     t_ilm_uint sourceWidth;                 /*!< source width value of the surface */
210     t_ilm_uint sourceHeight;                /*!< source height value of the surface */
211     t_ilm_uint origSourceWidth;             /*!< original source width value of the surface */
212     t_ilm_uint origSourceHeight;            /*!< original source height value of the surface */
213     t_ilm_uint destX;                       /*!< x destination position value of the surface */
214     t_ilm_uint destY;                       /*!< y desitination position value of the surface */
215     t_ilm_uint destWidth;                   /*!< destination width value of the surface */
216     t_ilm_uint destHeight;                  /*!< destination height value of the surface */
217     ilmOrientation orientation;             /*!< orientation value of the surface */
218     t_ilm_bool visibility;                  /*!< visibility value of the surface */
219     t_ilm_uint frameCounter;                /*!< already rendered frames of surface */
220     t_ilm_uint drawCounter;                 /*!< content updates of surface */
221     t_ilm_uint updateCounter;               /*!< content updates of surface */
222     t_ilm_uint pixelformat;                 /*!< pixel format of surface */
223     t_ilm_uint nativeSurface;               /*!< native surface handle of surface */
224     ilmInputDevice inputDevicesAcceptance;  /*!< bitmask of ilmInputDevice from which the surface can accept input events */
225     t_ilm_bool chromaKeyEnabled;            /*!< chromakey validness of the surface */
226     t_ilm_uint chromaKeyRed;                /*!< chromakey's red value of the surface */
227     t_ilm_uint chromaKeyGreen;              /*!< chromakey's green value of the surface */
228     t_ilm_uint chromaKeyBlue;               /*!< chromakey's blue value of the surface */
229     t_ilm_int  creatorPid;                  /*!< process id of application that created this surface */
230 };
231
232 /**
233  * \brief Typedef for representing a the layer properties structure
234  * \ingroup ilmControl
235  **/
236 struct ilmLayerProperties
237 {
238     t_ilm_float opacity;         /*!< opacity value of the layer */
239     t_ilm_uint sourceX;          /*!< x source position value of the layer */
240     t_ilm_uint sourceY;          /*!< y source position value of the layer */
241     t_ilm_uint sourceWidth;      /*!< source width value of the layer */
242     t_ilm_uint sourceHeight;     /*!< source height value of the layer */
243     t_ilm_uint origSourceWidth;  /*!< original source width value of the layer */
244     t_ilm_uint origSourceHeight; /*!< original source height value of the layer */
245     t_ilm_uint destX;            /*!< x destination position value of the layer */
246     t_ilm_uint destY;            /*!< y desitination position value of the layer */
247     t_ilm_uint destWidth;        /*!< destination width value of the layer */
248     t_ilm_uint destHeight;       /*!< destination height value of the layer */
249     ilmOrientation orientation;  /*!< orientation value of the layer */
250     t_ilm_bool visibility;       /*!< visibility value of the layer */
251     t_ilm_uint type;             /*!< type of layer */
252     t_ilm_bool chromaKeyEnabled; /*!< chromakey validness of the layer */
253     t_ilm_uint chromaKeyRed;     /*!< chromakey's red value of the layer */
254     t_ilm_uint chromaKeyGreen;   /*!< chromakey's green value of the layer */
255     t_ilm_uint chromaKeyBlue;    /*!< chromakey's blue value of the layer */
256     t_ilm_int  creatorPid;       /*!< process id of application that created this layer */
257 };
258
259 /**
260  * \brief Typedef for representing a the screen properties structure
261  * \ingroup ilmControl
262  **/
263 struct ilmScreenProperties
264 {
265     t_ilm_uint layerCount;          /*!< number of layers displayed on the screen */
266     t_ilm_layer* layerIds;          /*!< array of layer ids */
267     t_ilm_uint harwareLayerCount;   /*!< number of hardware layers */
268     t_ilm_uint screenWidth;         /*!< width value of screen in pixels */
269     t_ilm_uint screenHeight;        /*!< height value of screen in pixels */
270 };
271
272 /**
273  * enum representing all possible incoming events for ilmClient and
274  * Communicator Plugin
275  */
276 typedef enum e_t_ilm_message_type
277 {
278     IpcMessageTypeNone = 0,
279     IpcMessageTypeCommand,
280     IpcMessageTypeConnect,
281     IpcMessageTypeDisconnect,
282     IpcMessageTypeNotification,
283     IpcMessageTypeError,
284     IpcMessageTypeShutdown
285 } t_ilm_message_type;
286
287 /**
288  * Typedef for opaque handling of client handles within an IpcModule
289  */
290 typedef void* t_ilm_client_handle;
291
292 /**
293  * Typedef for opaque handling of messages from IpcModule
294  */
295 typedef void* t_ilm_message;
296
297 /**
298  * enum representing the possible flags for changed properties in notification callbacks.
299  */
300 typedef enum
301 {
302     ILM_NOTIFICATION_VISIBILITY         = ILM_BIT(1),
303     ILM_NOTIFICATION_OPACITY            = ILM_BIT(2),
304     ILM_NOTIFICATION_ORIENTATION        = ILM_BIT(3),
305     ILM_NOTIFICATION_SOURCE_RECT        = ILM_BIT(4),
306     ILM_NOTIFICATION_DEST_RECT          = ILM_BIT(5),
307     ILM_NOTIFICATION_ALL                = 0xffff
308 } t_ilm_notification_mask;
309
310 /**
311  * Typedef for notification callback on property changes of a layer
312  */
313 typedef void(*layerNotificationFunc)(t_ilm_layer layer,
314                                      struct ilmLayerProperties*,
315                                      t_ilm_notification_mask mask);
316
317 /**
318  * Typedef for notification callback on property changes of a surface
319  */
320 typedef void(*surfaceNotificationFunc)(t_ilm_surface surface,
321                                      struct ilmSurfaceProperties*,
322                                      t_ilm_notification_mask mask);
323
324 /**
325  * enum for identifying different health states
326  */
327 enum HealthCondition
328 {
329     HealthStopped,
330     HealthRunning,
331     HealthDead
332 };
333
334 /**
335  * enum for identifying plugin types and versions
336  *
337  * All plugins are started in the order defined by their value
338  * in this enum (lowest first, highest last).
339  * The plugins are stopped in opposite order (highest first,
340  * lowest last).
341  */
342 typedef enum PluginApi
343 {
344     Renderer_Api            = 0x00010000,
345     Renderer_Api_v1,
346
347     SceneProvider_Api       = 0x00020000,
348     SceneProvider_Api_v1,
349
350     Communicator_Api        = 0x00040000,
351     Communicator_Api_v1,
352
353     HealthMonitor_Api       = 0x00080000,
354     HealthMonitor_Api_v1
355 } ilmPluginApi;
356
357 #define PLUGIN_IS_COMMUNICATOR(x)  ((x) & Communicator_Api)
358 #define PLUGIN_IS_RENDERER(x)      ((x) & Renderer_Api)
359 #define PLUGIN_IS_SCENEPROVIDER(x) ((x) & SceneProvider_Api)
360 #define PLUGIN_IS_HEALTHMONITOR(x) ((x) & HealthMonitor_Api)
361
362 #endif /* _ILM_TYPES_H_*/