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_all_widgets_16bpp_shapes_screen_pie", /* 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_565rgb
46 #undef win32_graphics_driver_setup_565rgb
47 #endif
48 #define win32_graphics_driver_setup_565rgb  gx_validation_graphics_driver_setup_565rgb
49 
50 
51 #ifdef WIN32
52 #undef WIN32
53 #endif
54 
55 #include "gx_validation_wrapper.h"
56 
57 #include "demo_guix_all_widgets_16bpp.c"
58 
59 typedef struct PIE_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 }PIE_PROPS;
68 
69 PIE_PROPS pie_props[]={
70     {0, 90, 1, 0, 0, 0, 0},
71     {10, 30, 2, 1, 0, 0, 0},
72     {10, 65, 3, 0, 1, 0, 0},
73     {100, 115, 5, 0, 1, 0, 1},
74     {110, 175, 7, 0, 1, 2, 0},
75     {180, 190, 9, 0, 1, 2, 1},
76     {185, -115, 10, 1, 0, 0, 0},
77     {-10, -55, 12, 1, 0, 0, 0},
78     {15, 175, 13, 1, 0, 0, 0},
79     {16, 260, 14, 1, 0, 0, 0},
80     {25, 335, 15, 1, 0, 0, 0},
81     {115, 200, 16, 1, 0, 0, 0},
82     {160, 300, 17, 1, 0, 0, 0},
83     {210, 355, 18, 1, 0, 0, 0}
84 };
85 
86 char test_comment[256];
87 extern INT               draw_shape;
88 extern INT               radius;
89 extern GX_BOOL           anti_aliased;
90 extern GX_BOOL           round_end;
91 extern GX_BOOL           solid_fill;
92 extern GX_BOOL           pixelmap_fill;
93 extern INT               brush_width;
94 extern INT               start_angle;
95 extern INT               end_angle;
96 extern GX_UBYTE          brush_alpha;
97 extern INT               fill_pixelmap_index;
98 extern INT               alpha;
99 extern INT               compress;
100 
101 extern GX_RESOURCE_ID pixelmap_id[4];
102 
103 
104 static INT brush_alpha_value[] = {0, 155, 255};
105 
106 /* This thread simulates user input.  Its priority is lower
107    than the GUIX thread, so that GUIX finishes an operation
108    before this thread is able to issue the next command. */
control_thread_entry(ULONG input)109 static VOID control_thread_entry(ULONG input)
110 {
111 INT index, brush_alpha_index;
112 INT frame_id = 1;
113 GX_WINDOW *pGraphicsWin = &(((SHAPES_SCREEN_CONTROL_BLOCK *)pShapesScreen)->shapes_screen_graphics_window);
114 
115     /* pie */
116     draw_shape = 2;
117     ToggleScreen(pShapesScreen, pButtonScreen);
118 
119     /* Loop radius from 5 to 200. */
120     for(radius = 1; radius < 200; radius += 50)
121     {
122         for(brush_alpha_index = 0; brush_alpha_index < (INT)(sizeof(brush_alpha_value)/sizeof(INT)); brush_alpha_index++)
123         {
124             brush_alpha = brush_alpha_value[brush_alpha_index];
125 
126             for(index = 0; index < (INT)(sizeof(pie_props)/sizeof(PIE_PROPS)); index++)
127             {
128                 start_angle = pie_props[index].start_angle;
129                 end_angle = pie_props[index].end_angle;
130 
131                 if(radius < 30)
132                 {
133                     brush_width = 1;
134                 }
135                 else
136                 {
137                     brush_width = pie_props[index].brush_width;
138                 }
139 
140                 solid_fill = pie_props[index].solid_fill;
141                 pixelmap_fill = pie_props[index].pixelmap_fill;
142                 alpha = pie_props[index].alpha_mode;
143                 compress = pie_props[index].compress_mode;
144                 fill_pixelmap_index = alpha + compress;
145 
146                /* Set frame id. */
147                gx_validation_set_frame_id(frame_id);
148 
149                frame_id++;
150 
151                /* Set test comments. */
152                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", radius, start_angle, end_angle, brush_width, solid_fill, pixelmap_fill, alpha, compress, brush_alpha);
153 
154                 gx_validation_set_frame_comment(test_comment);
155 
156                 /* Mark graphics window dirty. */
157                 gx_system_dirty_mark(pGraphicsWin);
158 
159                 /* Force a screen refresh.  */
160                 gx_validation_screen_refresh();
161             }
162         }
163     }
164 
165     /* Signal the end of the test case, Verify the outout.  */
166     gx_validation_end();
167 
168     exit(0);
169 }
170