1 /***************************************************************************
3 * Copyright 2012 BMW Car IT GmbH
6 * Licensed under the Apache License, Version 2.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
10 * http://www.apache.org/licenses/LICENSE-2.0
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
18 ****************************************************************************/
20 #include "ilm_client.h"
21 #include "LMControl.h"
40 void printArray(const char* text, unsigned int* array, int count)
42 cout << count << " " << text << "(s):\n";
43 for (int i = 0; i < count; ++i)
45 cout << "- " << text << " " << dec << array[i] << hex << " (0x"
46 << array[i] << ")" << dec << "\n";
51 void printArray(const char* text, T* array, int count)
53 cout << count << " " << text << "(s):\n";
54 for (int i = 0; i < count; ++i)
56 cout << "- " << text << " " << "[" << array[i] << "]" << "\n";
61 void printVector(const char* text, vector<T> v)
63 cout << v.size() << " " << text << "(s) Vector:\n";
64 for (int i = 0; i < v.size(); ++i)
66 cout << "- " << text << " " << v[i] << endl;
70 template<typename K, typename V>
71 void printMap(const char* text, std::map<K, V> m)
73 cout << m.size() << " " << text << endl;
75 for (typename map<K, V>::iterator it = m.begin(); it != m.end(); ++it)
77 cout << "- " << (*it).first << " -> " << (*it).second << endl;
81 void printScreenProperties(unsigned int screenid, const char* prefix)
83 cout << prefix << "screen " << screenid << " (0x" << hex << screenid << dec
85 cout << prefix << "---------------------------------------\n";
87 ilmScreenProperties screenProperties;
89 ilmErrorTypes callResult = ilm_getPropertiesOfScreen(screenid, &screenProperties);
90 if (ILM_SUCCESS != callResult)
92 cout << "LayerManagerService returned: " << ILM_ERROR_STRING(callResult) << "\n";
93 cout << "Failed to get properties of screen with ID " << screenid << " found\n";
97 cout << prefix << "- resolution: x=" << screenProperties.screenWidth << ", y="
98 << screenProperties.screenHeight << "\n";
100 cout << prefix << "- hardware layer count: " << screenProperties.harwareLayerCount << "\n";
102 cout << prefix << "- layer render order: ";
104 for (t_ilm_uint layerIndex = 0; layerIndex < screenProperties.layerCount; ++layerIndex)
106 t_ilm_layer layerid = screenProperties.layerIds[layerIndex];
107 cout << layerid << "(0x" << hex << layerid << dec << "), ";
112 void printLayerProperties(unsigned int layerid, const char* prefix)
114 cout << prefix << "layer " << layerid << " (0x" << hex << layerid << dec
116 cout << prefix << "---------------------------------------\n";
118 ilmLayerProperties p;
120 ilmErrorTypes callResult = ilm_getPropertiesOfLayer(layerid, &p);
121 if (ILM_SUCCESS != callResult)
123 cout << "LayerManagerService returned: " << ILM_ERROR_STRING(callResult) << "\n";
124 cout << "Failed to get properties of layer with ID " << layerid << " found\n";
128 cout << prefix << "- created by pid: " << p.creatorPid << "\n";
130 cout << prefix << "- original size: x=" << p.origSourceWidth
131 << ", y=" << p.origSourceHeight << "\n";
132 cout << prefix << "- destination region: x=" << p.destX << ", y="
133 << p.destY << ", w=" << p.destWidth << ", h=" << p.destHeight
135 cout << prefix << "- source region: x=" << p.sourceX << ", y="
136 << p.sourceY << ", w=" << p.sourceWidth << ", h=" << p.sourceHeight
139 cout << prefix << "- orientation: " << p.orientation << " (";
140 switch (p.orientation)
143 cout << "up is top)\n";
146 cout << "up is right)\n";
149 cout << "up is bottom)\n";
151 case 3/*TwoSeventy*/:
152 cout << "up is left)\n";
155 cout << "unknown)\n";
159 cout << prefix << "- opacity: " << p.opacity << "\n";
160 cout << prefix << "- visibility: " << p.visibility << "\n";
162 cout << prefix << "- type: " << p.type << " (";
166 cout << "hardware)\n";
168 case 2/*Software_2D*/:
169 cout << "software 2d)\n";
171 case 3/*Software_2_5D*/:
172 cout << "software 2.5d)\n";
175 cout << "unknown)\n";
179 cout << prefix << "- chromakey: "
180 << (p.chromaKeyEnabled ? "enabled " : "disabled ")
181 << "(r=" << p.chromaKeyRed << ", g=" << p.chromaKeyGreen << ", b=" << p.chromaKeyBlue << ")\n";
183 cout << prefix << "- surface render order: ";
185 int surfaceCount = 0;
186 unsigned int* surfaceArray = NULL;
188 callResult = ilm_getSurfaceIDsOnLayer(layerid, &surfaceCount, &surfaceArray);
189 if (ILM_SUCCESS != callResult)
191 cout << "LayerManagerService returned: " << ILM_ERROR_STRING(callResult) << "\n";
192 cout << "Failed to get surfaces on layer with ID " << layerid << " \n";
196 for (int surfaceIndex = 0; surfaceIndex < surfaceCount; ++surfaceIndex)
198 cout << surfaceArray[surfaceIndex] << "(0x" << hex
199 << surfaceArray[surfaceIndex] << dec << "), ";
203 cout << prefix << "- on screen: ";
205 unsigned int screenCount = 0;
206 unsigned int* screenArray = NULL;
208 callResult = ilm_getScreenIDs(&screenCount, &screenArray);
209 if (ILM_SUCCESS != callResult)
211 cout << "LayerManagerService returned: " << ILM_ERROR_STRING(callResult) << "\n";
212 cout << "Failed to get available screens\n";
216 for (unsigned int screenIndex = 0; screenIndex < screenCount;
219 unsigned int screenid = screenArray[screenIndex];
221 unsigned int* layerArray = NULL;
223 callResult = ilm_getLayerIDsOnScreen(screenid, &layerCount, &layerArray);
224 if (ILM_SUCCESS != callResult)
226 cout << "LayerManagerService returned: " << ILM_ERROR_STRING(callResult) << "\n";
227 cout << "Failed to get available layers on screen with ID" << screenid << "\n";
231 for (int layerIndex = 0; layerIndex < layerCount; ++layerIndex)
233 unsigned int id = layerArray[layerIndex];
236 cout << screenid << "(0x" << hex << screenid << dec << ") ";
243 void printSurfaceProperties(unsigned int surfaceid, const char* prefix)
245 cout << prefix << "surface " << surfaceid << " (0x" << hex << surfaceid
247 cout << prefix << "---------------------------------------\n";
249 ilmSurfaceProperties p;
251 ilmErrorTypes callResult = ilm_getPropertiesOfSurface(surfaceid, &p);
252 if (ILM_SUCCESS != callResult)
254 cout << "LayerManagerService returned: " << ILM_ERROR_STRING(callResult) << "\n";
255 cout << "No surface with ID " << surfaceid << " found\n";
259 cout << prefix << "- created by pid: " << p.creatorPid << "\n";
261 cout << prefix << "- original size: x=" << p.origSourceWidth << ", y="
262 << p.origSourceHeight << "\n";
263 cout << prefix << "- destination region: x=" << p.destX << ", y=" << p.destY
264 << ", w=" << p.destWidth << ", h=" << p.destHeight << "\n";
265 cout << prefix << "- source region: x=" << p.sourceX << ", y="
266 << p.sourceY << ", w=" << p.sourceWidth << ", h=" << p.sourceHeight
269 cout << prefix << "- orientation: " << p.orientation << " (";
270 switch (p.orientation)
273 cout << "up is top)\n";
276 cout << "up is right)\n";
279 cout << "up is bottom)\n";
281 case 3/*TwoSeventy*/:
282 cout << "up is left)\n";
285 cout << "unknown)\n";
289 cout << prefix << "- opacity: " << p.opacity << "\n";
290 cout << prefix << "- visibility: " << p.visibility << "\n";
292 cout << prefix << "- pixel format: " << p.pixelformat << " (";
293 switch (p.pixelformat)
295 case 0/*PIXELFORMAT_R8*/:
298 case 1/*PIXELFORMAT_RGB888*/:
299 cout << "RGB-888)\n";
301 case 2/*PIXELFORMAT_RGBA8888*/:
302 cout << "RGBA-8888)\n";
304 case 3/*PIXELFORMAT_RGB565*/:
305 cout << "RGB-565)\n";
307 case 4/*PIXELFORMAT_RGBA5551*/:
308 cout << "RGBA-5551)\n";
310 case 5/*PIXELFORMAT_RGBA6661*/:
311 cout << "RGBA-6661)\n";
313 case 6/*PIXELFORMAT_RGBA4444*/:
314 cout << "RGBA-4444)\n";
317 cout << "unknown)\n";
321 cout << prefix << "- native surface: " << p.nativeSurface << "\n";
323 cout << prefix << "- accepts input from: "
324 << (p.inputDevicesAcceptance & ILM_INPUT_DEVICE_KEYBOARD ? "keyboard " : "")
325 << (p.inputDevicesAcceptance & ILM_INPUT_DEVICE_POINTER ? "mouse " : "")
326 << (p.inputDevicesAcceptance & ILM_INPUT_DEVICE_TOUCH ? "touch " : "")
329 t_ilm_surface keyboardFocusSurfaceId;
330 callResult = ilm_GetKeyboardFocusSurfaceId(&keyboardFocusSurfaceId);
331 if (ILM_SUCCESS != callResult)
333 cout << "LayerManagerService returned: " << ILM_ERROR_STRING(callResult) << "\n";
334 cout << "Failed to get keyboard focus surface ID\n";
338 cout << prefix << "- has keyboard focus: "
339 << (keyboardFocusSurfaceId == surfaceid ? "true" : "false")
342 cout << prefix << "- chromakey: "
343 << (p.chromaKeyEnabled ? "enabled " : "disabled ")
344 << "(r=" << p.chromaKeyRed << ", g=" << p.chromaKeyGreen << ", b=" << p.chromaKeyBlue << ")\n";
346 cout << prefix << "- counters: frame=" << p.frameCounter
347 << ", draw=" << p.drawCounter << ", update=" << p.updateCounter
350 cout << prefix << "- on layer: ";
352 unsigned int* layerArray = NULL;
354 callResult = ilm_getLayerIDs(&layerCount, &layerArray);
355 if (ILM_SUCCESS != callResult)
357 cout << "LayerManagerService returned: " << ILM_ERROR_STRING(callResult) << "\n";
358 cout << "Failed to get available layer IDs\n";
362 for (int layerIndex = 0; layerIndex < layerCount; ++layerIndex)
364 unsigned int layerid = layerArray[layerIndex];
365 int surfaceCount = 0;
366 unsigned int* surfaceArray = NULL;
368 callResult = ilm_getSurfaceIDsOnLayer(layerid, &surfaceCount, &surfaceArray);
369 if (ILM_SUCCESS != callResult)
371 cout << "LayerManagerService returned: " << ILM_ERROR_STRING(callResult) << "\n";
372 cout << "Failed to get surface IDs on layer" << layerid << "\n";
376 for (int surfaceIndex = 0; surfaceIndex < surfaceCount;
379 unsigned int id = surfaceArray[surfaceIndex];
382 cout << layerid << "(0x" << hex << layerid << dec << ") ";
391 unsigned int screenCount = 0;
392 unsigned int* screenArray = NULL;
394 ilmErrorTypes callResult = ilm_getScreenIDs(&screenCount, &screenArray);
395 if (ILM_SUCCESS != callResult)
397 cout << "LayerManagerService returned: " << ILM_ERROR_STRING(callResult) << "\n";
398 cout << "Failed to get available screen IDs\n";
402 for (unsigned int screenIndex = 0; screenIndex < screenCount; ++screenIndex)
404 unsigned int screenid = screenArray[screenIndex];
405 printScreenProperties(screenid);
409 unsigned int* layerArray = NULL;
411 callResult = ilm_getLayerIDsOnScreen(screenid, &layerCount, &layerArray);
412 if (ILM_SUCCESS != callResult)
414 cout << "LayerManagerService returned: " << ILM_ERROR_STRING(callResult) << "\n";
415 cout << "Failed to get available layers on screen with ID" << screenid << "\n";
419 for (int layerIndex = 0; layerIndex < layerCount; ++layerIndex)
421 unsigned int layerid = layerArray[layerIndex];
422 printLayerProperties(layerid, " ");
425 int surfaceCount = 0;
426 unsigned int* surfaceArray = NULL;
428 callResult = ilm_getSurfaceIDsOnLayer(layerid, &surfaceCount, &surfaceArray);
429 if (ILM_SUCCESS != callResult)
431 cout << "LayerManagerService returned: " << ILM_ERROR_STRING(callResult) << "\n";
432 cout << "Failed to get available surfaces on layer with ID" << layerid << "\n";
436 for (int surfaceIndex = 0; surfaceIndex < surfaceCount; ++surfaceIndex)
438 unsigned int surfaceid = surfaceArray[surfaceIndex];
439 printSurfaceProperties(surfaceid, " ");