summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAaron Plattner <aplattner@nvidia.com>2009-11-28 10:58:41 -0800
committerAaron Plattner <aplattner@nvidia.com>2009-11-28 17:51:28 -0800
commitf9adc569498bd6612af9f9aae1717b13b7662a49 (patch)
tree555f46af953232899871562eb7c4bb9f5ceb6514
parentcbcda62580e0d5a58be9aeb924ece32e3f7a8a71 (diff)
Misc. updates.
Use the freedesktop.org logo with part of it translucent as the destination image. Load the dst image every time we start the test loop. Use a test image with a more interesting alpha channel (the X.Org logo with a white X). Add an option to create a 32-bit ARGB window instead of one with the default visual. In that mode, create the destination pictures with a format that has alpha so ops like PictOpIn will work correctly. Reduce the test time from 5 seconds to 2 seconds to make things go a little faster. Change the mask image to have colors so component alpha will look interesting.
-rw-r--r--images/fdo-translucent.pngbin0 -> 30128 bytes
-rw-r--r--images/mask.pngbin6170 -> 15138 bytes
-rw-r--r--images/xorg-small.pngbin0 -> 5660 bytes
-rw-r--r--main.c145
-rw-r--r--surface.c4
-rw-r--r--testscenarios.c12
-rw-r--r--utils.c30
-rw-r--r--utils.h1
8 files changed, 124 insertions, 68 deletions
diff --git a/images/fdo-translucent.png b/images/fdo-translucent.png
new file mode 100644
index 0000000..a7c6b88
--- /dev/null
+++ b/images/fdo-translucent.png
Binary files differ
diff --git a/images/mask.png b/images/mask.png
index 98c98c6..e3adf86 100644
--- a/images/mask.png
+++ b/images/mask.png
Binary files differ
diff --git a/images/xorg-small.png b/images/xorg-small.png
new file mode 100644
index 0000000..dd0e4e7
--- /dev/null
+++ b/images/xorg-small.png
Binary files differ
diff --git a/main.c b/main.c
index 0fe5d89..f59ee77 100644
--- a/main.c
+++ b/main.c
@@ -6,57 +6,59 @@
#include <stdio.h>
#include <signal.h>
#include <stdlib.h>
+#include <string.h>
#include "utils.h"
#include "surface.h"
#include "testscenarios.h"
-int win_w = 600;
+int win_w = 538;
int win_h = 450;
Display *disp = NULL;
Window win;
int test_type = AllTests;
+Bool useARGBWindow;
RenderOp all_render_ops[] = {
- {"PictOpClear", PictOpClear, 1},
- {"PictOpSrc", PictOpSrc, 1},
- {"PictOpDst", PictOpDst, 1},
- {"PictOpOver", PictOpOver, 1},
- {"PictOpOverReverse", PictOpOverReverse, 1},
- {"PictOpIn", PictOpIn, 1},
- {"PictOpInReverse", PictOpInReverse, 1},
- {"PictOpOut", PictOpOut, 1},
- {"PictOpOutReverse", PictOpOutReverse, 1},
- {"PictOpAtop", PictOpAtop, 1},
- {"PictOpAtopReverse", PictOpAtopReverse, 1},
- {"PictOpXor", PictOpXor, 1},
- {"PictOpAdd", PictOpAdd, 1},
- {"PictOpSaturate", PictOpSaturate, 1},
- {"PictOpDisjointClear", PictOpDisjointClear, 1},
- {"PictOpDisjointSrc", PictOpDisjointSrc, 0},
- {"PictOpDisjointDst", PictOpDisjointDst, 0},
- {"PictOpDisjointOver", PictOpDisjointOver, 0},
- {"PictOpDisjointOverReverse", PictOpDisjointOverReverse, 0},
- {"PictOpDisjointIn", PictOpDisjointIn, 0},
- {"PictOpDisjointInReverse", PictOpDisjointInReverse, 0},
- {"PictOpDisjointOut", PictOpDisjointOut, 0},
- {"PictOpDisjointOutReverse", PictOpDisjointOutReverse, 0},
- {"PictOpDisjointAtop", PictOpDisjointAtop, 0},
- {"PictOpDisjointAtopReverse", PictOpDisjointAtopReverse, 0},
- {"PictOpDisjointXor", PictOpDisjointXor, 0},
- {"PictOpConjointClear", PictOpConjointClear, 0},
- {"PictOpConjointSrc", PictOpConjointSrc, 0},
- {"PictOpConjointDst", PictOpConjointDst, 0},
- {"PictOpConjointOver", PictOpConjointOver, 0},
- {"PictOpConjointOverReverse", PictOpConjointOverReverse, 0},
- {"PictOpConjointIn", PictOpConjointIn, 0},
- {"PictOpConjointInReverse", PictOpConjointInReverse, 0},
- {"PictOpConjointOut", PictOpConjointOut, 0},
- {"PictOpConjointOutReverse", PictOpConjointOutReverse, 0},
- {"PictOpConjointAtop", PictOpConjointAtop, 0},
- {"PictOpConjointAtopReverse", PictOpConjointAtopReverse, 0},
- {"PictOpConjointXor", PictOpConjointXor, 0},
- {NULL, 0, 0}
+ {"Clear", PictOpClear, 1},
+ {"Src", PictOpSrc, 1},
+ {"Dst", PictOpDst, 1},
+ {"Over", PictOpOver, 1},
+ {"OverReverse", PictOpOverReverse, 1},
+ {"In", PictOpIn, 1},
+ {"InReverse", PictOpInReverse, 1},
+ {"Out", PictOpOut, 1},
+ {"OutReverse", PictOpOutReverse, 1},
+ {"Atop", PictOpAtop, 1},
+ {"AtopReverse", PictOpAtopReverse, 1},
+ {"Xor", PictOpXor, 1},
+ {"Add", PictOpAdd, 1},
+ {"Saturate", PictOpSaturate, 1},
+ {"DisjointClear", PictOpDisjointClear, 1},
+ {"DisjointSrc", PictOpDisjointSrc, 0},
+ {"DisjointDst", PictOpDisjointDst, 0},
+ {"DisjointOver", PictOpDisjointOver, 0},
+ {"DisjointOverReverse", PictOpDisjointOverReverse, 0},
+ {"DisjointIn", PictOpDisjointIn, 0},
+ {"DisjointInReverse", PictOpDisjointInReverse, 0},
+ {"DisjointOut", PictOpDisjointOut, 0},
+ {"DisjointOutReverse", PictOpDisjointOutReverse, 0},
+ {"DisjointAtop", PictOpDisjointAtop, 0},
+ {"DisjointAtopReverse", PictOpDisjointAtopReverse, 0},
+ {"DisjointXor", PictOpDisjointXor, 0},
+ {"ConjointClear", PictOpConjointClear, 0},
+ {"ConjointSrc", PictOpConjointSrc, 0},
+ {"ConjointDst", PictOpConjointDst, 0},
+ {"ConjointOver", PictOpConjointOver, 0},
+ {"ConjointOverReverse", PictOpConjointOverReverse, 0},
+ {"ConjointIn", PictOpConjointIn, 0},
+ {"ConjointInReverse", PictOpConjointInReverse, 0},
+ {"ConjointOut", PictOpConjointOut, 0},
+ {"ConjointOutReverse", PictOpConjointOutReverse, 0},
+ {"ConjointAtop", PictOpConjointAtop, 0},
+ {"ConjointAtopReverse", PictOpConjointAtopReverse, 0},
+ {"ConjointXor", PictOpConjointXor, 0},
+ {NULL, 0, 0}
};
@@ -76,9 +78,10 @@ static Picture createBackgroundPicture()
unsigned int w, h;
char *data;
Picture back;
- XRenderSurf *surf = xrender_surf_new(disp, win, PictStandardRGB24, 40, 40, False);
+ XRenderSurf *surf;
- readPng("images/bg2.png", &data, &w, &h);
+ readPng("images/fdo-translucent.png", &data, &w, &h);
+ surf = xrender_surf_new(disp, win, PictStandardARGB32, w, h, False);
xrender_surf_populate(disp, surf, w, h, data);
XRenderPictureAttributes pa;
pa.repeat = 1;
@@ -96,10 +99,10 @@ static Picture createBackgroundPicture()
void
main_loop(void)
{
- RenderOp current_op;
+ RenderOp *current_op;
Picture backgroundPict;
int xrenderMajor, xrenderMinor;
- int i = 0, j = 0;
+ int j = 0;
int numberOfScenarios = 0;
XRenderQueryVersion(disp, &xrenderMajor, &xrenderMinor);
@@ -113,33 +116,36 @@ main_loop(void)
backgroundPict = createBackgroundPicture();
- current_op = all_render_ops[i++];
TestScenario *scenarios = create_test_scenarios(disp, win, win_w, win_h, &numberOfScenarios);
XRenderComposite(disp, PictOpSrc, backgroundPict, None,
scenarios[0].dst->pic, 0, 0, 0, 0, 0, 0, win_w, win_h);
XFlush(disp);
- while (current_op.name)
+ for (current_op = &all_render_ops[0]; current_op->name; current_op++)
{
- printf("Test: %s\n", current_op.name);
+ if (current_op->disabled)
+ continue;
+
+ printf("Test: %s\n", current_op->name);
+
for (j = 0; j < numberOfScenarios; ++j) {
TestScenario *currentTest = &(scenarios[j]);
+
+ XRenderComposite(disp, PictOpSrc, backgroundPict, None,
+ currentTest->dst->pic, 0, 0, 0, 0, 0, 0, win_w,
+ win_h);
+
if (test_type != AllTests) {
if (!(currentTest->types & test_type))
continue;
}
- time_test(currentTest->name, test_oper, &current_op,
+ time_test(currentTest->name, test_oper, current_op,
currentTest->src, currentTest->mask, currentTest->dst);
- if ((j + 1) < numberOfScenarios)
- XRenderComposite(disp, PictOpSrc, backgroundPict, None,
- scenarios[j+1].dst->pic, 0, 0, 0, 0, 0, 0, win_w, win_h);
XSync(disp, False);
}
-
- current_op = all_render_ops[i++];
}
}
@@ -148,7 +154,9 @@ void
display_help()
{
printf("./xrenderbenchmark \n");
- printf("\t -help\tdisplays help\n");
+ printf("\t -help\t\tdisplays help\n");
+ printf("\t -argb\t\tuses a 32-bit ARGB window\n");
+ printf("\t -ops ops\tconfigures which ops to test\n");
printf("\t -tests type\truns only specified tests\n");
printf("\t\ttype can be: plain, alpha, mask, transformation and filter\n");
printf("\t \n");
@@ -164,6 +172,35 @@ process_args(int argc, char **argv)
if (!strcmp("-help", arg)) {
display_help();
exit(1);
+ } else if (!strcmp("-argb", arg)) {
+ useARGBWindow = True;
+ } else if (!strcmp("-ops", arg)) {
+ char *opname, *nextname;
+ RenderOp *op;
+
+ ++i;
+ if (i == argc) {
+ fprintf(stderr, "Error: -ops expected a comma-separated list of ops\n");
+ exit(1);
+ }
+
+ nextname = argv[i];
+
+ for (op = &all_render_ops[0]; op->name; op++)
+ op->disabled = True;
+
+ while ((opname = strsep(&nextname, ",")) != NULL) {
+ for (op = &all_render_ops[0]; op->name; op++) {
+ if (strcasecmp(op->name, opname) != 0)
+ continue;
+ op->disabled = False;
+ break;
+ }
+ if (!op->name) {
+ display_help();
+ exit(1);
+ }
+ }
} else if (!strcmp("-tests", arg)) {
++i;
if (i == argc) {
diff --git a/surface.c b/surface.c
index 5299276..022a935 100644
--- a/surface.c
+++ b/surface.c
@@ -31,11 +31,13 @@ xrender_surf_new(Display *disp, Drawable draw, int format, int w, int h, Bool ca
XRenderSurf *
xrender_surf_adopt(Display *disp, Drawable draw, int w, int h)
{
+ XWindowAttributes win_attr;
XRenderSurf *rs;
XRenderPictFormat *fmt;
XRenderPictureAttributes att;
- Visual *vis = DefaultVisual(disp, DefaultScreen(disp));
+ XGetWindowAttributes(disp, draw, &win_attr);
+ Visual *vis = win_attr.visual;
rs = (XRenderSurf*)calloc(1, sizeof(XRenderSurf));
fmt = XRenderFindVisualFormat(disp, vis);
diff --git a/testscenarios.c b/testscenarios.c
index 5ca04ff..9f51586 100644
--- a/testscenarios.c
+++ b/testscenarios.c
@@ -24,7 +24,7 @@ TestScenario * create_test_scenarios(Display *disp, Window win, int w, int h, in
current->mask = 0;
current->src = xrender_surf_new(disp, win, PictStandardRGB24, 128, 128, False);
populate_from_file(disp, current->dst, "images/bg1.png");
- populate_from_file(disp, current->src, "images/kde_gear_64.png");
+ populate_from_file(disp, current->src, "images/xorg-small.png");
current = &scenarios[currentNumber++];
@@ -34,7 +34,7 @@ TestScenario * create_test_scenarios(Display *disp, Window win, int w, int h, in
current->dst = xrender_surf_adopt(disp, win, w, h);
current->mask = 0;
current->src = xrender_surf_new(disp, win,PictStandardARGB32, 128, 128, False);
- populate_from_file(disp, current->src, "images/kde_gear_64_alpha.png");
+ populate_from_file(disp, current->src, "images/xorg-small.png");
current = &scenarios[currentNumber++];
/*********************************/
@@ -44,7 +44,7 @@ TestScenario * create_test_scenarios(Display *disp, Window win, int w, int h, in
current->mask = xrender_surf_new(disp, win,PictStandardARGB32, 128, 128, False);
current->src = xrender_surf_new(disp, win,PictStandardARGB32, 128, 128, False);
populate_from_file(disp, current->mask, "images/mask.png");
- populate_from_file(disp, current->src, "images/kde_gear_64_alpha.png");
+ populate_from_file(disp, current->src, "images/xorg-small.png");
current = &scenarios[currentNumber++];
/*********************************/
@@ -54,7 +54,7 @@ TestScenario * create_test_scenarios(Display *disp, Window win, int w, int h, in
current->mask = xrender_surf_new(disp, win,PictStandardARGB32, 128, 128, True);
current->src = xrender_surf_new(disp, win,PictStandardARGB32, 128, 128, False);
populate_from_file(disp, current->mask, "images/mask.png");
- populate_from_file(disp, current->src, "images/kde_gear_64_alpha.png");
+ populate_from_file(disp, current->src, "images/xorg-small.png");
current = &scenarios[currentNumber++];
/*********************************/
@@ -64,7 +64,7 @@ TestScenario * create_test_scenarios(Display *disp, Window win, int w, int h, in
current->mask = 0;
current->src = xrender_surf_new(disp, win, PictStandardRGB24,
128, 128, False);
- populate_from_file(disp, current->src, "images/kde_gear_64.png");
+ populate_from_file(disp, current->src, "images/xorg-small.png");
xrender_surf_prepare(disp, current->src, current->src->w, current->src->h, 1,
SurfaceNone);
@@ -75,7 +75,7 @@ TestScenario * create_test_scenarios(Display *disp, Window win, int w, int h, in
current->dst = xrender_surf_adopt(disp, win, w, h);
current->mask = 0;
current->src = xrender_surf_new(disp, win, PictStandardRGB24, 128, 128, False);
- populate_from_file(disp, current->src, "images/kde_gear_64.png");
+ populate_from_file(disp, current->src, "images/xorg-small.png");
xrender_surf_prepare(disp, current->src, current->src->w, current->src->h, 1,
SurfaceBilinear);
diff --git a/utils.c b/utils.c
index 22a6ede..4a3a2b0 100644
--- a/utils.c
+++ b/utils.c
@@ -17,6 +17,7 @@ extern int win_w;
extern int win_h;
extern Display *disp;
extern Window win;
+extern Bool useARGBWindow;
static const char *const FILLER =
"......................................................................";
@@ -42,7 +43,7 @@ time_test(char *description, void (*func) (int op, XRenderSurf *src, XRenderSurf
printf("\t\t %s", buf);
fflush(NULL);
- alarm(5);
+ alarm(2);
keep_running = 1;
while (keep_running) {
func(op->op, src, mask, dst);
@@ -67,9 +68,25 @@ setup_window(void)
{
XSetWindowAttributes att;
XClassHint *xch;
+ int scrn = DefaultScreen(disp);
+ int depth = DefaultDepth(disp, scrn);
+ Window parent = RootWindow(disp, scrn);
+ Visual *vis = DefaultVisual(disp, scrn);
+
+ if (useARGBWindow) {
+ // Override the default visual and find a 32-bit one instead.
+ XVisualInfo vis_info;
+
+ depth = 32;
+ if (!XMatchVisualInfo(disp, scrn, depth, TrueColor, &vis_info)) {
+ fprintf(stderr, "Failed to find a 32-bit TrueColor visual\n");
+ exit(1);
+ }
+ vis = vis_info.visual;
+ }
att.background_pixmap = None;
- att.colormap = DefaultColormap(disp, DefaultScreen(disp));
+ att.colormap = XCreateColormap(disp, parent, vis, AllocNone);
att.border_pixel = 0;
att.event_mask =
ButtonPressMask |
@@ -81,9 +98,8 @@ setup_window(void)
StructureNotifyMask |
KeyPressMask |
KeyReleaseMask;
- win = XCreateWindow(disp, RootWindow(disp, DefaultScreen(disp)),
- 0, 0, win_w, win_h, 0, DefaultDepth(disp, DefaultScreen(disp)),
- InputOutput, DefaultVisual(disp, DefaultScreen(disp)),
+ win = XCreateWindow(disp, parent, 0, 0, win_w, win_h, 0, depth,
+ InputOutput, vis,
CWColormap | CWBorderPixel | CWEventMask | CWBackPixmap,
&att);
XStoreName(disp, win, "XRender Benchmark");
@@ -99,8 +115,8 @@ setup_window(void)
void alarmhandler(int sig)
{
if (sig == SIGALRM) {
- printf ("%d frames in 5.0 seconds = %.3f FPS\n", frame_cnt,
- frame_cnt / 5.0);
+ printf ("%d frames in 2.0 seconds = %.3f FPS\n", frame_cnt,
+ frame_cnt / 2.0);
frame_cnt = 0;
keep_running = 0;
}
diff --git a/utils.h b/utils.h
index a3e2ba5..551100f 100644
--- a/utils.h
+++ b/utils.h
@@ -15,6 +15,7 @@ typedef struct _RenderOp
const char *name;
int op;
int baseOp;
+ Bool disabled;
} RenderOp;
double get_time(void);