1 /* This is a small demo of the high-performance GUIX graphics framework. */
2
3
4 #include <stdio.h>
5 #include "tx_api.h"
6 #include "gx_api.h"
7 #include "gx_validation_utility.h"
8
9 TEST_PARAM test_parameter = {
10 "guix_canvas_pixelmap_rotate", /* Test name */
11 0, 0, 640, 480 /* Define the coordinates of the capture area.
12 In this test, we only need to capture the pixelmap
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 pixelmap 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_565rgb
47 #undef win32_graphics_driver_setup_565rgb
48 #endif
49 #define win32_graphics_driver_setup_565rgb gx_validation_graphics_driver_setup_565rgb
50
51
52 #ifdef WIN32
53 #undef WIN32
54 #endif
55
56 #include "gx_validation_wrapper.h"
57
58 #include "demo_guix_all_widgets_16bpp.c"
59
60 char test_comment[256];
61 int frame_id = 1;
62 static GX_RESOURCE_ID pixelmap_id = GX_PIXELMAP_ID_ID_RAW;
63 TX_SEMAPHORE *selected_semaphore;
test_pixelmap_draw(GX_WINDOW * window)64 static VOID test_pixelmap_draw(GX_WINDOW *window)
65 {
66 GX_PIXELMAP *pixelmap;
67 INT xpos;
68 INT ypos;
69 INT angle;
70 UINT status;
71 GX_RECTANGLE win_size;
72 GX_DISPLAY *display;
73 VOID (*rotate)(GX_DRAW_CONTEXT *, INT, INT, GX_PIXELMAP *, INT, INT, INT);
74 VOID (*draw)(GX_DRAW_CONTEXT *,INT , INT , GX_PIXELMAP *);
75 display = root->gx_window_root_canvas->gx_canvas_display;
76 gx_window_draw((GX_WINDOW*)window);
77
78 gx_widget_pixelmap_get(window, pixelmap_id, &pixelmap);
79 win_size = pRotateWin->gx_widget_size;
80
81 xpos = (win_size.gx_rectangle_right + win_size.gx_rectangle_left - pixelmap->gx_pixelmap_width) >> 1;
82 ypos = (win_size.gx_rectangle_top + win_size.gx_rectangle_bottom - pixelmap->gx_pixelmap_height) >> 1;
83 if(pixelmap)
84 {
85 switch(frame_id)
86 {
87 case 5:
88 case 1:
89 /* do nothing to make it draw the original roatet map.*/
90 angle = 30;
91 gx_canvas_pixelmap_rotate(xpos, ypos, pixelmap, angle, -1, -1);
92 break;
93
94 case 2:
95 /* Try to rotate compress pixelmap. */
96 status = gx_canvas_pixelmap_rotate(xpos, ypos, pixelmap, angle, -1, -1);
97 if(status != GX_NOT_SUPPORTED)
98 {
99 printf("Guix Test: guix_canvas_rotated_text_draw....................................................Failed!\n");
100 exit(1);
101 }
102 break;
103
104 case 3:
105 angle = 0;
106 draw = display->gx_display_driver_pixelmap_draw;
107 display->gx_display_driver_pixelmap_draw = GX_NULL;
108
109 status = gx_canvas_pixelmap_rotate(xpos, ypos, pixelmap, angle, -1, -1);
110 if(status != GX_FAILURE)
111 {
112 printf("Guix Test: guix_canvas_rotated_text_draw....................................................Failed!\n");
113 exit(1);
114 }
115 display->gx_display_driver_pixelmap_draw = draw;
116 break;
117
118 case 4:
119 angle = 30;
120 rotate = display->gx_display_driver_pixelmap_rotate;
121 display->gx_display_driver_pixelmap_rotate = GX_NULL;
122 status = gx_canvas_pixelmap_rotate(xpos, ypos, pixelmap, angle, -1, -1);
123 if(status != GX_FAILURE)
124 {
125 printf("Guix Test: guix_canvas_rotated_text_draw....................................................Failed!\n");
126 exit(1);
127 }
128 display->gx_display_driver_pixelmap_rotate = rotate;
129 break;
130
131 }
132 }
133
134 if(selected_semaphore)
135 {
136 tx_semaphore_put(selected_semaphore);
137 }
138 }
139
140 /* This thread simulates user input. Its priority is lower
141 than the GUIX thread, so that GUIX finishes an operation
142 before this thread is able to issue the next command. */
control_thread_entry(ULONG input)143 static VOID control_thread_entry(ULONG input)
144 {
145 static TX_SEMAPHORE semaphore_memory;
146 static GX_WINDOW cover_window;
147 GX_RECTANGLE size;
148 selected_semaphore = &semaphore_memory;
149 tx_semaphore_create(selected_semaphore, "test_semaphore", 0);
150
151 size = pRotateScreen->gx_widget_size;
152 size.gx_rectangle_left += 10;
153 size.gx_rectangle_top += 10;
154 size.gx_rectangle_right -= 10;
155 size.gx_rectangle_bottom -= 10;
156 gx_widget_resize(pRotateScreen, &size);
157
158 gx_widget_draw_set(&rotate_screen.rotate_screen_pixelmap_window, (VOID (*)(GX_WIDGET *))test_pixelmap_draw);
159 gx_widget_detach(pButtonScreen);
160 gx_widget_attach(root, pRotateScreen);
161
162 /* Inform the validation system
163 (1) Frame ID, which identifies a specific test configuration;
164 (2) Start recording frame on the next toggle operation.
165 */
166 while(frame_id <= 5)
167 {
168 pixelmap_id = GX_PIXELMAP_ID_ID_RAW;
169 gx_validation_set_frame_id(frame_id);
170 switch(frame_id)
171 {
172 case 1:
173 sprintf(test_comment, "Just draw rotate raw pixelmap.");
174 break;
175 case 2:
176 pixelmap_id = GX_PIXELMAP_ID_ID_COMPRESS;
177 sprintf(test_comment, "Try to rotate compressed map, So no rotated map should be drawn.");
178 break;
179 case 3:
180 sprintf(test_comment, "Set display pixelmap draw function to NULL, set rotate angle to 0, then call gx_canvas_pixelmap_rotate.");
181 break;
182 case 4:
183 sprintf(test_comment, "Set display pixelmap rotate function to NULL, set rotate angle to 30, then call gx_canvas_pixelmap_rotate.");
184 break;
185 case 5:
186 memset(&cover_window, 0, sizeof(GX_WINDOW));
187 size = pRotateScreen->gx_widget_size;
188 size.gx_rectangle_left += 50;
189 size.gx_rectangle_top += 50;
190 gx_window_create(&cover_window, "cover_window", 0, 0, 0, &size);
191 gx_widget_attach(root, &cover_window);
192 sprintf(test_comment, "Create window to cover the rotate map.");
193 break;
194 }
195 gx_validation_set_frame_comment(test_comment);
196
197 gx_system_dirty_mark(pRotateScreen);
198
199 /* Force a screen refresh. */
200 gx_validation_screen_refresh();
201
202 tx_semaphore_get(selected_semaphore, TX_WAIT_FOREVER);
203 frame_id++;
204 }
205
206 tx_semaphore_delete(selected_semaphore);
207 selected_semaphore = GX_NULL;
208 /* Signal the end of the test case. Verify the output. */
209 gx_validation_end();
210
211 exit(0);
212 }
213
214
215
216
217
218