]>
Commit | Line | Data |
---|---|---|
ba84d019 | 1 | --- fbterm-1.2/src/screen.cpp.old 2008-12-15 20:27:32.000000000 +0100 |
2 | +++ fbterm-1.2/src/screen.cpp 2008-12-15 20:31:55.000000000 +0100 | |
3 | @@ -184,8 +184,6 @@ void Screen::switchVc(bool enter) | |
4 | ||
5 | void Screen::setupSysPalette(bool restore) | |
6 | { | |
7 | - if (vinfo.bits_per_pixel != 8) return; | |
8 | - | |
9 | static bool palette_saved = false; | |
10 | static u16 saved_red[NR_COLORS], saved_green[NR_COLORS], saved_blue[NR_COLORS]; | |
11 | fb_cmap cmap; | |
12 | @@ -212,17 +210,62 @@ void Screen::setupSysPalette(bool restor | |
13 | INIT_CMAP(saved_red, saved_green, saved_blue); | |
14 | ioctl(mFd, FBIOGETCMAP, &cmap); | |
15 | } | |
16 | + if (finfo.visual == FB_VISUAL_DIRECTCOLOR && vinfo.bits_per_pixel != 8) { | |
17 | + u16 *red, *green, *blue; | |
18 | + int rcols = 1 << vinfo.red.length; | |
19 | + int gcols = 1 << vinfo.green.length; | |
20 | + int bcols = 1 << vinfo.blue.length; | |
21 | + | |
22 | + /* Make our palette the length of the deepest color */ | |
23 | + int cols = (rcols > gcols ? rcols : gcols); | |
24 | + cols = (cols > bcols ? cols : bcols); | |
25 | + | |
26 | + red = new u16[cols]; | |
27 | + if (!red) | |
28 | + return; | |
29 | + for (int i = 0; i < rcols; i++) | |
30 | + red[i] = (65535 / (rcols - 1)) * i; | |
31 | + | |
32 | + green = new u16[cols]; | |
33 | + if (!green) { | |
34 | + delete[] red; | |
35 | + return; | |
36 | + } | |
37 | + for (int i = 0; i < gcols; i++) | |
38 | + green[i] = (65535 / (gcols - 1)) * i; | |
39 | + | |
40 | + blue = new u16[cols]; | |
41 | + if (!blue) { | |
42 | + delete[] red; | |
43 | + delete[] green; | |
44 | + return; | |
45 | + } | |
46 | + for (int i = 0; i < bcols; i++) | |
47 | + blue[i] = (65535 / (bcols - 1)) * i; | |
48 | + | |
49 | + cmap.start = 0; | |
50 | + cmap.len = cols; | |
51 | + cmap.red = red; | |
52 | + cmap.blue = blue; | |
53 | + cmap.green = green; | |
54 | + cmap.transp = NULL; | |
55 | + ioctl(mFd, FBIOPUTCMAP, &cmap); | |
56 | + delete[] red; | |
57 | + delete[] blue; | |
58 | + delete[] green; | |
59 | ||
60 | - u16 red[NR_COLORS], green[NR_COLORS], blue[NR_COLORS]; | |
61 | + } else { | |
62 | + u16 red[NR_COLORS], green[NR_COLORS], blue[NR_COLORS]; | |
63 | ||
64 | - for (u32 i = 0; i < NR_COLORS; i++) { | |
65 | - red[i] = palette[i].red << 8 | palette[i].red; | |
66 | - green[i] = palette[i].green << 8 | palette[i].green; | |
67 | - blue[i] = palette[i].blue << 8 | palette[i].blue; | |
68 | - } | |
69 | + for (u32 i = 0; i < NR_COLORS; i++) { | |
70 | + red[i] = palette[i].red << 8 | palette[i].red; | |
71 | + green[i] = palette[i].green << 8 | palette[i].green; | |
72 | + blue[i] = palette[i].blue << 8 | palette[i].blue; | |
73 | + } | |
74 | ||
75 | - INIT_CMAP(red, green, blue); | |
76 | - ioctl(mFd, FBIOPUTCMAP, &cmap); | |
77 | + INIT_CMAP(red, green, blue); | |
78 | + ioctl(mFd, FBIOPUTCMAP, &cmap); | |
79 | + } | |
80 | } | |
81 | } | |
82 |