1 /* This is a small demo of the high-performance GUIX graphics framework. */
2 
3 #include <stdio.h>
4 #include "tx_api.h"
5 #include "gx_api.h"
6 #include "gx_validation_utility.h"
7 
8 GX_WINDOW pCoverWin;
9 # define ID_WINDOW_COVER 18
10 INT cover_delta =0;
11 TEST_PARAM test_parameter = {
12     "guix_lines_clip_565rgb", /* Test name */
13     25, 17, 344, 336  /* Define the coordinates of the capture area.
14                          In this test, we only need to capture the line
15                          drawing area.  */
16 };
17 
18 static VOID      control_thread_entry(ULONG);
main(int argc,char ** argv)19 int main(int argc, char ** argv)
20 {
21     /* Parse the command line argument. */
22     gx_validation_setup(argc, argv);
23 
24     /* Start ThreadX system */
25     tx_kernel_enter();
26     return(0);
27 }
28 
tx_application_define(void * first_unused_memory)29 VOID tx_application_define(void *first_unused_memory)
30 {
31 
32     /* Create a dedicated thread to perform various operations
33        on the line drawing example. These operations simulate
34        user input. */
35     gx_validation_control_thread_create(control_thread_entry);
36 
37     /* Termiante the test if it runs for more than 100 ticks */
38     /* This function is not implemented yet. */
39     gx_validation_watchdog_create(100);
40 
41     /* Call the actual line example routine. */
42     gx_validation_application_define(first_unused_memory);
43 
44 }
45 
46 
47 /* Replace the default graphics driver with the validation driver. */
48 #ifdef win32_graphics_driver_setup_24xrgb
49 #undef win32_graphics_driver_setup_24xrgb
50 #endif
51 #define win32_graphics_driver_setup_24xrgb  gx_validation_graphics_driver_setup_565rgb
52 
53 
54 #ifdef WIN32
55 #undef WIN32
56 #endif
57 
58 #include "gx_validation_wrapper.h"
59 
60 #include "demo_guix_lines.c"
61 /* Define the angles values for the line. */
62 static int angle_value[] = {0, 1, 23, 30, 45, 60, 75, 89, 90, 135};
63 
64 /* Define the width values for the line.*/
65 static int width_value[] = {1, 2, 3, 5, 10};
66 
67 /* Define the cover coordinate values for the line.*/
68 static int cover_value[] = {50, 100, 5, 145, -300};
69 
70 /* Define the anti-alias settings. */
71 static int aa_value[] = {GX_TRUE, GX_FALSE};
72 
73 /* Define the line end settings. */
74 static int rounded_value[] = {GX_TRUE, GX_FALSE};
75 
76 char test_comment[256];
77 
78 /* This thread simulates user input.  Its priority is lower
79    than the GUIX thread, so that GUIX finishes an operation
80    before this thread is able to issue the next command. */
control_thread_entry(ULONG input)81 static VOID control_thread_entry(ULONG input)
82 {
83 
84 int angle_index, width_index, aa_index, rounded_index, cover_index;
85 int frame_id = 1;
86 GX_EVENT my_event;
87 GX_RECTANGLE    size;
88 
89     gx_utility_rectangle_define(&size, 25, 14, 34, 333);
90     gx_window_create(&pCoverWin, "cover_window", (GX_WIDGET *)pMainWin, 0,ID_WINDOW_COVER,  &size);
91     gx_widget_fill_color_set(&pCoverWin, pCoverWin.gx_widget_normal_fill_color, pCoverWin.gx_widget_normal_fill_color,
92                              pCoverWin.gx_widget_normal_fill_color);
93     gx_widget_status_add(&pCoverWin, GX_STATUS_MOVABLE);
94     for(aa_index = 0; aa_index < 2; aa_index++)
95     {
96         anti_aliased = aa_value[aa_index];
97         for(rounded_index = 0; rounded_index < 2; rounded_index++)
98         {
99             rounded =rounded_value[rounded_index];
100             for(width_index = 0; width_index < (INT)(sizeof(width_value) / sizeof(int)); width_index++)
101             {
102                 line_width = width_value[width_index];
103                 for(angle_index = 0; angle_index < (INT)(sizeof(angle_value) / sizeof(int)); angle_index++)
104                 {
105                     /* Set the line angle value */
106                     line_angle =angle_value[angle_index];
107 
108                     /* Mark the window "dirty" */
109                     gx_system_dirty_mark(pLineWin);
110 
111                     /* Force a screen refresh. */
112                     gx_validation_screen_refresh();
113 
114                     for(cover_index = 0; cover_index < (INT)(sizeof(cover_value) / sizeof(int)); cover_index++)
115                     {
116                         /* Inform the validation system
117                            (1) Frame ID, which identifies a specific test configuration;
118                            (2) Start recording frame on the next toggle operation.
119                         */
120                         /* Set the cover window coordinate shift. */
121                         cover_delta = cover_value[cover_index];
122                         memset(&my_event, 0, sizeof(GX_EVENT));
123                         my_event.gx_event_display_handle = 1;
124                         /* Create the pen down event. */
125                         my_event.gx_event_target = (GX_WIDGET *)&pCoverWin;
126                         my_event.gx_event_type = GX_EVENT_PEN_DOWN;
127                         my_event.gx_event_payload.gx_event_pointdata.gx_point_x = pCoverWin.gx_widget_size.gx_rectangle_left + 5;
128                         my_event.gx_event_payload.gx_event_pointdata.gx_point_y = pCoverWin.gx_widget_size.gx_rectangle_top + 10;
129                         gx_system_event_send(&my_event);
130                         /* Create the pen drag event. */
131                         my_event.gx_event_payload.gx_event_pointdata.gx_point_x = pCoverWin.gx_widget_size.gx_rectangle_left+ 5 + cover_delta;
132                         my_event.gx_event_type = GX_EVENT_PEN_DRAG;
133                         gx_system_event_send(&my_event);
134                         my_event.gx_event_type = GX_EVENT_PEN_UP;
135                         gx_system_event_send(&my_event);
136 
137                         gx_validation_set_frame_id(frame_id);
138 
139                         sprintf(test_comment, "width %d angle %d cover %d ", line_width, line_angle, cover_delta);
140                         if(anti_aliased)
141                             strcat(test_comment, "anti-aliased ");
142                         if(rounded)
143                             strcat(test_comment, "round end ");
144 
145                         gx_validation_set_frame_comment(test_comment);
146                         /* Increment frame ID */
147                         frame_id ++;
148                     }
149                 }
150             }
151         }
152     }
153 
154     /* Signal the end of the test case.  Verify the output. */
155     gx_validation_end();
156 
157     exit(0);
158 }
159 
160 
161 
162 
163 
164