xref: /haiku/src/bin/screeninfo.cpp (revision 97dfeb96704e5dbc5bec32ad7b21379d0125e031)
1 /*
2  * Copyright 2013-2014 Haiku, Inc. All rights reserved.
3  * Distributed under the terms of the MIT License.
4  *
5  * Authors:
6  *		Alexander von Gluck IV <kallisti5@unixzen.com>
7  */
8 
9 
10 #include <Application.h>
11 #include <Screen.h>
12 #include <stdio.h>
13 
14 
15 #define M(x)	{ B_##x, #x }
16 
17 struct ColorSpace {
18 	color_space space;
19 	const char* name;
20 };
21 
22 ColorSpace table[] =
23 {
24 	M(RGB32),
25 	M(RGB32),
26 	M(RGBA32),
27 	M(RGB24),
28 	M(RGB16),
29 	M(RGB15),
30 	M(RGBA15),
31 	M(CMAP8),
32 	M(GRAY8),
33 	M(GRAY1),
34 	M(RGB32_BIG),
35 	M(RGBA32_BIG),
36 	M(RGB24_BIG),
37 	M(RGB16_BIG),
38 	M(RGB15_BIG),
39 	M(RGBA15_BIG),
40 	M(YCbCr422),
41 	M(YCbCr411),
42 	M(YCbCr444),
43 	M(YCbCr420),
44 	M(YUV422),
45 	M(YUV411),
46 	M(YUV444),
47 	M(YUV420),
48 	M(YUV9),
49 	M(YUV12),
50 	M(UVL24),
51 	M(UVL32),
52 	M(UVLA32),
53 	M(LAB24),
54 	M(LAB32),
55 	M(LABA32),
56 	M(HSI24),
57 	M(HSI32),
58 	M(HSIA32),
59 	M(HSV24),
60 	M(HSV32),
61 	M(HSVA32),
62 	M(HLS24),
63 	M(HLS32),
64 	M(HLSA32),
65 	M(CMY24),
66 	M(CMY32),
67 	M(CMYA32),
68 	M(CMYK32),
69 	M(CMYA32),
70 	M(CMYK32)
71 };
72 
73 
74 void
75 print_supported_overlays()
76 {
77 	for (int32 i = 0; i < sizeof(table) / sizeof(table[0]); i++)
78 	{
79 		uint32 supportFlags = 0;
80 
81 		if (bitmaps_support_space(table[i].space, &supportFlags)
82 				&& (supportFlags & B_BITMAPS_SUPPORT_OVERLAY))
83 			printf("\t%s\n", table[i].name);
84 	}
85 }
86 
87 
88 int
89 main()
90 {
91 	// BScreen usage requires BApplication for AppServerLink
92 	BApplication app("application/x-vnd.Haiku-screen_info");
93 
94 	BScreen screen(B_MAIN_SCREEN_ID);
95 
96 	do {
97 		screen_id screenIndex = screen.ID();
98 		accelerant_device_info info;
99 
100 		// At the moment, screen.ID() is always 0;
101 		printf("Screen %" B_PRId32 ":", screen.ID().id);
102 		if (screen.GetDeviceInfo(&info) != B_OK) {
103 			printf(" unavailable\n");
104 		} else {
105 			printf(" attached\n");
106 			printf("  version: %" B_PRId32 "\n", info.version);
107 			printf("  name:    %s\n", info.name);
108 			printf("  chipset: %s\n", info.chipset);
109 			printf("  serial:  %s\n", info.serial_no);
110 			printf("  bitmap overlay colorspaces supported:\n");
111 			print_supported_overlays();
112 		}
113 	} while (screen.SetToNext() == B_OK);
114 
115 	return 0;
116 }
117