summaryrefslogtreecommitdiff
path: root/utils.c
diff options
context:
space:
mode:
Diffstat (limited to 'utils.c')
-rw-r--r--utils.c30
1 files changed, 23 insertions, 7 deletions
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;
}