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 #include "gx_system.h"
8 
9 TEST_PARAM test_parameter = {
10     "guix_widget_pixelmap_get", /* Test name */
11     41, 31, 597, 471  /* 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     /* Call the actual line example routine. */
30     gx_validation_application_define(first_unused_memory);
31 
32     /* Termiante the test if it runs for more than 100 ticks */
33     /* This function is not implemented yet. */
34     gx_validation_watchdog_create(100);
35 
36     /* Create a dedicated thread to perform various operations
37        on the line drawing example. These operations simulate
38        user input. */
39     gx_validation_control_thread_create(control_thread_entry);
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 #include "demo_guix_all_widgets.c"
57 
58 static GX_RESOURCE_ID blend_map = GX_PIXELMAP_ID_ROTATE_FOOT;
sprite_screen_draw(GX_WINDOW * window)59 VOID sprite_screen_draw(GX_WINDOW *window)
60 {
61     GX_PIXELMAP *map;
62 
63     gx_window_draw(window);
64 
65     gx_widget_pixelmap_get(window, blend_map, &map);
66     if(map)
67     {
68         gx_canvas_pixelmap_blend(window->gx_widget_size.gx_rectangle_left, window->gx_widget_size.gx_rectangle_top, map, 200);
69     }
70 }
71 
72 static GX_CHAR test_comment[256];
73 
74 /* This thread simulates user input.  Its priority is lower
75    than the GUIX thread, so that GUIX finishes an operation
76    before this thread is able to issue the next command. */
control_thread_entry(ULONG input)77 static VOID control_thread_entry(ULONG input)
78 {
79 int                        frame_id = 1;
80 GX_RECTANGLE size;
81 GX_PIXELMAP *map;
82 UINT        status;
83 
84     gx_widget_style_remove(&((SPRITE_SCREEN_CONTROL_BLOCK *)pSpriteScreen)->sprite_screen_sprite_1, GX_STYLE_SPRITE_AUTO);
85     gx_widget_draw_set(pSpriteScreen, (void(*)(GX_WIDGET *))sprite_screen_draw);
86 
87     size = pButtonScreen->gx_widget_size;
88     size.gx_rectangle_right = 400;
89     size.gx_rectangle_bottom = 400;
90 
91     size = pSpriteScreen->gx_widget_size;
92     size.gx_rectangle_left = 300;
93     size.gx_rectangle_top = 200;
94     gx_widget_resize(pSpriteScreen, &size);
95     gx_widget_attach(root, pSpriteScreen);
96     gx_widget_back_move(pSpriteScreen, GX_NULL);
97     /* blend pixelmap in different position. */
98 
99     gx_validation_set_frame_id(frame_id++);
100     sprintf(test_comment, "Change sprite screen draw function and attach sprite screen to root window.");
101     gx_validation_set_frame_comment(test_comment);
102     gx_validation_screen_refresh();
103 
104     blend_map = PRIMARY_PIXELMAP_TABLE_SIZE + 1;
105 
106     gx_validation_set_frame_id(frame_id++);
107     sprintf(test_comment, "Call function gx_widget_pixelmap_get with invalid pixelmap id.");
108     gx_validation_set_frame_comment(test_comment);
109     gx_system_dirty_mark(pSpriteScreen);
110     gx_validation_screen_refresh();
111 
112     gx_widget_hide(pSpriteScreen);
113     status = gx_widget_pixelmap_get(pSpriteScreen, blend_map, &map);
114     if((status != GX_INVALID_CANVAS) || (map != GX_NULL))
115     {
116         printf("Guix Test:   guix_canvas_pixelmap_blend.......................................................Failed!\n");
117         exit(1);
118     }
119 
120     text_screen.gx_widget_status |= GX_STATUS_VISIBLE;
121     /* Call pixelmap get function here, which condition has no canvas and no context.
122        And GX_INVALID_CANVAS will be returned. */
123     status = gx_widget_pixelmap_get((GX_WIDGET *)&text_screen, blend_map, &map);
124     if((status != GX_INVALID_CANVAS) || (map != GX_NULL))
125     {
126         printf("Guix Test:   guix_canvas_pixelmap_blend.......................................................Failed!\n");
127         exit(1);
128     }
129 
130     /* Signal the end of the test case.  Verify the output. */
131     gx_validation_end();
132 
133     exit(0);
134 }
135