1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151
|
/*
* Copyright © 2006 Eric Anholt
*
* Permission to use, copy, modify, distribute, and sell this software and its
* documentation for any purpose is hereby granted without fee, provided that
* the above copyright notice appear in all copies and that both that
* copyright notice and this permission notice appear in supporting
* documentation, and that the name of Eric Anholt not be used in
* advertising or publicity pertaining to distribution of the software without
* specific, written prior permission. Eric Anholt makes no
* representations about the suitability of this software for any purpose. It
* is provided "as is" without express or implied warranty.
*
* ERIC ANHOLT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
* EVENT SHALL ERIC ANHOLT BE LIABLE FOR ANY SPECIAL, INDIRECT OR
* CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
* DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
* TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
* PERFORMANCE OF THIS SOFTWARE.
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "rendercheck.h"
static int
expecting_error(Display *dpy, XErrorEvent *event)
{
return TRUE;
}
/**
* Check SetPictureTransform on a source picture causing a crash.
*/
static Bool
bug7366_test_set_picture_transform(Display *dpy)
{
Picture source_pict;
XRenderColor color;
XTransform transform;
memset(&color, 0, sizeof(color));
source_pict = XRenderCreateSolidFill(dpy, &color);
memset(&transform, 0, sizeof(transform));
XRenderSetPictureTransform(dpy, source_pict, &transform);
XSync(dpy, FALSE);
XRenderFreePicture(dpy, source_pict);
return TRUE;
}
/**
* Check setting of AlphaMap to a source picture causing a crash.
*/
static Bool
bug7366_test_set_alpha_map(Display *dpy)
{
Picture source_pict, pict;
XRenderColor color;
Drawable pixmap;
XRenderPictureAttributes pa;
memset(&color, 0, sizeof(color));
source_pict = XRenderCreateSolidFill(dpy, &color);
pixmap = XCreatePixmap(dpy, DefaultRootWindow(dpy), 1, 1, 32);
pict = XRenderCreatePicture(dpy, pixmap,
XRenderFindStandardFormat(dpy, PictStandardARGB32), 0, NULL);
XSetErrorHandler(expecting_error);
pa.alpha_map = source_pict;
XRenderChangePicture(dpy, pict, CPAlphaMap, &pa);
XSync(dpy, FALSE);
XSetErrorHandler(NULL);
XFreePixmap(dpy, pixmap);
XRenderFreePicture(dpy, pict);
XRenderFreePicture(dpy, source_pict);
return TRUE;
}
/**
* Check SetPictureClipRectangles on a source potentially causing a crash.
*/
static Bool
bug7366_test_set_picture_clip_rectangles(Display *dpy)
{
Picture source_pict;
XRenderColor color;
XRectangle rectangle;
memset(&color, 0, sizeof(color));
source_pict = XRenderCreateSolidFill(dpy, &color);
memset(&rectangle, 0, sizeof(rectangle));
XSetErrorHandler(expecting_error);
XRenderSetPictureClipRectangles(dpy, source_pict, 0, 0, &rectangle, 1);
XSync(dpy, FALSE);
XSetErrorHandler(NULL);
XRenderFreePicture(dpy, source_pict);
return TRUE;
}
/**
* Check SetPictureFilter on a source potentially causing a crash.
*/
static Bool
bug7366_test_set_picture_filter(Display *dpy)
{
Picture source_pict;
XRenderColor color;
memset(&color, 0, sizeof(color));
source_pict = XRenderCreateSolidFill(dpy, &color);
XRenderSetPictureFilter(dpy, source_pict, "bilinear", NULL, 0);
XSync(dpy, FALSE);
XSetErrorHandler(NULL);
XRenderFreePicture(dpy, source_pict);
return TRUE;
}
Bool
bug7366_test(Display *dpy)
{
int maj, min;
/* Make sure we actually have gradients available */
XRenderQueryVersion(dpy, &maj, &min);
if (maj != 0 || min < 10)
return TRUE;
bug7366_test_set_picture_transform(dpy);
bug7366_test_set_alpha_map(dpy);
bug7366_test_set_picture_clip_rectangles(dpy);
bug7366_test_set_picture_filter(dpy);
/* If the server isn't gone, then we've succeeded. */
return TRUE;
}
|