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_4bpp_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_4bpp_grayscale
47 #undef win32_graphics_driver_setup_4bpp_grayscale
48 #endif
49 #define win32_graphics_driver_setup_4bpp_grayscale gx_validation_graphics_driver_setup_4bpp_grayscale
50
51
52 #ifdef WIN32
53 #undef WIN32
54 #endif
55
56 #include "gx_validation_wrapper.h"
57
58 #include "demo_guix_all_widgets_4bpp.c"
59
60 static int xpos = 230;
61 static int map_id = 0;
62 static int angle = 90;
63 static GX_BOOL test_invalid_map = GX_FALSE;
64
test_pixelmap_draw(GX_WINDOW * window)65 VOID test_pixelmap_draw(GX_WINDOW *window)
66 {
67 GX_PIXELMAP *pixelmap;
68 GX_PIXELMAP invalid_map;
69
70 gx_window_draw((GX_WINDOW*)window);
71
72 if(test_invalid_map)
73 {
74 memset(&invalid_map, 0, sizeof(GX_PIXELMAP));
75 invalid_map.gx_pixelmap_width = 100;
76 invalid_map.gx_pixelmap_height = 100;
77 invalid_map.gx_pixelmap_flags = GX_PIXELMAP_TRANSPARENT;
78 pixelmap = &invalid_map;
79 }
80 else
81 {
82 gx_context_pixelmap_get(map_id, &pixelmap);
83 }
84
85 gx_canvas_pixelmap_rotate(xpos, 161, pixelmap, angle, -1, -1);
86 }
87
88 /*NOTICE: Number of xpos_value and ypos_valus should be same.*/
89
90 GX_RESOURCE_ID pixelmap_id_list[]={
91 GX_PIXELMAP_ID_RED_APPLE,
92 GX_PIXELMAP_ID_ROTATE_FISH
93 };
94
95 char test_comment[256];
96 /* This thread simulates user input. Its priority is lower
97 than the GUIX thread, so that GUIX finishes an operation
98 before this thread is able to issue the next command. */
control_thread_entry(ULONG input)99 static VOID control_thread_entry(ULONG input)
100 {
101 int frame_id = 1;
102 int index;
103
104 ToggleScreen(pRotateScreen, pSpriteScreen);
105
106 gx_widget_draw_set((GX_WIDGET *)&rotate_screen.rotate_screen_pixelmap_window, test_pixelmap_draw);
107
108 for(index = 0; index < (int)(sizeof(pixelmap_id_list)/sizeof(GX_RESOURCE_ID)); index++)
109 {
110 map_id = pixelmap_id_list[index];
111 for(xpos = 229; xpos <= 230; xpos++)
112 {
113 for(angle = 90; angle <= 270; angle += 90)
114 {
115 sprintf(test_comment, "map_id = %d, xpos = %d, angle = %d", map_id, xpos, angle);
116 gx_validation_set_frame_id(frame_id++);
117 gx_validation_set_frame_comment(test_comment);
118 gx_validation_screen_refresh();
119 }
120 }
121 }
122
123 test_invalid_map = GX_TRUE;
124 angle = 90;
125 gx_validation_set_frame_id(frame_id++);
126 gx_validation_set_frame_comment("set invalid rotate pixelmap");
127 gx_validation_screen_refresh();
128
129 /* Signal the end of the test case. Verify the output. */
130 gx_validation_end();
131
132 exit(0);
133 }
134