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_graphics_arc_32bpp", /* Test name */
10     24, 43, 370, 402  /* Define the coordinates of the capture area.
11                          In this test, we only need to capture the graphics
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 pixelmap 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_24xrgb
46 #undef win32_graphics_driver_setup_24xrgb
47 #endif
48 #define win32_graphics_driver_setup_24xrgb  gx_validation_graphics_driver_setup_24xrgb
49 
50 
51 #ifdef WIN32
52 #undef WIN32
53 #endif
54 
55 #include "gx_validation_wrapper.h"
56 
57 #include "demo_guix_graphics_32bpp.c"
58 
59 typedef struct ARC_PROPS_STRUCT{
60 INT start_angle;
61 INT end_angle;
62 INT brush_width;
63 INT solid_fill;
64 INT pixelmap_fill;
65 INT alpha_mode;
66 INT compress_mode;
67 INT anti_aliased_mode;
68 }ARC_PROPS;
69 
70 ARC_PROPS arc_props[]={
71     {0, 90, 1, 0, 0, 0, 0, 1},
72     {10, 30, 2, 1, 0, 0, 0, 1},
73     {10, 65, 3, 0, 1, 0, 0, 1},
74     {100, 115, 5, 0, 1, 0, 1, 1},
75     {110, 175, 7, 0, 1, 2, 0, 1},
76     {180, 190, 9, 0, 1, 2, 1, 1},
77     {185, -115, 10, 1, 0, 0, 0, 1},
78     {-10, -55, 12, 1, 0, 0, 0, 1},
79     {15, 175, 13, 1, 0, 0, 0, 1},
80     {16, 260, 14, 1, 0, 0, 0, 1},
81     {25, 335, 15, 1, 0, 0, 0, 1},
82     {115, 200, 16, 1, 0, 0, 0, 1},
83     {160, 300, 17, 1, 0, 0, 0, 1},
84     {210, 355, 18, 1, 0, 0, 0, 1},
85     {0, 90, 1, 0, 0, 0, 0, 0},
86     {185, -115, 10, 1, 0, 0, 0, 0},
87     {-10, -55, 12, 1, 0, 0, 0, 0},
88     {115, 200, 16, 1, 0, 0, 0, 0},
89     {210, 355, 18, 1, 0, 0, 0, 0},
90 };
91 
92 static INT brush_alpha_value[] = {0, 155, 255};
93 
94 char test_comment[256];
95 
96 
97 /* This thread simulates user input.  Its priority is lower
98    than the GUIX thread, so that GUIX finishes an operation
99    before this thread is able to issue the next command. */
control_thread_entry(ULONG input)100 static VOID control_thread_entry(ULONG input)
101 {
102 INT index, brush_alpha_index;
103 INT frame_id = 1;
104 
105     draw_shape = ARC;
106 
107     /* Loop radius from 5 to 200. */
108     for(radius = 1; radius < 200; radius += 50)
109     {
110         for(brush_alpha_index = 0; brush_alpha_index < (INT)(sizeof(brush_alpha_value)/sizeof(INT)); brush_alpha_index++)
111         {
112            brush_alpha = brush_alpha_value[brush_alpha_index];
113 
114             for(index = 0; index < (INT)(sizeof(arc_props)/sizeof(ARC_PROPS)); index++)
115             {
116                 start_angle = arc_props[index].start_angle;
117                 end_angle = arc_props[index].end_angle;
118 
119                 if(radius < 30)
120                 {
121                     brush_width = 1;
122                 }
123                 else
124                 {
125                     brush_width = arc_props[index].brush_width;
126                 }
127 
128                 solid_fill = arc_props[index].solid_fill;
129                 pixelmap_fill = arc_props[index].pixelmap_fill;
130                 alpha = arc_props[index].alpha_mode;
131                 compress = arc_props[index].compress_mode;
132                 pixelmap_index = alpha + compress;
133                 anti_aliased = arc_props[index].anti_aliased_mode;
134                 /* Set frame id. */
135                 gx_validation_set_frame_id(frame_id);
136 
137                 frame_id++;
138 
139                 /* Set test comments. */
140                 sprintf(test_comment, "radius:%d, start_angle:%d, end_angle:%d, brush_width %d, solid_fill:%d, pixelmap_fill:%d, alpha:%d, compress: %d, brush_alpha: %d, anti_aliased: %d", radius, start_angle, end_angle, brush_width, solid_fill, pixelmap_fill, alpha, compress, brush_alpha, anti_aliased);
141 
142                 gx_validation_set_frame_comment(test_comment);
143 
144                 /* Mark graphics window dirty. */
145                 gx_system_dirty_mark(pGraphicsWin);
146 
147                 /* Force a screen refresh.  */
148                 gx_validation_screen_refresh();
149             }
150         }
151     }
152 
153     anti_aliased = GX_TRUE;
154     brush_alpha = 255;
155     root->gx_window_root_canvas->gx_canvas_display->gx_display_driver_pixel_blend = GX_NULL;
156 
157     brush_width = 1;
158     gx_validation_screen_refresh();
159 
160     brush_width = 2;
161     gx_validation_screen_refresh();
162 
163     /* Signal the end of the test case, Verify the outout.  */
164     gx_validation_end();
165 
166     exit(0);
167 }
168