Patch for feature request
Matthew Wakeling <[email protected]> Thu, 6 Jan 2011 12:22:51 +0000 (GMT)
| Newsgroups | gmane.comp.tex.xdvi.devel |
|---|---|
| Message-ID | <alpine.DEB.2.00.1101061212190.6632@localhost> |
Attached is a patch for feature request 701101 for xdvik. This implements subpixel rendering. Only a small amount of code needed to be changed, as much of the required stuff was already there - just not quite finished. There may be an issue with coloured text, which I may have time to look at later. Fixing it would involve putting the color_filter_image() step before the tinting step rather than after. As it stands, B&W text looks really quite nice on my LCD screen with the patched version. Thanks, Matthew -- Experience is what allows you to recognise a mistake the second time you make it. ------------------------------------------------------------------------------ Learn how Oracle Real Application Clusters (RAC) One Node allows customers to consolidate database storage, standardize their database environment, and, should the need arise, upgrade to a full multi-node Oracle RAC database without downtime or disruption http://p.sf.net/sfu/oracle-sfdevnl _______________________________________________ XDvi-core mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/xdvi-core
patch1
(text/plain, 5.2 KB)
? patch1
? utils
? texk/kpathsea/stamp-auto
? texk/kpathsea/stamp-paths
Index: texk/xdvik/dvi-draw.c
===================================================================
RCS file: /cvsroot/xdvi/xdvik/texk/xdvik/dvi-draw.c,v
retrieving revision 1.384
diff -r1.384 dvi-draw.c
74c74,75
< #define TRACE_AA1 1
---
> //#define TRACE_AA1 1
> #define TRACE_AA1 0
1025a1027,1069
> #ifdef RGB_ANTI_ALIASING
> /*
> * For RGB greyscaling, return the number of bits that are set in a given
> * region of width w and height, as if the given bits bitmap was stretched
> * by a factor of three. See also saample()
> */
> static int rgb_sample(bmUnitT *bits, int bytes_wide, int bit_skip, int w, int h)
> {
> bmUnitT *beg_ptr, *end_ptr, *curr_ptr;
> int x;
> int n, bit_shift;
>
> #if TRACE_AA
> fprintf(stderr, "sample: %d bytes wide, %d skip, %d w, %d h\n", bytes_wide, bit_skip, w, h);
> #endif
>
> n = 0;
> for (x = 0; x < w; x++) {
> beg_ptr = bits + ((bit_skip + x) / 3) / BMBITS;
> end_ptr = ADD(bits, h * bytes_wide);
>
> #if TRACE_AA
> fprintf(stderr, "beg_ptr: %p, end: %p\n", (void *)beg_ptr, (void *)end_ptr);
> #endif
>
> #ifdef WORDS_BIGENDIAN
> bit_shift = BMBITS - ((bit_skip + x) / 3) % BMBITS;
> #else
> bit_shift = ((bit_skip + x) / 3) % BMBITS;
> #endif
> #if TRACE_AA
> fprintf(stderr, "shift: %d\n", bit_shift);
> #endif
> for (curr_ptr = beg_ptr;
> curr_ptr < end_ptr;
> curr_ptr = ADD(curr_ptr, bytes_wide)) {
> n += (*curr_ptr >> bit_shift) & 1;
> }
> }
> return n;
> }
> #endif
>
1224c1268
< fprintf(stderr, "total: %d\n", arr_size);
---
> //fprintf(stderr, "total: %d\n", arr_size);
1329,1348d1372
< #ifdef RGB_ANTI_ALIASING
< if (resource.subpixel_order == SUBPIXEL_NONE)
< g->x2 = g->x / currwin.shrinkfactor;
< else {
< if (g->x < 0)
< g->x2 = (int)(g->x / 3.0 - 0.5) / currwin.shrinkfactor;
< else
< g->x2 = (int)(g->x / 3.0 + 0.5) / currwin.shrinkfactor;
< }
<
< if (resource.subpixel_order == SUBPIXEL_NONE)
< init_cols = g->x - g->x2 * currwin.shrinkfactor;
< else {
< if (g->x < 0)
< init_cols = (int)(g->x / 3.0 - 0.5) - g->x2 * currwin.shrinkfactor;
< else
< init_cols = (int)(g->x / 3.0 + 0.5) - g->x2 * currwin.shrinkfactor;
< fprintf(stderr, "g->x: %d, g->x2: %d, init_cols: %d\n", g->x, g->x2, init_cols);
< }
< #else
1351d1374
< #endif
1358,1372d1380
< #ifdef RGB_ANTI_ALIASING
<
< if (resource.subpixel_order == SUBPIXEL_NONE)
< g->bitmap2.w = g->x2 + ROUNDUP((int)g->bitmap.w - g->x, currwin.shrinkfactor);
< else {
< fprintf(stderr, "AFTER: g->x2: %d, init_cols: %d\n", g->x2, init_cols);
< /* fprintf(stderr, "g->bitmap.w / 3.0 + 0.5: %d; g->x / 3.0: %d; all: %d, %d\n", */
< /* (int)(g->bitmap.w / 3.0 + 0.5), */
< /* (int)(g->x / 3.0), */
< /* (int)((g->bitmap.w / 3.0 + 0.5) - g->x / 3.0), */
< /* g->x2 + (int)((((g->bitmap.w / 3.0 + 0.5) - g->x / 3.0) + currwin.shrinkfactor - 1) / currwin.shrinkfactor)); */
< g->bitmap2.w = g->x2 + ROUNDUP((int)((g->bitmap.w / 3.0 + 0.5) - g->x / 3.0), currwin.shrinkfactor);
< /* fprintf(stderr, "g->bitmap.w: %d\n", g->bitmap2.w); */
< }
< #else
1374d1381
< #endif
1433a1441,1447
> if (resource.subpixel_order != SUBPIXEL_NONE) {
> cols_left = g->bitmap.w * 3;
> } else {
> cols_left = g->bitmap.w;
> }
> #else
> cols_left = g->bitmap.w;
1438d1451
< cols_left = g->bitmap.w;
1444a1458,1466
> #ifdef RGB_ANTI_ALIASING
> if (resource.subpixel_order != SUBPIXEL_NONE) {
> thesample = rgb_sample(unshrunk_ptr, g->bitmap.bytes_wide,
> ((int)g->bitmap.w * 3) - cols_left, cols, rows);
> } else {
> thesample = sample(unshrunk_ptr, g->bitmap.bytes_wide,
> (int)g->bitmap.w - cols_left, cols, rows);
> }
> #else
1446a1469
> #endif
1496c1519
< fprintf(stderr, "pixel at %d\n", div);
---
> //fprintf(stderr, "pixel at %d\n", div);
1501c1524
< fprintf(stderr, "rest pixel at %d\n", div);
---
> //fprintf(stderr, "rest pixel at %d\n", div);
1942c1965,1966
< if (currwin.shrinkfactor == -1) {
---
> //if (currwin.shrinkfactor == -1) {
> if (currwin.shrinkfactor == 1) {
Index: texk/xdvik/main.c
===================================================================
RCS file: /cvsroot/xdvi/xdvik/texk/xdvik/main.c,v
retrieving revision 1.7
diff -r1.7 main.c
236c236
< /* subpixels */ "{rgb,bgr}[ i1 i2 i3]",
---
> /* subpixels */ "{rgb,bgr,none}[ i1 i2 i3]",
566c566
< else if (memicmp(resource.sub_pixels, "none", 3) == 0)
---
> else if (memicmp(resource.sub_pixels, "none", 4) == 0)
571c571
< "(possible values are: \"rgb\" or \"bgr\").",
---
> "(possible values are: \"rgb\", \"bgr\", or \"none\").",
573c573,574
< xdvi_exit(EXIT_FAILURE);
---
> resource.subpixel_order = SUBPIXEL_NONE;
> //xdvi_exit(EXIT_FAILURE);
Index: texk/xdvik/xdvi.c
===================================================================
RCS file: /cvsroot/xdvi/xdvik/texk/xdvik/xdvi.c,v
retrieving revision 1.465
diff -r1.465 xdvi.c
430c430
< offset(sub_pixels), XtRString, "Unknown"},
---
> offset(sub_pixels), XtRString, "none"},