| @@ -1,58 +1,60 @@ | | | @@ -1,58 +1,60 @@ |
1 | $NetBSD: patch-x.c,v 1.1 2020/11/15 20:36:37 nat Exp $ | | 1 | $NetBSD: patch-x.c,v 1.2 2021/06/29 15:13:24 fcambus Exp $ |
| | | 2 | |
2 | Fix display for color depths lower than 4bpp. | | 3 | Fix display for color depths lower than 4bpp. |
3 | --- x.c.orig 2019-08-28 13:01:46.000000000 +0000 | | 4 | |
| | | 5 | --- x.c.orig 2021-01-27 20:31:20.000000000 +0000 |
4 | +++ x.c | | 6 | +++ x.c |
5 | @@ -1663,12 +1663,12 @@ static unsigned char *x_init_driver(unsi | | 7 | @@ -1665,12 +1665,12 @@ static unsigned char *x_init_driver(unsi |
6 | | | 8 | |
7 | /* find best visual */ | | 9 | /* find best visual */ |
8 | { | | 10 | { |
9 | - static_const unsigned char depths[] = {24, 16, 15, 8, 4}; | | 11 | - static_const unsigned char depths[] = {24, 16, 15, 8, 4}; |
10 | - static_const int classes[] = {TrueColor, PseudoColor, StaticColor}; /* FIXME: dodelat DirectColor */ | | 12 | - static_const int classes[] = {TrueColor, PseudoColor, StaticColor}; /* FIXME: dodelat DirectColor */ |
11 | + static_const unsigned char depths[] = {24, 16, 15, 8, 4, 2, 1}; | | 13 | + static_const unsigned char depths[] = {24, 16, 15, 8, 4, 2, 1}; |
12 | + static_const int classes[] = {TrueColor, PseudoColor, StaticColor, StaticGray}; /* FIXME: dodelat DirectColor */ | | 14 | + static_const int classes[] = {TrueColor, PseudoColor, StaticColor, StaticGray}; /* FIXME: dodelat DirectColor */ |
13 | unsigned a, b; | | 15 | unsigned a, b; |
14 | | | 16 | |
15 | for (a = 0; a < array_elements(depths); a++) for (b = 0; b < array_elements(classes); b++) { | | 17 | for (a = 0; a < array_elements(depths); a++) for (b = 0; b < array_elements(classes); b++) { |
16 | - if ((classes[b] == PseudoColor || classes[b] == StaticColor) && depths[a] > 8) | | 18 | - if ((classes[b] == PseudoColor || classes[b] == StaticColor) && depths[a] > 8) |
17 | + if ((classes[b] == PseudoColor || classes[b] == StaticColor || classes[b] == StaticGray) && depths[a] > 8) | | 19 | + if ((classes[b] == PseudoColor || classes[b] == StaticColor || classes[b] == StaticGray) && depths[a] > 8) |
18 | continue; | | 20 | continue; |
19 | if (classes[b] == TrueColor && depths[a] <= 8) | | 21 | if (classes[b] == TrueColor && depths[a] <= 8) |
20 | continue; | | 22 | continue; |
21 | @@ -1696,11 +1696,13 @@ bytes_per_pixel_found: | | 23 | @@ -1698,11 +1698,13 @@ bytes_per_pixel_found: |
22 | /* test misordered flag */ | | 24 | /* test misordered flag */ |
23 | /*debug("x_depth %d, x_bitmap_bpp %d %lx %lx %lx %s", x_depth, x_bitmap_bpp, vinfo.red_mask, vinfo.green_mask, vinfo.blue_mask, x_bitmap_bit_order == MSBFirst ? "MSBFirst" : "LSBFirst");*/ | | 25 | /*debug("x_depth %d, x_bitmap_bpp %d %lx %lx %lx %s", x_depth, x_bitmap_bpp, vinfo.red_mask, vinfo.green_mask, vinfo.blue_mask, x_bitmap_bit_order == MSBFirst ? "MSBFirst" : "LSBFirst");*/ |
24 | switch (x_depth) { | | 26 | switch (x_depth) { |
25 | + case 1: | | 27 | + case 1: |
26 | + case 2: | | 28 | + case 2: |
27 | case 4: | | 29 | case 4: |
28 | case 8: | | 30 | case 8: |
29 | if (x_bitmap_bpp != 1) | | 31 | if (x_bitmap_bpp != 1) |
30 | break; | | 32 | break; |
31 | - if (vinfo.class == StaticColor || vinfo.class == PseudoColor) { | | 33 | - if (vinfo.class == StaticColor || vinfo.class == PseudoColor) { |
32 | + if (vinfo.class == StaticColor || vinfo.class == PseudoColor || vinfo.class == StaticGray) { | | 34 | + if (vinfo.class == StaticColor || vinfo.class == PseudoColor || vinfo.class == StaticGray) { |
33 | misordered = 0; | | 35 | misordered = 0; |
34 | goto visual_found; | | 36 | goto visual_found; |
35 | } | | 37 | } |
36 | @@ -1755,7 +1757,7 @@ visual_found: | | 38 | @@ -1757,7 +1759,7 @@ visual_found: |
37 | x_driver.flags &= ~GD_SWITCH_PALETTE; | | 39 | x_driver.flags &= ~GD_SWITCH_PALETTE; |
38 | x_have_palette = 0; | | 40 | x_have_palette = 0; |
39 | x_use_static_color_table = 0; | | 41 | x_use_static_color_table = 0; |
40 | - if (vinfo.class == StaticColor) { | | 42 | - if (vinfo.class == StaticColor) { |
41 | + if (vinfo.class == StaticColor || vinfo.class == StaticGray) { | | 43 | + if (vinfo.class == StaticColor || vinfo.class == StaticGray) { |
42 | if (x_depth > 8) | | 44 | if (x_depth > 8) |
43 | return stracpy(cast_uchar "Static color supported for up to 8-bit depth.\n"); | | 45 | return stracpy(cast_uchar "Static color supported for up to 8-bit depth.\n"); |
44 | if ((err = x_query_palette())) | | 46 | if ((err = x_query_palette())) |
45 | @@ -2219,13 +2221,32 @@ static void x_translate_colors(unsigned | | 47 | @@ -2221,13 +2223,32 @@ static void x_translate_colors(unsigned |
46 | return; | | 48 | return; |
47 | } | | 49 | } |
48 | | | 50 | |
49 | + unsigned char *mypic = data; | | 51 | + unsigned char *mypic = data; |
50 | if (x_use_static_color_table) { | | 52 | if (x_use_static_color_table) { |
51 | for (j = 0; j < y; j++) { | | 53 | for (j = 0; j < y; j++) { |
52 | for (i = 0; i < x; i++) | | 54 | for (i = 0; i < x; i++) |
53 | data[i] = static_color_table[data[i]]; | | 55 | data[i] = static_color_table[data[i]]; |
54 | data += skip; | | 56 | data += skip; |
55 | } | | 57 | } |
56 | - return; | | 58 | - return; |
57 | + } | | 59 | + } |
58 | + if (x_depth == 1) { | | 60 | + if (x_depth == 1) { |