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 TEST_PARAM test_parameter = {
9 "guix_line_1bpp", /* Test name */
10 20, 20, 400, 460 /* Define the coordinates of the capture area.
11 In this test, we only need to capture the line
12 drawing area. */
13 };
14
15 static VOID control_thread_entry(ULONG);
main(int argc,char ** argv)16 int main(int argc, char ** argv)
17 {
18 /* Parse the command line argument. */
19 gx_validation_setup(argc, argv);
20
21 /* Start ThreadX system */
22 tx_kernel_enter();
23 return(0);
24 }
25
tx_application_define(void * first_unused_memory)26 VOID tx_application_define(void *first_unused_memory)
27 {
28
29 /* Create a dedicated thread to perform various operations
30 on the line drawing example. These operations simulate
31 user input. */
32 gx_validation_control_thread_create(control_thread_entry);
33
34 /* Termiante the test if it runs for more than 100 ticks */
35 /* This function is not implemented yet. */
36 gx_validation_watchdog_create(100);
37
38 /* Call the actual line example routine. */
39 gx_validation_application_define(first_unused_memory);
40
41 }
42
43
44 /* Replace the default graphics driver with the validation driver. */
45 #ifdef win32_graphics_driver_setup_monochrome
46 #undef win32_graphics_driver_setup_monochrome
47 #endif
48 #define win32_graphics_driver_setup_monochrome gx_validation_graphics_driver_setup_monochrome
49
50
51 #ifdef WIN32
52 #undef WIN32
53 #endif
54
55 #include "gx_validation_wrapper.h"
56
57 #include "demo_line_1bpp.c"
58
59 char test_comment[256];
60 extern INT line_width;
61 extern GX_WINDOW line_window;
62 extern INT line_angle;
63 extern INT line_pattern;
64 extern GX_BOOL is_round;
65
test_line_win_draw(GX_WIDGET * widget)66 static VOID test_line_win_draw(GX_WIDGET *widget)
67 {
68 ULONG brush_style = 0;
69 GX_BRUSH *brush = GX_NULL;
70
71 gx_window_draw((GX_WINDOW*)widget);
72
73 if (is_round)
74 {
75 brush_style |= GX_BRUSH_ROUND;
76 }
77
78 gx_context_brush_width_set(line_width);
79 gx_context_raw_brush_define(0xffffff, 0x0, brush_style);
80
81 gx_context_brush_get(&brush);
82
83 if (brush)
84 {
85 brush -> gx_brush_line_pattern = line_pattern;
86 gx_context_brush_set(brush);
87
88 /* calculate the line end points */
89 gx_canvas_line_draw(line_x1, line_y1, line_x2, line_y2);
90 }
91
92 }
93
control_thread_entry(ULONG input)94 static VOID control_thread_entry(ULONG input)
95 {
96 int frame_id = 1;
97 int pattern_index;
98 int round_end;
99 GX_RECTANGLE size;
100
101 for(line_width = 1; line_width < 20 ; line_width += 6)
102 {
103 for(line_angle = 0; line_angle < 360; line_angle += 45)
104 {
105 for(round_end = 0; round_end <= 1; round_end ++)
106 {
107 is_round = round_end;
108 for (pattern_index = 0; pattern_index <= 1; pattern_index++)
109 {
110 if(pattern_index) line_pattern = 0x0f0f0f0f;
111 else line_pattern = 0;
112 /* Inform the validation system
113 (1) Frame ID, which identifies a specific test configuration;
114 (2) Start recording frame on the next toggle operation.
115 */
116 calculate_line_ends();
117
118 gx_system_dirty_mark(&line_window);
119 gx_validation_set_frame_id(frame_id);
120 sprintf(test_comment, "id: %d, line_width: %d, line_angle: %d, round_end: %d, line_pattern: %d", frame_id, line_width, line_angle, round_end, line_pattern);
121 gx_validation_set_frame_comment(test_comment);
122 /* Force a screen refresh. */
123 gx_validation_screen_refresh();
124
125 /* Increment frame ID */
126 frame_id ++;
127 }
128 }
129 }
130 }
131 size.gx_rectangle_left = 20;
132 size.gx_rectangle_top = 20;
133 size.gx_rectangle_right = 260;
134 size.gx_rectangle_bottom = 260;
135 gx_widget_resize(&line_window, &size);
136
137 for(line_width = 1; line_width < 20 ; line_width += 6)
138 {
139 for(line_angle = 0; line_angle < 360; line_angle += 30)
140 {
141 for(round_end = 0; round_end <= 1; round_end ++)
142 {
143 is_round = round_end;
144 line_pattern = 0;
145 /* Inform the validation system
146 (1) Frame ID, which identifies a specific test configuration;
147 (2) Start recording frame on the next toggle operation.
148 */
149 calculate_line_ends();
150
151 gx_system_dirty_mark(&line_window);
152 gx_validation_set_frame_id(frame_id);
153 sprintf(test_comment, "id: %d, line_width: %d, line_angle: %d, round_end: %d ", frame_id, line_width, line_angle, round_end);
154 gx_validation_set_frame_comment(test_comment);
155 /* Force a screen refresh. */
156 gx_validation_screen_refresh();
157
158 /* Increment frame ID */
159 frame_id ++;
160 }
161 }
162 }
163 size.gx_rectangle_left = 20;
164 size.gx_rectangle_top = 20;
165 size.gx_rectangle_right = 179;
166 size.gx_rectangle_bottom = 179;
167 gx_widget_resize(&line_window, &size);
168 gx_context_raw_brush_define(0x0, 0xffffff, 0);
169
170 for(line_width = 1; line_width < 15 ; line_width += 6)
171 {
172 for(line_angle = 0; line_angle < 360; line_angle += 30)
173 {
174 for(round_end = 0; round_end <= 1; round_end ++)
175 {
176 is_round = round_end;
177 line_pattern = 0;
178 /* Inform the validation system
179 (1) Frame ID, which identifies a specific test configuration;
180 (2) Start recording frame on the next toggle operation.
181 */
182 calculate_line_ends();
183
184 gx_system_dirty_mark(&line_window);
185 gx_validation_set_frame_id(frame_id);
186 sprintf(test_comment, "id: %d, line_width: %d, line_angle: %d, round_end: %d ", frame_id, line_width, line_angle, round_end);
187 gx_validation_set_frame_comment(test_comment);
188 /* Force a screen refresh. */
189 gx_validation_screen_refresh();
190
191 /* Increment frame ID */
192 frame_id ++;
193 }
194 }
195 }
196
197 /******************************************************/
198 /* set window color to black and line color to white.
199 then do operation as above again. */
200 gx_widget_fill_color_set((GX_WIDGET *)&line_window, GX_1BPP_BLACK, GX_1BPP_BLACK, GX_1BPP_BLACK);
201 line_color = GX_1BPP_WHITE;
202 size.gx_rectangle_left = 20;
203 size.gx_rectangle_top = 20;
204 size.gx_rectangle_right = 400;
205 size.gx_rectangle_bottom = 460;
206 gx_widget_resize(&line_window, &size);
207 gx_context_raw_brush_define(0xffffff, 0, 0);
208 /* Reset line wind draw function because line color is hard-coded in original draw function in demo file,
209 Rewrite this draw function to change line color. */
210 gx_widget_draw_set((GX_WIDGET *)&line_window, test_line_win_draw);
211
212 for(line_width = 1; line_width < 20 ; line_width += 6)
213 {
214 for(line_angle = 0; line_angle < 360; line_angle += 45)
215 {
216 for(round_end = 0; round_end <= 1; round_end ++)
217 {
218 is_round = round_end;
219 for (pattern_index = 0; pattern_index <= 1; pattern_index++)
220 {
221 if(pattern_index) line_pattern = 0x0f0f0f0f;
222 else line_pattern = 0;
223 /* Inform the validation system
224 (1) Frame ID, which identifies a specific test configuration;
225 (2) Start recording frame on the next toggle operation.
226 */
227 calculate_line_ends();
228
229 gx_system_dirty_mark(&line_window);
230 gx_validation_set_frame_id(frame_id);
231 sprintf(test_comment, "id: %d, line_width: %d, line_angle: %d, round_end: %d, line_pattern: %d", frame_id, line_width, line_angle, round_end, line_pattern);
232 gx_validation_set_frame_comment(test_comment);
233 /* Force a screen refresh. */
234 gx_validation_screen_refresh();
235
236 /* Increment frame ID */
237 frame_id ++;
238 }
239 }
240 }
241 }
242 size.gx_rectangle_left = 20;
243 size.gx_rectangle_top = 20;
244 size.gx_rectangle_right = 260;
245 size.gx_rectangle_bottom = 260;
246 gx_widget_resize(&line_window, &size);
247 gx_context_raw_brush_define(0xffffff, 0, 0);
248 for(line_width = 1; line_width < 20 ; line_width += 6)
249 {
250 for(line_angle = 0; line_angle < 360; line_angle += 30)
251 {
252 for(round_end = 0; round_end <= 1; round_end ++)
253 {
254 is_round = round_end;
255 line_pattern = 0;
256 /* Inform the validation system
257 (1) Frame ID, which identifies a specific test configuration;
258 (2) Start recording frame on the next toggle operation.
259 */
260 calculate_line_ends();
261
262 gx_system_dirty_mark(&line_window);
263 gx_validation_set_frame_id(frame_id);
264 sprintf(test_comment, "id: %d, line_width: %d, line_angle: %d, round_end: %d ", frame_id, line_width, line_angle, round_end);
265 gx_validation_set_frame_comment(test_comment);
266 /* Force a screen refresh. */
267 gx_validation_screen_refresh();
268
269 /* Increment frame ID */
270 frame_id ++;
271 }
272 }
273 }
274 size.gx_rectangle_left = 20;
275 size.gx_rectangle_top = 20;
276 size.gx_rectangle_right = 179;
277 size.gx_rectangle_bottom = 179;
278 gx_widget_resize(&line_window, &size);
279 gx_context_raw_brush_define(0xffffff, 0, 0);
280
281 for(line_width = 1; line_width < 15 ; line_width += 6)
282 {
283 for(line_angle = 0; line_angle < 360; line_angle += 30)
284 {
285 for(round_end = 0; round_end <= 1; round_end ++)
286 {
287 is_round = round_end;
288 line_pattern = 0;
289 /* Inform the validation system
290 (1) Frame ID, which identifies a specific test configuration;
291 (2) Start recording frame on the next toggle operation.
292 */
293 calculate_line_ends();
294
295 gx_system_dirty_mark(&line_window);
296 gx_validation_set_frame_id(frame_id);
297 sprintf(test_comment, "id: %d, line_width: %d, line_angle: %d, round_end: %d ", frame_id, line_width, line_angle, round_end);
298 gx_validation_set_frame_comment(test_comment);
299 /* Force a screen refresh. */
300 gx_validation_screen_refresh();
301
302 /* Increment frame ID */
303 frame_id ++;
304 }
305 }
306 }
307
308
309 /* Signal the end of the test case. Verify the output. */
310 gx_validation_end();
311
312 exit(0);
313 }
314
315
316
317
318
319
320
321
322
323