summaryrefslogtreecommitdiff
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
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>
-rw-r--r--do_blt.c30
-rw-r--r--do_tests.c24
2 files changed, 52 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)
{
diff --git a/do_tests.c b/do_tests.c
index f746c10..14fa328 100644
--- a/do_tests.c
+++ b/do_tests.c
@@ -1189,6 +1189,18 @@ Test test[] = {
InitPutImage, DoPutImage, MidCopyPix, EndGetImage,
V1_4FEATURE, ROP, 0,
{4, 500, "XY"}},
+ {"-putimagexybitmap10", "PutImage XYBitmap 10x10 square", NULL,
+ InitPutImage, DoPutImage, MidCopyPix, EndGetImage,
+ V1_4FEATURE, ROP, 0,
+ {4, 10, "XYBitmap"}},
+ {"-putimagexybitmap100", "PutImage XYBitmap 100x100 square", NULL,
+ InitPutImage, DoPutImage, MidCopyPix, EndGetImage,
+ V1_4FEATURE, ROP, 0,
+ {4, 100, "XYBitmap"}},
+ {"-putimagexybitmap500", "PutImage XYBitmap 500x500 square", NULL,
+ InitPutImage, DoPutImage, MidCopyPix, EndGetImage,
+ V1_4FEATURE, ROP, 0,
+ {4, 500, "XYBitmap"}},
#ifdef MITSHM
{"-shmput10", "ShmPutImage 10x10 square", NULL,
InitShmPutImage, DoShmPutImage, MidCopyPix, EndShmPutImage,
@@ -1214,6 +1226,18 @@ Test test[] = {
InitShmPutImage, DoShmPutImage, MidCopyPix, EndShmPutImage,
V1_4FEATURE, ROP, 0,
{4, 500, "XY"}},
+ {"-shmputxybitmap10", "ShmPutImage XYBitmap 10x10 square", NULL,
+ InitShmPutImage, DoShmPutImage, MidCopyPix, EndShmPutImage,
+ V1_4FEATURE, ROP, 0,
+ {4, 10, "XYBitmap"}},
+ {"-shmputxybitmap100", "ShmPutImage XYBitmap 100x100 square", NULL,
+ InitShmPutImage, DoShmPutImage, MidCopyPix, EndShmPutImage,
+ V1_4FEATURE, ROP, 0,
+ {4, 100, "XYBitmap"}},
+ {"-shmputxybitmap500", "ShmPutImage XYBitmap 500x500 square", NULL,
+ InitShmPutImage, DoShmPutImage, MidCopyPix, EndShmPutImage,
+ V1_4FEATURE, ROP, 0,
+ {4, 500, "XYBitmap"}},
{"-shmget10", "ShmGetImage 10x10 square", NULL,
InitShmGetImage, DoShmGetImage, NullProc, EndShmGetImage,
V1_2FEATURE, ROP, 0,