diff options
author | Zack Rusin <zack@ppc64.localdomain> | 2006-03-17 18:13:42 -0500 |
---|---|---|
committer | Zack Rusin <zack@ppc64.localdomain> | 2006-03-17 18:13:42 -0500 |
commit | a3a1c41a28915ecf81567f35a27040fd7275b9c5 (patch) | |
tree | a36abfebaa3bf24a5e79ef6f260b93f5707238cb | |
parent | 2568832d52ea08463fb8ec41fce99ab9b2e29f2e (diff) |
add some command line options and example with a mask
-rw-r--r-- | images/mask.png | bin | 0 -> 6170 bytes | |||
-rw-r--r-- | main.c | 63 | ||||
-rw-r--r-- | testscenarios.c | 50 | ||||
-rw-r--r-- | testscenarios.h | 11 |
4 files changed, 103 insertions, 21 deletions
diff --git a/images/mask.png b/images/mask.png Binary files differnew file mode 100644 index 0000000..98c98c6 --- /dev/null +++ b/images/mask.png @@ -15,7 +15,7 @@ int win_w = 600; int win_h = 450; Display *disp = NULL; Window win; - +int test_type = AllTests; RenderOp all_render_ops[] = { {"PictOpClear", PictOpClear, 1}, @@ -124,8 +124,14 @@ main_loop(void) { printf("Test: %s\n", current_op.name); for (j = 0; j < numberOfScenarios; ++j) { - time_test(scenarios[j].name, test_oper, ¤t_op, - scenarios[j].src, scenarios[j].mask, scenarios[j].dst); + TestScenario *currentTest = &(scenarios[j]); + if (test_type != AllTests) { + if (!(currentTest->types & test_type)) + continue; + } + + time_test(currentTest->name, test_oper, ¤t_op, + currentTest->src, currentTest->mask, currentTest->dst); if ((j + 1) < numberOfScenarios) XRenderComposite(disp, PictOpSrc, backgroundPict, None, @@ -137,9 +143,60 @@ main_loop(void) } } + +void +display_help() +{ + printf("./xrenderbenchmark \n"); + printf("\t -help\tdisplays help\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"); +} + +void +process_args(int argc, char **argv) +{ + int i; + for (i = 1; i < argc; ++i) { + char *arg = argv[i]; + + if (!strcmp("-help", arg)) { + display_help(); + exit(1); + } else if (!strcmp("-tests", arg)) { + ++i; + if (i == argc) { + fprintf(stderr, "Error: Must specify a test type with -tests option\n"); + exit(1); + } + arg = argv[i]; + if (!strcmp("plain", arg)) { + test_type = PlainTest; + } else if (!strcmp("alpha", arg)) { + test_type = AlphaTest; + } else if (!strcmp("mask", arg)) { + test_type = MaskTest; + } else if (!strcmp("transformation", arg)) { + test_type = TransformationTest; + } else if (!strcmp("filter", arg)) { + test_type = FilterTest; + } else { + fprintf(stderr, "Unrecognized test type: '%s'\n", arg); + } + } else { + display_help(); + fprintf(stderr, "Unrecognized option: '%s'\n", arg); + exit(1); + } + } + +} + int main(int argc, char **argv) { + process_args(argc, argv); disp = XOpenDisplay(0); if (!disp) { fprintf(stderr, "Error: Cannot connect to display!\n"); diff --git a/testscenarios.c b/testscenarios.c index 25c59bf..f5f9de6 100644 --- a/testscenarios.c +++ b/testscenarios.c @@ -12,34 +12,47 @@ TestScenario * create_test_scenarios(Display *disp, Window win, int w, int h, in { TestScenario *scenarios; - *number = 4; + *number = 5; scenarios = (TestScenario*)malloc(sizeof(TestScenario) * (*number)); int currentNumber = 0; TestScenario *current = &scenarios[currentNumber++]; /*********************************/ - current->name = strdup("Plain"); - current->dst = xrender_surf_adopt(disp, win, w, h); - current->mask = 0; - current->src = xrender_surf_new(disp, win, PictStandardRGB24, 128, 128); + current->types = PlainTest; + current->name = strdup("Plain"); + current->dst = xrender_surf_adopt(disp, win, w, h); + current->mask = 0; + current->src = xrender_surf_new(disp, win, PictStandardRGB24, 128, 128); populate_from_file(disp, current->dst, "images/bg1.png"); populate_from_file(disp, current->src, "images/kde_gear_64.png"); current = &scenarios[currentNumber++]; /*********************************/ - current->name = strdup("Plain With Alpha"); - current->dst = xrender_surf_adopt(disp, win, w, h); - current->mask = 0; - current->src = xrender_surf_new(disp, win,PictStandardARGB32, 128, 128); - populate_from_file(disp, current->src, "images/kde_gear_64_alpha.png"); + current->types = PlainTest | AlphaTest; + current->name = strdup("Plain With Alpha"); + current->dst = xrender_surf_adopt(disp, win, w, h); + current->mask = 0; + current->src = xrender_surf_new(disp, win,PictStandardARGB32, 128, 128); + populate_from_file(disp, current->src, "images/kde_gear_64_alpha.png"); current = &scenarios[currentNumber++]; /*********************************/ - current->name = strdup("Transformation"); - current->dst = xrender_surf_adopt(disp, win, w, h); - current->mask = 0; - current->src = xrender_surf_new(disp, win, PictStandardRGB24, + current->types = PlainTest | AlphaTest | MaskTest; + current->name = strdup("Plain With Alpha And Mask"); + current->dst = xrender_surf_adopt(disp, win, w, h); + current->mask = xrender_surf_new(disp, win,PictStandardARGB32, 128, 128); + current->src = xrender_surf_new(disp, win,PictStandardARGB32, 128, 128); + populate_from_file(disp, current->mask, "images/mask.png"); + populate_from_file(disp, current->src, "images/kde_gear_64_alpha.png"); + + current = &scenarios[currentNumber++]; + /*********************************/ + current->types = TransformationTest; + current->name = strdup("Transformation"); + current->dst = xrender_surf_adopt(disp, win, w, h); + current->mask = 0; + current->src = xrender_surf_new(disp, win, PictStandardRGB24, 128, 128); populate_from_file(disp, current->src, "images/kde_gear_64.png"); xrender_surf_prepare(disp, current->src, current->src->w, current->src->h, 1, @@ -47,10 +60,11 @@ TestScenario * create_test_scenarios(Display *disp, Window win, int w, int h, in current = &scenarios[currentNumber++]; /*********************************/ - current->name = strdup("Transformation/Bilinear filter"); - current->dst = xrender_surf_adopt(disp, win, w, h); - current->mask = 0; - current->src = xrender_surf_new(disp, win, PictStandardRGB24, 128, 128); + current->types = TransformationTest | FilterTest; + current->name = strdup("Transformation/Bilinear filter"); + current->dst = xrender_surf_adopt(disp, win, w, h); + current->mask = 0; + current->src = xrender_surf_new(disp, win, PictStandardRGB24, 128, 128); populate_from_file(disp, current->src, "images/kde_gear_64.png"); xrender_surf_prepare(disp, current->src, current->src->w, current->src->h, 1, SurfaceBilinear); diff --git a/testscenarios.h b/testscenarios.h index d808dd9..de031bc 100644 --- a/testscenarios.h +++ b/testscenarios.h @@ -4,8 +4,19 @@ #include "surface.h" #include <X11/extensions/Xrender.h> +typedef enum _TestType { + PlainTest = 1 << 0, + AlphaTest = 1 << 1, + MaskTest = 1 << 2, + TransformationTest = 1 << 3, + FilterTest = 1 << 4, + AllTests +} TestType; + + typedef struct _TestScenario { + int types; char *name; XRenderSurf *src; XRenderSurf *dst; |