/* $XConsortium: rnd_trans.c,v 1.0 93/11/22 12:40:00 rws Exp $ */ /******************************************************************************/ /* */ /* (c) Copyright Hewlett-Packard Company, 1993, Fort Collins, Colorado */ /* */ /* All Rights Reserved */ /* */ /* Permission to use, copy, modify, and distribute this software and its */ /* documentation for any purpose and without fee is hereby granted, */ /* provided that the above copyright notices appear in all copies and that */ /* both the copyright notices and this permission notice appear in */ /* supporting documentation, and that the name of Hewlett-Packard not be */ /* used in advertising or publicity pertaining to distribution of the */ /* software without specific, written prior permission. */ /* */ /* HEWLETT-PACKARD MAKES NO WARRANTY OF ANY KIND WITH REGARD TO THIS */ /* SOFTWARE, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF */ /* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. Hewlett-Packard */ /* shall not be liable for errors contained herein or direct, indirect, */ /* special, incidental or consequential damages in connection with the */ /* furnishing, performance or use of this software. */ /* */ /******************************************************************************/ /* ****************************************************************************** ** Renderer resource state transition test ****************************************************************************** */ #include #include #include #include #include #include #include #ifdef XSYSTEM #include #endif #include #include #include #include #include "rnd_utils.h" #ifdef XSYSTEM XSystemTestingControlStructure xtc; #endif #ifdef XSYSTEM #define WIDTH 256 #define HEIGHT 256 #else #define WIDTH 200 #define HEIGHT 200 #endif static PEXViewport fullframe_data[]={ { {0, 0, 0.0}, {WIDTH, HEIGHT, 1.0}, True, { 0,0,0 } }, }; #define NUM_WINDOWS 3 #define BAD_WINDOW_ID 52 #define IDLE 0 #define RENDERING 1 #define PICK_ONE 2 #define PICK_ALL 3 /* This table describes expected values when various state transitions are attempted. */ static struct _state_value { int initial_set_state; int initial_expected_state; int begin_expected_error_type; int begin_expected_error_code; int begin_expected_state; int end_expected_error_type; int end_expected_error_code; int end_expected_state; } state_values[]={ { IDLE, PEXIdle, NO_ERR, 0, PEXRendering, NO_ERR, 0, PEXIdle }, { RENDERING, PEXRendering, PEX_ERR, BadPEXRendererState, PEXRendering, NO_ERR, 0, PEXIdle }, { PICK_ONE, PEXPicking, PEX_ERR, BadPEXRendererState, PEXRendering, PEX_ERR, BadPEXRendererState, PEXPicking }, { PICK_ALL, PEXPicking, PEX_ERR, BadPEXRendererState, PEXRendering, PEX_ERR, BadPEXRendererState, PEXPicking }, }; #define VIEWPORT 0 #define PIPELINE_CONTEXT_ATTR 1 #define NUM_ATTRS 2 #define NOT_A_RESOURCE 0 #define RESOURCE_ID 1 #define RESOURCE_CONTENTS 2 static struct _attr_info { int image_per_setting; int subframe_per_setting; int last_subframe_in_image; int suppress_clear_after_image; int resource_attr_type; XID *resource_id_attr; int resource_RA_bit; int lut_type; char *attr_name; } attr_control[]={ /* VIEWPORT */ { True, False, False, False, NOT_A_RESOURCE, NULL, PEXRAViewport, 0, "Viewport" }, /* PIPELINE_CONTEXT */ { False, False, False, False, RESOURCE_ID, NULL, PEXRAPipelineContext, 0, "Pipeline Context ID" }, }; static struct _viewport_value { PEXViewport value; char *message; } viewport_values[]={ { { {0, 0, 0.0}, {WIDTH, HEIGHT, 1.0}, False, { 0,0,0 } }, "First viewport value: Full-window viewport" }, { { {WIDTH/2, HEIGHT/2, 0.0}, {WIDTH, HEIGHT, 1.0}, False, { 0,0,0 } }, "Second viewport value: Viewport in upper-right quarter of window" }, }; static struct _plcattr_value { PEXEnumTypeIndex line_type; PEXBitmask asf_enables; PEXBitmask asf_values; char *message; } plcattr_values[]={ { PEXLineTypeSolid, PEXASFLineType, PEXASFLineType, "First PLC value: Solid line type" }, { PEXLineTypeDashed, PEXASFLineType, 0, "Second PLC value: Dashed line type" }, }; main(argc, argv) int argc; char **argv; { Display *display; Window window; Window windows[NUM_WINDOWS]; PEXRenderer renderer; PEXRendererAttributes set_attrs, expected_attrs; unsigned long value_mask; PEXExtensionInfo *ext_info; char title[256]; PEXUtWindowSpecification window_info; PEXUtVisualCriteria criteria; Atom prop_atom; XColor returned_background; XEvent event; unsigned int unmet; int status; XVisualInfo vis_info; XStandardColormap cmap_info; PEXColorApproxEntry capx_info; int screen; XSizeHints hints; PEXElementRef current_path_elems; PEXStructure structure, substructure; long client_structure; PEXPickRecord pick_aperture; int pick_status, more_hits, nd_hits; unsigned long pick_path_count; PEXPickPath *pick_paths; XVisualInfo *visuals; int num_visuals; XVisualInfo vis_templ; unsigned int vis_mask; int i, j; int value_index, trans, state, attr; int image_number = 0; PEXCoord points[2]; PEXPipelineContext pipeline_context; PEXPCAttributes plc_attrs; char *image_desc, image_msg[256]; char image_name[80], test_name[80]; #ifdef XSYSTEM int XSystemValues[20]; #endif int pexmode = 0; int image_depth = 0; #ifdef XSYSTEM openXSystemTesting(argc, argv, &xtc, 0, 0); #else /* Handle other arguments. */ if (parse_options (argc, argv, &pexmode, &image_depth)) exit (1); #endif _hppex_set_stderr("rnd_trans.stderr", "rnd_trans"); describe_test("\n\n"); describe_test("This is a test of PEXlib Renderer state transitions, in two parts.\n"); describe_test("The first part tests binding the Renderer to multiple windows in succession,\n"); describe_test("handling a PEXBegin* call when already active, and handling an inappropriate\n"); describe_test("PEXEnd* for the current state. Most of these conditions result in\n"); describe_test("PEXBadRendererState errors, which are trapped and checked. This part of the\n"); describe_test("test does not generate images. It succeeds if no messages starting with ERROR\n"); describe_test("are printed to stderr.\n\n"); describe_test("The second part of the test makes sure that if a Renderer attribute is changed,\n"); describe_test("the change is effective on each of several windows that the Renderer might\n"); describe_test("be bound to. Actually, only a representative Pipeline Context attribute\n"); describe_test("(line style), and a representative non-resource attribute (viewport), are tested\n\n"); describe_test("The second part of the test generates images. To demonstrate the viewport\n"); describe_test("change, a rectangle is drawn that outlines the NPC subvolume. To demonstrate\n"); describe_test("the Pipeline Context change, a horizontal line is drawn.\n\n"); describe_test("A third part of the test makes sure that primitives are not drawn when the\n"); describe_test("Renderer is Idle. This also generates one image.\n\n"); #ifdef XSYSTEM if (xtc.interactiveFramePrompt) #else if (glob_verbose_mode && getenv("PAUSE")) #endif prompt_user ("Hit return to continue with the test", ""); #ifndef XSYSTEM if (glob_verbose_mode) fflush (stdout); #endif /* Initialize X and PEX, and create two windows and a Renderer. */ #ifdef XSYSTEM display = xtc.display; #else if (NULL == (display = XOpenDisplay (NULL))) { _hppex_stderr_print( "PROCESS ERROR: XOpenDisplay failed on %s\n", getenv("DISPLAY")); exit (1); } #endif if (PEXInitialize (display, &ext_info, 0, NULL)) { _hppex_stderr_print( "PROCESS ERROR: PEXInitialize failed on %s\n", getenv("DISPLAY")); exit (1); } _hppex_test_init_error_handler(); /* Create a window. */ strcpy (title, "Rnd Transition #0"); screen = DefaultScreen(display); hints.x = 100; hints.y = 100; hints.width = WIDTH; hints.height = HEIGHT; hints.flags = (USSize|USPosition); window_info.attr_mask = CWEventMask; window_info.attrs.event_mask = ExposureMask; window_info.title = title; window_info.size_hints = hints; window_info.parent = RootWindow (display, screen); window_info.border_width = 0; window_info.background_color_name = "black"; window_info.border_color_name = "white"; if (image_depth == 0) { char *depth; if (depth = getenv("TEST_IMAGE_DEPTH")) { image_depth = atoi(depth); } } if (image_depth == 0) { criteria.hard_criteria_mask = PEXUtMinColors; criteria.soft_criteria_mask = PEXUtDepth | PEXUtStandardColormapProperty; criteria.depth = 24; } else { criteria.hard_criteria_mask = PEXUtMinColors | PEXUtDepth; criteria.soft_criteria_mask = PEXUtStandardColormapProperty; criteria.depth = image_depth; } criteria.min_colors = 2; criteria.standard_colormap_property = True; status = PEXUtCreateWindowAndColormap (display, screen, &criteria, &window_info, &(windows[0]), &vis_info, &cmap_info, &capx_info, &unmet, &prop_atom, &returned_background); if ((status != PEXUtSuccess) && (status != PEXUtQualifiedSuccess)) { fprintf (stderr, "PROCESS ERROR: First window creation failed\n"); exit (1); } window = windows[0]; XSetWindowColormap(display, window, cmap_info.colormap); #ifdef XSYSTEM XInstallColormap(display, cmap_info.colormap); #endif XMapWindow(display, window); XFlush(display); /* Wait for the first exposure */ XSelectInput( display, window, ExposureMask); XNextEvent(display, &event); #ifdef XSYSTEM XSystemValues[0] = WINDOW_SMART_HW_CONFIG; XSystemValues[1] = windows[0]; XSystemValues[2] = -1; defineXSystemTestControlParm(&xtc, ARCHIVE_MODE, XSystemValues); #endif /* Create more windows (assume to be using same colormap and visual). */ hints.x += 300; window_info.attr_mask = CWColormap; window_info.attrs.colormap = cmap_info.colormap; for (i=1; i 1)) { int i; PEXColorApproxEntry dummy_capx_info; XStandardColormap dummy_cmap_info; Window dummy_window; Colormap cmap_id; Atom dummy_prop_atom; for (i=0; i