summaryrefslogtreecommitdiff
path: root/do_blt.c
diff options
context:
space:
mode:
authorKeith Packard <keithp@keithp.com>2016-10-03 15:09:20 -0700
committerAlan Coopersmith <alan.coopersmith@oracle.com>2024-04-13 15:26:38 -0700
commitbd6b8109b34e2effbe071b7881aebb8a7cfac53d (patch)
tree6ee59bfc4ae3889e1b7551b0a86daa6397b24f56 /do_blt.c
parentba26e97853d209663de8527cfefee16afe3b959b (diff)
Add xybitmap putimage tests
Signed-off-by: Keith Packard <keithp@keithp.com> Part-of: <https://gitlab.freedesktop.org/xorg/test/x11perf/-/merge_requests/1>
Diffstat (limited to 'do_blt.c')
-rw-r--r--do_blt.c30
1 files changed, 28 insertions, 2 deletions
diff --git a/do_blt.c b/do_blt.c
index 536bd64..ba0c7c7 100644
--- a/do_blt.c
+++ b/do_blt.c
@@ -215,11 +215,37 @@ InitImage(XParms xp, Parms p, int64_t reps, long pm)
/* Create image to stuff bits into */
image = XGetImage(xp->d, xp->w, 0, 0, WIDTH, HEIGHT, pm,
- p->font==NULL?ZPixmap:XYPixmap);
+ p->font==NULL ? ZPixmap : (strcmp(p->font, "XY") == 0? XYPixmap : ZPixmap));
if(image==NULL){
printf("XGetImage failed\n");
return False;
}
+ if (p->font && !strcmp(p->font, "XYBitmap")) {
+ int bytes_per_line = (WIDTH + 31) / 8;
+ char *data = malloc (bytes_per_line * HEIGHT);
+ XImage *new = XCreateImage(xp->d, xp->vinfo.visual, 1, XYBitmap, 0,
+ data, WIDTH, HEIGHT, 32, bytes_per_line);
+ int x, y;
+ unsigned long zero_pixel;
+ int has_zero = 0;
+
+ for (y = 0; y < HEIGHT; y++)
+ for (x = 0; x < WIDTH; x++) {
+ unsigned long src_pixel = XGetPixel(image, x, y);
+ unsigned long dst_pixel = 0;
+ if (!has_zero) {
+ zero_pixel = src_pixel;
+ has_zero = 1;
+ }
+ if (src_pixel == zero_pixel)
+ dst_pixel = 0;
+ else
+ dst_pixel = 1;
+ XPutPixel(new, x, y, dst_pixel);
+ }
+ XDestroyImage(image);
+ image = new;
+ }
return reps;
}
@@ -394,7 +420,7 @@ InitShmImage(XParms xp, Parms p, int64_t reps, Bool read_only)
shm_image = *image;
image_size = image->bytes_per_line * image->height;
/* allow XYPixmap choice: */
- if(p->font)image_size *= xp->vinfo.depth;
+ if(p->font && strcmp(p->font, "XYBitmap") != 0) image_size *= xp->vinfo.depth;
shm_info.shmid = shmget(IPC_PRIVATE, image_size, IPC_CREAT|0777);
if (shm_info.shmid < 0)
{