Fix for 687442 GX_CINFO_SEP_LIN_UNKNOWN in display device
"Russell Lang" <[email protected]>
| Newsgroups | gmane.comp.printing.ghostscript.patches |
|---|---|
| Message-ID | <409C0B14.27531.4B475899@localhost> |
Dan, LOG MESSAGE: Enable separable_and_linear and separable for the display device. Fixes bug #687442. DETAILS: Enable separable_and_linear for gray, RGB and CMYK formats. The display device needs to explicitly call check_device_separable because it is closed and reopened when the callback is set, which causes linear_and_separable to be reset. Set the gray_index which is not set by check_device_separable. Prevent the unimplemented DISPLAY_ALPHA_FIRST and DISPLAY_ALPHA_LAST from being used. Make it clear that the display_map_rgb_color_rgb and display_map_color_rgb_rgb functions only work with 8bits/pixel. Russell Lang [email protected] Ghostgum Software Pty Ltd http://www.ghostgum.com.au/ diff -u l:/cvs/gs/src/gdevdsp.c src/gdevdsp.c --- l:/cvs/gs/src/gdevdsp.c Wed Apr 30 10:34:53 2003 +++ src/gdevdsp.c Fri May 07 11:55:45 2004 @@ -495,13 +495,9 @@ gx_color_value r = cv[0]; gx_color_value g = cv[1]; gx_color_value b = cv[2]; - int drop; + int drop = gx_color_value_bits - 8; gx_color_value red, green, blue; - if ((ddev->nFormat & DISPLAY_ALPHA_MASK) == DISPLAY_ALPHA_NONE) - drop = gx_color_value_bits - (dev->color_info.depth / 3); - else - drop = gx_color_value_bits - (dev->color_info.depth / 4); red = r >> drop; green = g >> drop; blue = b >> drop; @@ -537,13 +533,9 @@ gx_color_value prgb[3]) { gx_device_display *ddev = (gx_device_display *) dev; - uint bits_per_color; + uint bits_per_color = 8; uint color_mask; - if ((ddev->nFormat & DISPLAY_ALPHA_MASK) == DISPLAY_ALPHA_NONE) - bits_per_color = dev->color_info.depth / 3; - else - bits_per_color = dev->color_info.depth / 4; color_mask = (1 << bits_per_color) - 1; switch (ddev->nFormat & DISPLAY_ALPHA_MASK) { @@ -1092,6 +1084,7 @@ int bpc; /* bits per component */ int bpp; /* bits per pixel */ int maxvalue; + int i; switch (nFormat & DISPLAY_DEPTH_MASK) { case DISPLAY_DEPTH_1: @@ -1117,23 +1110,35 @@ } maxvalue = (1 << bpc) - 1; + switch (ddev->nFormat & DISPLAY_ALPHA_MASK) { + case DISPLAY_ALPHA_FIRST: + case DISPLAY_ALPHA_LAST: + /* Not implemented and unlikely to ever be implemented + * because they would interact with linear_and_separable + */ + return_error(gs_error_rangecheck); + } + switch (nFormat & DISPLAY_COLORS_MASK) { case DISPLAY_COLORS_NATIVE: switch (nFormat & DISPLAY_DEPTH_MASK) { case DISPLAY_DEPTH_1: /* 1bit/pixel, black is 1, white is 0 */ + dci.separable_and_linear = GX_CINFO_SEP_LIN_NONE; set_color_info(&dci, 1, 1, 1, 0); set_gray_color_procs(pdev, gx_b_w_gray_encode, gx_default_b_w_map_color_rgb); break; case DISPLAY_DEPTH_4: /* 4bit/pixel VGA color */ + dci.separable_and_linear = GX_CINFO_SEP_LIN_NONE; set_color_info(&dci, 3, 4, 3, 2); set_rgb_color_procs(pdev, display_map_rgb_color_device4, display_map_color_rgb_device4); break; case DISPLAY_DEPTH_8: /* 8bit/pixel 96 color palette */ + dci.separable_and_linear = GX_CINFO_SEP_LIN_NONE; set_color_info(&dci, 3, 8, 31, 3); set_rgb_color_procs(pdev, display_map_rgb_color_device8, display_map_color_rgb_device8); @@ -1141,16 +1146,22 @@ case DISPLAY_DEPTH_16: /* Windows 16-bit display */ /* Is maxgray = maxcolor = 63 correct? */ - set_color_info(&dci, 3, 16, 63, 63); + if ((ddev->nFormat & DISPLAY_555_MASK) + == DISPLAY_NATIVE_555) + set_color_info(&dci, 3, 16, 31, 31); + else + set_color_info(&dci, 3, 16, 63, 63); set_rgb_color_procs(pdev, display_map_rgb_color_device16, display_map_color_rgb_device16); break; default: return_error(gs_error_rangecheck); } + dci.gray_index = GX_CINFO_COMP_INDEX_UNKNOWN; break; case DISPLAY_COLORS_GRAY: set_color_info(&dci, 1, bpc, maxvalue, 0); + dci.gray_index = 0; if (bpc == 1) set_gray_color_procs(pdev, gx_default_gray_encode, gx_default_w_b_map_color_rgb); @@ -1164,6 +1175,7 @@ else bpp = bpc * 4; set_color_info(&dci, 3, bpp, maxvalue, maxvalue); + dci.gray_index = GX_CINFO_COMP_INDEX_UNKNOWN; if (((nFormat & DISPLAY_DEPTH_MASK) == DISPLAY_DEPTH_8) && ((nFormat & DISPLAY_ALPHA_MASK) == DISPLAY_ALPHA_NONE)) { if ((nFormat & DISPLAY_ENDIAN_MASK) == DISPLAY_BIGENDIAN) @@ -1182,6 +1194,7 @@ case DISPLAY_COLORS_CMYK: bpp = bpc * 4; set_color_info(&dci, 4, bpp, maxvalue, maxvalue); + dci.gray_index = 3; if ((nFormat & DISPLAY_ALPHA_MASK) != DISPLAY_ALPHA_NONE) return_error(gs_error_rangecheck); if ((nFormat & DISPLAY_ENDIAN_MASK) != DISPLAY_BIGENDIAN) @@ -1202,9 +1215,14 @@ /* restore old anti_alias info */ dci.anti_alias = ddev->color_info.anti_alias; + for (i=0; i<GX_DEVICE_COLOR_MAX_COMPONENTS; i++) { + /* Clear the mask bits, etc. */ + dci.comp_shift[i] = 0; + dci.comp_mask[i] = 0; + dci.comp_bits[i] = 0; + } ddev->color_info = dci; - /* Set the mask bits, etc. even though we are setting linear: unkown */ - set_linear_color_bits_mask_shift(pdev); + check_device_separable(pdev); ddev->nFormat = nFormat; return 0; _______________________________________________ gs-code-review mailing list [email protected] http://www.ghostscript.com/mailman/listinfo/gs-code-review