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_32bpp_pixelmap_draw", /* Test name */
10 9, 11, 280, 290 /* Define the coordinates of the capture area.
11 In this test, we only need to capture the pixelmap
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_pixelmaps_32bpp.c"
58
59 char test_comment[256];
60
61 static int test_map_list[]={
62 GX_PIXELMAP_ID_APPLE_ALPHA_565RGB,
63 GX_PIXELMAP_ID_COMPRESS_ALPHA_565RGB,
64 GX_PIXELMAP_ID_APPLE_COMPRESS_TRANSPARENT_PALETTE,
65 GX_PIXELMAP_ID_COMPRESS_PALETTE
66 };
67
68 static int x_shift = -50;
69 static int test_map_id = 0;
70 static int blend_alpha = 255;
71
72 #define TEST_INVALID_FORMAT 0x1
73 #define TEST_INVALID_PALETTE 0x2
74 #define TEST_INVALID_TRANSPARENT_PALETTE 0x3
75 #define TEST_INVALID_BLEND 0x04
76 #define TEST_INVALID_PIXELMAP_DATA 0x05
77
78 static int test_invalid_type = 0;
79 static GX_UBYTE pixelmap_data_1[] = {0x00, 0x00, 0x00};
80 static GX_UBYTE pixelmap_data_2[] = {0xff, 0x00, 0x00};
81 static GX_UBYTE *pixelmap_data = GX_NULL;
82
test_pic_win_draw(GX_WINDOW * window)83 VOID test_pic_win_draw(GX_WINDOW *window)
84 {
85 GX_PIXELMAP *map;
86 GX_PIXELMAP invalid_map;
87 int xpos;
88 int ypos;
89 GX_BRUSH *brush;
90
91 gx_window_background_draw(window);
92
93 gx_context_brush_get(&brush);
94 brush->gx_brush_alpha = blend_alpha;
95
96 xpos = window->gx_window_client.gx_rectangle_left + x_shift;
97 ypos = window->gx_window_client.gx_rectangle_top - 10;
98
99 if(test_invalid_type)
100 {
101 memset(&invalid_map, 0, sizeof(GX_PIXELMAP));
102 invalid_map.gx_pixelmap_width = 100;
103 invalid_map.gx_pixelmap_height = 100;
104 switch(test_invalid_type)
105 {
106 case TEST_INVALID_FORMAT:
107 invalid_map.gx_pixelmap_flags = GX_PIXELMAP_COMPRESSED;
108 break;
109
110 case TEST_INVALID_PALETTE:
111 invalid_map.gx_pixelmap_format = GX_COLOR_FORMAT_8BIT_PALETTE;
112 break;
113
114 case TEST_INVALID_TRANSPARENT_PALETTE:
115 invalid_map.gx_pixelmap_format = GX_COLOR_FORMAT_8BIT_PALETTE;
116 invalid_map.gx_pixelmap_flags = GX_PIXELMAP_TRANSPARENT;
117 break;
118
119 case TEST_INVALID_BLEND:
120 break;
121
122 case TEST_INVALID_PIXELMAP_DATA:
123 invalid_map.gx_pixelmap_flags = GX_PIXELMAP_RAW_FORMAT;
124 invalid_map.gx_pixelmap_data = pixelmap_data;
125 invalid_map.gx_pixelmap_data_size = 30;
126 break;
127 }
128 map = &invalid_map;
129 }
130 else
131 {
132 gx_widget_pixelmap_get((GX_WIDGET *)window, test_map_id, &map);
133 }
134 gx_canvas_pixelmap_draw(xpos, ypos, map);
135 }
136 /* This thread simulates user input. Its priority is lower
137 than the GUIX thread, so that GUIX finishes an operation
138 before this thread is able to issue the next command. */
control_thread_entry(ULONG input)139 static VOID control_thread_entry(ULONG input)
140 {
141 int frame_id = 1;
142 int map_index;
143 int index;
144 GX_CANVAS *canvas;
145
146 gx_widget_draw_set((GX_WIDGET *)&main_window.main_window_pic_window, test_pic_win_draw);
147
148 for(map_index = 0; map_index < (int)(sizeof(test_map_list) / sizeof(int)); map_index++)
149 {
150 test_map_id = test_map_list[map_index];
151
152 for(blend_alpha = 128; blend_alpha < 256; blend_alpha += 127)
153 {
154 for(x_shift = -50; x_shift <= 100; x_shift += 150)
155 {
156 sprintf(test_comment, "map_id = %d, blend_alpha = %d, x_shift = %d", test_map_list[map_index], blend_alpha, x_shift);
157 gx_validation_set_frame_id(frame_id++);
158 gx_validation_set_frame_comment(test_comment);
159 gx_validation_screen_refresh();
160 }
161 }
162 }
163
164 for(index = 0; index < 8; index++)
165 {
166 switch(index)
167 {
168 case 0:
169 test_invalid_type = TEST_INVALID_FORMAT;
170 blend_alpha = 128;
171 sprintf(test_comment, "test draw with invalid pixelmap format, blend alpha = 128");
172 break;
173
174 case 1:
175 test_invalid_type = TEST_INVALID_FORMAT;
176 blend_alpha = 255;
177 sprintf(test_comment, "test draw with invalid pixelmap format, blend alpha = 255");
178 break;
179
180 case 2:
181 test_invalid_type = TEST_INVALID_PALETTE;
182 blend_alpha = 255;
183 sprintf(test_comment, "test invalid palette pixelmap without aux data");
184 break;
185
186 case 3:
187 test_invalid_type = TEST_INVALID_TRANSPARENT_PALETTE;
188 blend_alpha = 255;
189 sprintf(test_comment, "test invalid transparent palette pixelmap withou aux data");
190 break;
191
192 case 4:
193 test_invalid_type = TEST_INVALID_BLEND;
194 blend_alpha = 128;
195 sprintf(test_comment, "test blend with invalid pixelmap format");
196 break;
197
198 case 5:
199 test_invalid_type = TEST_INVALID_PIXELMAP_DATA;
200 blend_alpha = 255;
201 pixelmap_data = pixelmap_data_1;
202 sprintf(test_comment, "test raw format pixelmap draw with invalid pixelmap data");
203 break;
204
205 case 6:
206 pixelmap_data = pixelmap_data_2;
207 break;
208
209 case 7:
210 test_invalid_type = 0;
211 x_shift = 10;
212 gx_widget_canvas_get(&main_window, &canvas);
213 canvas->gx_canvas_display->gx_display_driver_pixel_write = GX_NULL;
214 sprintf(test_comment, "set gx_dispaly_driver_pixel_write = GX_NULL");
215 break;
216 }
217
218 gx_validation_set_frame_id(frame_id++);
219 gx_validation_set_frame_comment(test_comment);
220 gx_validation_screen_refresh();
221 }
222
223 /* Signal the end of the test case. Verify the output. */
224 gx_validation_end();
225
226 exit(0);
227 }
228
229
230
231
232
233