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_display.h"
7 #include "gx_validation_utility.h"
8 
9 TEST_PARAM test_parameter = {
10     "guix_generic_line_draw", /* Test name */
11     25, 17, 344, 336  /* Define the coordinates of the capture area.
12                          In this test, we only need to capture the line
13                          drawing area.  */
14 };
15 
16 static VOID      control_thread_entry(ULONG);
main(int argc,char ** argv)17 int main(int argc, char ** argv)
18 {
19     /* Parse the command line argument. */
20     gx_validation_setup(argc, argv);
21 
22     /* Start ThreadX system */
23     tx_kernel_enter();
24     return(0);
25 }
26 
tx_application_define(void * first_unused_memory)27 VOID tx_application_define(void *first_unused_memory)
28 {
29 
30     /* Create a dedicated thread to perform various operations
31        on the line drawing example. These operations simulate
32        user input. */
33     gx_validation_control_thread_create(control_thread_entry);
34 
35     /* Termiante the test if it runs for more than 100 ticks */
36     /* This function is not implemented yet. */
37     gx_validation_watchdog_create(100);
38 
39     /* Call the actual line example routine. */
40     gx_validation_application_define(first_unused_memory);
41 
42 }
43 
44 
45 /* Replace the default graphics driver with the validation driver. */
46 #ifdef win32_graphics_driver_setup_24xrgb
47 #undef win32_graphics_driver_setup_24xrgb
48 #endif
49 #define win32_graphics_driver_setup_24xrgb  gx_validation_graphics_driver_setup_24xrgb
50 
51 
52 #ifdef WIN32
53 #undef WIN32
54 #endif
55 
56 #include "gx_validation_wrapper.h"
57 
58 #include "demo_guix_lines.c"
59 
60 char test_comment[256];
test_line_win_draw(GX_WINDOW * window)61 VOID test_line_win_draw(GX_WINDOW *window)
62 {
63     gx_window_draw((GX_WINDOW*) window);
64 
65     gx_context_brush_define(GX_COLOR_ID_CANVAS, window->gx_widget_normal_fill_color, GX_BRUSH_ALIAS);
66     gx_context_brush_width_set(1);
67 
68     gx_canvas_line_draw(24, 13, 23, 12);
69 
70     /* Line with round end. aliased. */
71     gx_context_brush_define(GX_COLOR_ID_CANVAS, window->gx_widget_normal_fill_color, GX_BRUSH_ALIAS | GX_BRUSH_ROUND);
72     gx_context_brush_width_set(5);
73 
74     gx_canvas_line_draw(200, 10, 150, 400);
75     gx_canvas_line_draw(15, 200, 400, 150);
76 
77     /* Line with round end, not aliased. */
78     gx_context_brush_define(GX_COLOR_ID_CANVAS, window->gx_widget_normal_fill_color, GX_BRUSH_ROUND);
79     gx_canvas_line_draw(220, 10, 170, 400);
80     gx_canvas_line_draw(15, 220, 400, 170);
81 
82 }
83 /* This thread simulates user input.  Its priority is lower
84    than the GUIX thread, so that GUIX finishes an operation
85    before this thread is able to issue the next command. */
control_thread_entry(ULONG input)86 static VOID control_thread_entry(ULONG input)
87 {
88 int frame_id = 1;
89 GX_DRAW_CONTEXT context;
90 GX_DISPLAY display;
91 
92     gx_widget_draw_set(&main_window.main_window_line_window, test_line_win_draw);
93 
94     gx_validation_set_frame_id(frame_id++);
95     gx_validation_set_frame_comment("draw one pixel aliased line");
96     gx_validation_screen_refresh();
97 
98     /* Test aliased filled circle draw with null pointer blend func. */
99     display.gx_display_driver_pixel_blend = GX_NULL;
100     context.gx_draw_context_display = &display;
101     _gx_display_driver_generic_aliased_filled_circle_draw(&context, 0, 0, 5);
102 
103     /* Signal the end of the test case.  Verify the output. */
104     gx_validation_end();
105 
106     exit(0);
107 }
108 
109 
110 
111 
112 
113