void nop();
void create_destroy_pixmap();
void create_destroy_picture();
+void random_color(XRenderColor *color, int alpha);
void fill_rectangle();
void composite_trapezoid();
void draw_string8();
+void copy_area();
+void composite_copy_area();
Display *dpy;
Window wnd;
Pixmap pxm;
+GC gc;
int depth;
XRenderPictFormat *pfmt;
Picture pict;
XftDraw *ftdraw;
char *text;
unsigned textlen;
+int copymode;
int main(int argc, char **argv)
{
Visual *visual;
Colormap cmap;
Window root;
- Pixmap srcpxm;
XRenderPictFormat pft;
- XRenderPictFormat *pfmt32;
- XRenderPictureAttributes pattr;
char *test_name=NULL;
unsigned batch=3000;
unsigned time=1000;
FILE *in=NULL, *out;
float total=0;
float weight=1.0;
- XRenderColor color;
int prec;
if(argc>=2)
pfmt=XRenderFindFormat(dpy, PictFormatDepth, &pft, 1);
pict=XRenderCreatePicture(dpy, wnd, pfmt, 0, NULL);
- pfmt32=XRenderFindStandardFormat(dpy, PictStandardARGB32);
- srcpxm=XCreatePixmap(dpy, wnd, 1, 1, 32);
- pattr.repeat=RepeatNormal;
- srcpict=XRenderCreatePicture(dpy, srcpxm, pfmt32, CPRepeat, &pattr);
-
- color.red=0xFFFF;
- color.green=0xFFFF;
- color.blue=0xFFFF;
- XRenderFillRectangle(dpy, PictOpSrc, srcpict, &color, 0, 0, 1, 1);
-
op=PictOpSrc;
while(1)
{
op=PictOpSrc;
else if(!strcmp(delim+1, "add"))
op=PictOpAdd;
+ else
+ fprintf(stderr, "Unknown operator '%s'\n", delim+1);
}
else if(!strncmp(line, "weight", delim-line))
weight=strtod(delim+1, NULL);
+ else if(!strncmp(line, "copymode", delim-line))
+ {
+ if(!strcmp(delim+1, "pxm>wnd"))
+ copymode=0;
+ else if(!strcmp(delim+1, "pxm>pxm"))
+ copymode=1;
+ else if(!strcmp(delim+1, "wnd>wnd"))
+ copymode=2;
+ else if(!strcmp(delim+1, "wnd>pxm"))
+ copymode=3;
+ else
+ fprintf(stderr, "Unknown copy mode '%s'\n", delim+1);
+ }
else
fprintf(stderr, "Unknown assignment '%s'\n", line);
continue;
{
if(!strncmp(line, "run", delim-line))
{
- printf("%s:\n", test_name);
Result res;
unsigned size=0;
+ printf("%s:\n", test_name);
if(!strcmp(delim+1, "rect") || !strcmp(delim+1, "rectangle"))
{
size=width*height;
}
else if(!strcmp(delim+1, "trapezoid"))
{
+ XRenderColor color;
+ random_color(&color, 0);
size=width*height;
+ srcpict=XRenderCreateSolidFill(dpy, &color);
res=measure(composite_trapezoid, batch, time, type);
+ XRenderFreePicture(dpy, srcpict);
}
else if(!strcmp(delim+1, "text"))
{
res=measure(draw_string8, batch, time, type);
XftDrawDestroy(ftdraw);
}
+ else if(!strcmp(delim+1, "copy"))
+ {
+ size=width*height;
+ pxm=XCreatePixmap(dpy, wnd, 640, 480, depth);
+ gc=XCreateGC(dpy, wnd, 0, NULL);
+ XCopyArea(dpy, wnd, pxm, gc, 0, 0, 640, 480, 0, 0);
+ res=measure(copy_area, batch, time, type);
+ XFreeGC(dpy, gc);
+ XFreePixmap(dpy, pxm);
+ }
+ else if(!strcmp(delim+1, "composite"))
+ {
+ size=width*height;
+ pxm=XCreatePixmap(dpy, wnd, 640, 480, depth);
+ gc=XCreateGC(dpy, wnd, 0, NULL);
+ XCopyArea(dpy, wnd, pxm, gc, 0, 0, 640, 480, 0, 0);
+ XFreeGC(dpy, gc);
+ srcpict=XRenderCreatePicture(dpy, pxm, pfmt, 0, NULL);
+ res=measure(composite_copy_area, batch, time, type);
+ XFreePixmap(dpy, pxm);
+ }
else if(!strcmp(delim+1, "pixmap"))
res=measure(create_destroy_pixmap, batch, time, type);
else if(!strcmp(delim+1, "picture"))
float stddev=0;
nbatches=batch;
- speed=measure(func, 100, 100, NORMAL).ops_per_sec;
+ i=time/nbatches;
+ speed=measure(func, 100, (i<1000 ? i<100 ? 100 : i : 1000), NORMAL).ops_per_sec;
batch=(long long)speed*time/1000/nbatches;
data=(unsigned *)malloc(nbatches*sizeof(unsigned));
y=rand()%(481-extents.height);
XftDrawString8(ftdraw, &ftcolor, font, x, y, textptr, textlen);
}
+
+void copy_area()
+{
+ int x1, y1;
+ int x2, y2;
+
+ x1=rand()%(641-width);
+ y1=rand()%(481-height);
+ x2=rand()%(641-width);
+ y2=rand()%(481-height);
+
+ switch(copymode)
+ {
+ case 0: XCopyArea(dpy, pxm, wnd, gc, x1, y1, width, height, x2, y2); break;
+ case 1: XCopyArea(dpy, pxm, pxm, gc, x1, y1, width, height, x2, y2); break;
+ case 2: XCopyArea(dpy, wnd, wnd, gc, x1, y1, width, height, x2, y2); break;
+ case 3: XCopyArea(dpy, wnd, pxm, gc, x1, y1, width, height, x2, y2); break;
+ }
+}
+
+void composite_copy_area()
+{
+ int x1, y1;
+ int x2, y2;
+
+ x1=rand()%(641-width);
+ y1=rand()%(481-height);
+ x2=rand()%(641-width);
+ y2=rand()%(481-height);
+
+ switch(copymode)
+ {
+ case 0: XRenderComposite(dpy, op, srcpict, None, pict, x1, y1, 0, 0, x2, y2, width, height); break;
+ case 1: XRenderComposite(dpy, op, srcpict, None, srcpict, x1, y1, 0, 0, x2, y2, width, height); break;
+ case 2: XRenderComposite(dpy, op, pict, None, pict, x1, y1, 0, 0, x2, y2, width, height); break;
+ case 3: XRenderComposite(dpy, op, pict, None, srcpict, x1, y1, 0, 0, x2, y2, width, height); break;
+ }
+}