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;
88 ilm_getPropertiesOfScreen(screenid, &screenProperties);
89 cout << prefix << "- resolution: x=" << screenProperties.screenWidth << ", y="
90 << screenProperties.screenHeight << "\n";
92 cout << prefix << "- hardware layer count: " << screenProperties.harwareLayerCount << "\n";
94 cout << prefix << "- layer render order: ";
96 for (int layerIndex = 0; layerIndex < screenProperties.layerCount; ++layerIndex)
98 t_ilm_layer layerid = screenProperties.layerIds[layerIndex];
99 cout << layerid << "(0x" << hex << layerid << dec << "), ";
104 void printLayerProperties(unsigned int layerid, const char* prefix)
106 cout << prefix << "layer " << layerid << " (0x" << hex << layerid << dec
108 cout << prefix << "---------------------------------------\n";
110 ilmLayerProperties p;
111 ilm_getPropertiesOfLayer(layerid, &p);
113 cout << prefix << "- created by pid: " << p.creatorPid << "\n";
115 cout << prefix << "- original size: x=" << p.origSourceWidth
116 << ", y=" << p.origSourceHeight << "\n";
117 cout << prefix << "- destination region: x=" << p.destX << ", y="
118 << p.destY << ", w=" << p.destWidth << ", h=" << p.destHeight
120 cout << prefix << "- source region: x=" << p.sourceX << ", y="
121 << p.sourceY << ", w=" << p.sourceWidth << ", h=" << p.sourceHeight
124 cout << prefix << "- orientation: " << p.orientation << " (";
125 switch (p.orientation)
128 cout << "up is top)\n";
131 cout << "up is right)\n";
134 cout << "up is bottom)\n";
136 case 3/*TwoSeventy*/:
137 cout << "up is left)\n";
140 cout << "unknown)\n";
144 cout << prefix << "- opacity: " << p.opacity << "\n";
145 cout << prefix << "- visibility: " << p.visibility << "\n";
147 cout << prefix << "- type: " << p.type << " (";
151 cout << "hardware)\n";
153 case 2/*Software_2D*/:
154 cout << "software 2d)\n";
156 case 3/*Software_2_5D*/:
157 cout << "software 2.5d)\n";
160 cout << "unknown)\n";
164 cout << prefix << "- chromakey: "
165 << (p.chromaKeyEnabled ? "enabled " : "disabled ")
166 << "(r=" << p.chromaKeyRed << ", g=" << p.chromaKeyGreen << ", b=" << p.chromaKeyBlue << ")\n";
168 cout << prefix << "- surface render order: ";
169 int surfaceCount = 0;
170 unsigned int* surfaceArray = NULL;
171 ilm_getSurfaceIDsOnLayer(layerid, &surfaceCount, &surfaceArray);
172 for (int surfaceIndex = 0; surfaceIndex < surfaceCount; ++surfaceIndex)
174 cout << surfaceArray[surfaceIndex] << "(0x" << hex
175 << surfaceArray[surfaceIndex] << dec << "), ";
179 cout << prefix << "- on screen: ";
180 unsigned int screenCount = 0;
181 unsigned int* screenArray = NULL;
182 ilm_getScreenIDs(&screenCount, &screenArray);
183 for (unsigned int screenIndex = 0; screenIndex < screenCount;
186 unsigned int screenid = screenArray[screenIndex];
188 unsigned int* layerArray = NULL;
189 ilm_getLayerIDsOnScreen(screenid, &layerCount, &layerArray);
190 for (int layerIndex = 0; layerIndex < layerCount; ++layerIndex)
192 unsigned int id = layerArray[layerIndex];
195 cout << screenid << "(0x" << hex << screenid << dec << ") ";
202 void printSurfaceProperties(unsigned int surfaceid, const char* prefix)
204 cout << prefix << "surface " << surfaceid << " (0x" << hex << surfaceid
206 cout << prefix << "---------------------------------------\n";
208 ilmSurfaceProperties p;
209 ilm_getPropertiesOfSurface(surfaceid, &p);
211 cout << prefix << "- created by pid: " << p.creatorPid << "\n";
213 cout << prefix << "- original size: x=" << p.origSourceWidth << ", y="
214 << p.origSourceHeight << "\n";
215 cout << prefix << "- destination region: x=" << p.destX << ", y=" << p.destY
216 << ", w=" << p.destWidth << ", h=" << p.destHeight << "\n";
217 cout << prefix << "- source region: x=" << p.sourceX << ", y="
218 << p.sourceY << ", w=" << p.sourceWidth << ", h=" << p.sourceHeight
221 cout << prefix << "- orientation: " << p.orientation << " (";
222 switch (p.orientation)
225 cout << "up is top)\n";
228 cout << "up is right)\n";
231 cout << "up is bottom)\n";
233 case 3/*TwoSeventy*/:
234 cout << "up is left)\n";
237 cout << "unknown)\n";
241 cout << prefix << "- opacity: " << p.opacity << "\n";
242 cout << prefix << "- visibility: " << p.visibility << "\n";
244 cout << prefix << "- pixel format: " << p.pixelformat << " (";
245 switch (p.pixelformat)
247 case 0/*PIXELFORMAT_R8*/:
250 case 1/*PIXELFORMAT_RGB888*/:
251 cout << "RGB-888)\n";
253 case 2/*PIXELFORMAT_RGBA8888*/:
254 cout << "RGBA-8888)\n";
256 case 3/*PIXELFORMAT_RGB565*/:
257 cout << "RGB-565)\n";
259 case 4/*PIXELFORMAT_RGBA5551*/:
260 cout << "RGBA-5551)\n";
262 case 5/*PIXELFORMAT_RGBA6661*/:
263 cout << "RGBA-6661)\n";
265 case 6/*PIXELFORMAT_RGBA4444*/:
266 cout << "RGBA-4444)\n";
269 cout << "unknown)\n";
273 cout << prefix << "- native surface: " << p.nativeSurface << "\n";
275 cout << prefix << "- accepts input from: "
276 << (p.inputDevicesAcceptance & ILM_INPUT_DEVICE_KEYBOARD ? "keyboard " : "")
277 << (p.inputDevicesAcceptance & ILM_INPUT_DEVICE_POINTER ? "mouse " : "")
278 << (p.inputDevicesAcceptance & ILM_INPUT_DEVICE_TOUCH ? "touch " : "")
281 t_ilm_surface keyboardFocusSurfaceId;
282 ilm_GetKeyboardFocusSurfaceId(&keyboardFocusSurfaceId);
284 cout << prefix << "- has keyboard focus: "
285 << (keyboardFocusSurfaceId == surfaceid ? "true" : "false")
288 cout << prefix << "- chromakey: "
289 << (p.chromaKeyEnabled ? "enabled " : "disabled ")
290 << "(r=" << p.chromaKeyRed << ", g=" << p.chromaKeyGreen << ", b=" << p.chromaKeyBlue << ")\n";
292 cout << prefix << "- counters: frame=" << p.frameCounter
293 << ", draw=" << p.drawCounter << ", update=" << p.updateCounter
296 cout << prefix << "- on layer: ";
298 unsigned int* layerArray = NULL;
299 ilm_getLayerIDs(&layerCount, &layerArray);
300 for (unsigned int layerIndex = 0; layerIndex < layerCount; ++layerIndex)
302 unsigned int layerid = layerArray[layerIndex];
303 int surfaceCount = 0;
304 unsigned int* surfaceArray = NULL;
305 ilm_getSurfaceIDsOnLayer(layerid, &surfaceCount, &surfaceArray);
306 for (int surfaceIndex = 0; surfaceIndex < surfaceCount;
309 unsigned int id = surfaceArray[surfaceIndex];
312 cout << layerid << "(0x" << hex << layerid << dec << ") ";
321 unsigned int screenCount = 0;
322 unsigned int* screenArray = NULL;
324 ilm_getScreenIDs(&screenCount, &screenArray);
326 for (unsigned int screenIndex = 0; screenIndex < screenCount; ++screenIndex)
328 unsigned int screenid = screenArray[screenIndex];
329 printScreenProperties(screenid);
333 unsigned int* layerArray = NULL;
334 ilm_getLayerIDsOnScreen(screenid, &layerCount, &layerArray);
335 for (int layerIndex = 0; layerIndex < layerCount; ++layerIndex)
337 unsigned int layerid = layerArray[layerIndex];
338 printLayerProperties(layerid, " ");
341 int surfaceCount = 0;
342 unsigned int* surfaceArray = NULL;
343 ilm_getSurfaceIDsOnLayer(layerid, &surfaceCount, &surfaceArray);
344 for (int surfaceIndex = 0; surfaceIndex < surfaceCount; ++surfaceIndex)
346 unsigned int surfaceid = surfaceArray[surfaceIndex];
347 printSurfaceProperties(surfaceid, " ");