aboutsummaryrefslogtreecommitdiff
path: root/nx-X11
diff options
context:
space:
mode:
authorMihai Moldovan <ionic@ionic.de>2017-08-26 23:29:58 +0200
committerMihai Moldovan <ionic@ionic.de>2017-08-26 23:29:58 +0200
commitbc66da7141f51f0594334ad641272c7de7ff3cff (patch)
treee7cdb3d3ad3507dc10cc9639c263915e595b370f /nx-X11
parent7290aea3b77fe6603a62cc686a23e1dbca21de65 (diff)
parent4eade297b18ef977bdfc3522259bfd6e19d084b1 (diff)
downloadnx-libs-bc66da7141f51f0594334ad641272c7de7ff3cff.tar.gz
nx-libs-bc66da7141f51f0594334ad641272c7de7ff3cff.tar.bz2
nx-libs-bc66da7141f51f0594334ad641272c7de7ff3cff.zip
Merge branch 'sunweaver-pr/nxagent-render-cleanup' into 3.6.x
Attributes GH PR #488: https://github.com/ArcticaProject/nx-libs/pull/488
Diffstat (limited to 'nx-X11')
-rw-r--r--nx-X11/programs/Xserver/hw/nxagent/Imakefile1
-rw-r--r--nx-X11/programs/Xserver/hw/nxagent/Render.c249
2 files changed, 250 insertions, 0 deletions
diff --git a/nx-X11/programs/Xserver/hw/nxagent/Imakefile b/nx-X11/programs/Xserver/hw/nxagent/Imakefile
index 43dace09e..c5773215c 100644
--- a/nx-X11/programs/Xserver/hw/nxagent/Imakefile
+++ b/nx-X11/programs/Xserver/hw/nxagent/Imakefile
@@ -234,6 +234,7 @@ DEFINES = \
-DNXAGENT_CONSTRAINCURSOR \
-DNXAGENT_FONTCACHE_SIZE=50 \
-DNXAGENT_GLYPHCACHE -DNXAGENT_GLYPHCACHE_SIZE=50 \
+ -DNXAGENT_RENDER_CLEANUP \
-DNXAGENT_SHAPE2 \
-DNXAGENT_FIXKEYS \
-DNXAGENT_CLIPBOARD \
diff --git a/nx-X11/programs/Xserver/hw/nxagent/Render.c b/nx-X11/programs/Xserver/hw/nxagent/Render.c
index 1ce62b2f2..cf1d0ed07 100644
--- a/nx-X11/programs/Xserver/hw/nxagent/Render.c
+++ b/nx-X11/programs/Xserver/hw/nxagent/Render.c
@@ -202,6 +202,251 @@ Bool nxagentReconnectAllPicture(void *);
Bool nxagentDisconnectAllPicture(void);
+#ifdef NXAGENT_RENDER_CLEANUP
+
+#include <stdio.h>
+
+#define ROUNDUP(nbits, pad) ((((nbits) + ((pad)-1)) / (pad)) * ((pad)>>3))
+
+void
+nxagentCleanGlyphs(xGlyphInfo *gi,
+ int nglyphs,
+ CARD8 *images,
+ int depth,
+ Display *dpy)
+{
+ int widthInBits;
+ int bytesPerLine;
+ int bytesToClean;
+ int bitsToClean;
+ int widthInBytes;
+ int height = gi -> height;
+ register int i;
+ int j;
+
+ #ifdef DEBUG
+ fprintf(stderr, "nxagentCleanGlyphs: Found a Glyph with Depth %d, width %d, pad %d.\n",
+ depth, gi -> width, dpy -> bitmap_pad);
+ #endif
+
+ while (nglyphs > 0)
+ {
+ if (depth == 24)
+ {
+ widthInBits = gi -> width * 32;
+
+ bytesPerLine = ROUNDUP(widthInBits, dpy -> bitmap_pad);
+
+ bytesToClean = bytesPerLine * height;
+
+ #ifdef DUBUG
+ fprintf(stderr, "nxagentCleanGlyphs: Found glyph with depth 24, bytes to clean is %d"
+ "width in bits is %d bytes per line [%d] height [%d].\n", bytesToClean,
+ widthInBits, bytesPerLine, height);
+ #endif
+
+ if (dpy -> byte_order == LSBFirst)
+ {
+ for (i = 3; i < bytesToClean; i += 4)
+ {
+ images[i] = 0x00;
+ }
+ }
+ else
+ {
+ for (i = 0; i < bytesToClean; i += 4)
+ {
+ images[i] = 0x00;
+ }
+ }
+
+ #ifdef DUMP
+ fprintf(stderr, "nxagentCleanGlyphs: depth %d, bytesToClean %d, scanline: ", depth, bytesToClean);
+ for (i = 0; i < bytesPerLine; i++)
+ {
+ fprintf(stderr, "[%d]", images[i]);
+ }
+ fprintf(stderr,"\n");
+ #endif
+
+ images += bytesToClean;
+
+ gi++;
+
+ nglyphs--;
+ }
+ else if (depth == 1)
+ {
+ widthInBits = gi -> width;
+
+ bytesPerLine = ROUNDUP(widthInBits, dpy -> bitmap_pad);
+
+ bitsToClean = (bytesPerLine << 3) - (gi -> width);
+
+ #ifdef DEBUG
+ fprintf(stderr, "nxagentCleanGlyphs: Found glyph with depth 1, width [%d], height [%d], bitsToClean [%d],"
+ " bytesPerLine [%d].\n", gi -> width, height, bitsToClean, bytesPerLine);
+ #endif
+
+ bytesToClean = bitsToClean >> 3;
+
+ bitsToClean &= 7;
+
+ #ifdef DEBUG
+ fprintf(stderr, "nxagentCleanGlyphs: bitsToClean &=7 is %d, bytesToCLean is %d."
+ " byte_order is %d, bitmap_bit_order is %d.\n", bitsToClean, bytesToClean,
+ dpy -> byte_order, dpy -> bitmap_bit_order);
+ #endif
+
+ for (i = 1; i <= height; i++)
+ {
+ if (dpy -> byte_order == dpy -> bitmap_bit_order)
+ {
+ for (j = 1; j <= bytesToClean; j++)
+ {
+ images[i * bytesPerLine - j] = 0x00;
+
+ #ifdef DEBUG
+ fprintf(stderr, "nxagentCleanGlyphs: byte_order = bitmap_bit_orde, cleaning %d, i=%d, j=%d.\n"
+ , (i * bytesPerLine - j), i, j);
+ #endif
+
+ }
+ }
+ else
+ {
+ for (j = bytesToClean; j >= 1; j--)
+ {
+ images[i * bytesPerLine - j] = 0x00;
+
+ #ifdef DEBUG
+ fprintf(stderr, "nxagentCleanGlyphs: byte_order %d, bitmap_bit_order %d, cleaning %d, i=%d, j=%d.\n"
+ , dpy -> byte_order, dpy -> bitmap_bit_order, (i * bytesPerLine - j), i, j);
+ #endif
+
+ }
+ }
+
+ if (dpy -> bitmap_bit_order == MSBFirst)
+ {
+ images[i * bytesPerLine - j] &= 0xff << bitsToClean;
+
+ #ifdef DEBUG
+ fprintf(stderr, "nxagentCleanGlyphs: byte_order MSBFirst, cleaning %d, i=%d, j=%d.\n"
+ , (i * bytesPerLine - j), i, j);
+ #endif
+ }
+ else
+ {
+ images[i * bytesPerLine - j] &= 0xff >> bitsToClean;
+
+ #ifdef DEBUG
+ fprintf(stderr, "nxagentCleanGlyphs: byte_order LSBFirst, cleaning %d, i=%d, j=%d.\n"
+ , (i * bytesPerLine - j), i, j);
+ #endif
+ }
+ }
+
+ #ifdef DUMP
+ fprintf(stderr, "nxagentCleanGlyphs: depth %d, bytesToClean %d, scanline: ", depth, bytesToClean);
+ for (i = 0; i < bytesPerLine; i++)
+ {
+ fprintf(stderr, "[%d]", images[i]);
+ }
+ fprintf(stderr,"\n");
+ #endif
+
+ images += bytesPerLine * height;
+
+ gi++;
+
+ nglyphs--;
+ }
+ else if ((depth == 8) || (depth == 16) )
+ {
+ widthInBits = gi -> width * depth;
+
+ bytesPerLine = ROUNDUP(widthInBits, dpy -> bitmap_pad);
+
+ widthInBytes = (widthInBits >> 3);
+
+ bytesToClean = bytesPerLine - widthInBytes;
+
+ #ifdef DEBUG
+ fprintf(stderr, "nxagentCleanGlyphs: nglyphs is %d, width of glyph in bits is %d, in bytes is %d.\n",
+ nglyphs, widthInBits, widthInBytes);
+
+ fprintf(stderr, "nxagentCleanGlyphs: bytesPerLine is %d bytes, there are %d scanlines.\n", bytesPerLine, height);
+
+ fprintf(stderr, "nxagentCleanGlyphs: Bytes to clean for each scanline are %d.\n", bytesToClean);
+ #endif
+
+ if (bytesToClean > 0)
+ {
+ while (height > 0)
+ {
+ i = bytesToClean;
+
+ while (i > 0)
+ {
+ *(images + (bytesPerLine - i)) = 0;
+
+ #ifdef DEBUG
+ fprintf(stderr, "nxagentCleanGlyphs: cleaned a byte.\n");
+ #endif
+
+ i--;
+ }
+
+ #ifdef DUMP
+ fprintf(stderr, "nxagentCleanGlyphs: depth %d, bytesToClean %d, scanline: ", depth, bytesToClean);
+ for (i = 0; i < bytesPerLine; i++)
+ {
+ fprintf(stderr, "[%d]", images[i]);
+ }
+ fprintf(stderr,"\n");
+ #endif
+
+ images += bytesPerLine;
+
+ height--;
+ }
+ }
+
+ gi++;
+
+ nglyphs--;
+
+ #ifdef DEBUG
+ fprintf(stderr, "nxagentCleanGlyphs: Breaking Out.\n");
+ #endif
+ }
+ else if (depth == 32)
+ {
+ #ifdef DEBUG
+ fprintf(stderr, "nxagentCleanGlyphs: Found glyph with depth 32.\n");
+ #endif
+
+ gi++;
+
+ nglyphs--;
+ }
+ else
+ {
+ #ifdef WARNING
+ fprintf(stderr, "nxagentCleanGlyphs: Unrecognized glyph, depth is not 8/16/24/32, it appears to be %d.\n",
+ depth);
+ #endif
+
+ gi++;
+
+ nglyphs--;
+ }
+ }
+}
+
+#endif /* #ifdef NXAGENT_RENDER_CLEANUP */
+
void nxagentRenderExtensionInit()
{
int first_event, first_error;
@@ -2269,6 +2514,10 @@ void nxagentAddGlyphs(GlyphSetPtr glyphSet, Glyph *gids, xGlyphInfo *gi,
normalizedImages = images;
}
+ #ifdef NXAGENT_RENDER_CLEANUP
+ nxagentCleanGlyphs(gi, nglyphs, normalizedImages, glyphDepths[glyphSet -> fdepth], nxagentDisplay);
+ #endif /* NXAGENT_RENDER_CLEANUP */
+
XRenderAddGlyphs(nxagentDisplay,
glyphSet -> remoteID,
gids,