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_generic_alphamap_draw", /* Test name */
10     382, 139, 580, 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_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_alphamap_16bpp.c"
58 
59 char test_comment[256];
60 
61 static int map_id_list[]={
62 GX_PIXELMAP_ID_RED_APPLE_RAW,/*alpha*/
63 GX_PIXELMAP_ID_FOOT_COMPRESSED,/*compress, alpha*/
64 GX_PIXELMAP_ID_CHECKBOX_ON_RAW,/*raw*/
65 GX_PIXELMAP_ID_CHECKBOX_OFF_COMPRESSED/*compress*/
66 };
67 static int map_id = 0;
68 static int x_shift = 0;
69 static int blend_alpha = 255;
70 
test_pixelmap_wnd_draw(GX_WINDOW * window)71 VOID test_pixelmap_wnd_draw(GX_WINDOW *window)
72 {
73 int xpos;
74 int ypos;
75 GX_PIXELMAP *map;
76 GX_BRUSH *brush;
77 
78     gx_context_brush_get(&brush);
79     brush->gx_brush_fill_color = COLOR_ID_BLUE;
80     brush->gx_brush_alpha = blend_alpha;
81 
82     xpos = window->gx_window_client.gx_rectangle_left + x_shift;
83     ypos = window->gx_window_client.gx_rectangle_top - 10;
84 
85     gx_context_pixelmap_get(map_id, &map);
86     gx_canvas_pixelmap_draw(xpos, ypos, map);
87 }
88 
89 /* This thread simulates user input.  Its priority is lower
90    than the GUIX thread, so that GUIX finishes an operation
91    before this thread is able to issue the next command. */
control_thread_entry(ULONG input)92 static VOID control_thread_entry(ULONG input)
93 {
94 int frame_id = 1;
95 GX_WINDOW *window2;
96 GX_BOOL set_blend_null;
97 int index;
98 
99     window2 = &main_window.main_window_window_2;
100 
101     gx_widget_draw_set(window2, test_pixelmap_wnd_draw);
102 
103     for(set_blend_null = 0; set_blend_null < 2; set_blend_null++)
104     {
105         if(set_blend_null)
106         {
107             root->gx_window_root_canvas->gx_canvas_display->gx_display_driver_pixel_blend = GX_NULL;
108         }
109 
110         for(blend_alpha = 128; blend_alpha <= 255; blend_alpha += 127)
111         {
112             for(index = 0; index < (int)(sizeof(map_id_list) / sizeof(int)); index++)
113             {
114                 map_id = map_id_list[index];
115                 for(x_shift = -10; x_shift <= 190; x_shift += 200)
116                 {
117                     sprintf(test_comment, "set_blend_null = %d, blend_alpha = %d, map_id = %d, x_shift = %d", set_blend_null, blend_alpha, map_id, x_shift);
118                     gx_validation_set_frame_id(frame_id++);
119                     gx_validation_set_frame_comment(test_comment);
120                     gx_validation_screen_refresh();
121                 }
122             }
123         }
124     }
125     /* Signal the end of the test case.  Verify the output. */
126     gx_validation_end();
127 
128     exit(0);
129 }
130 
131 
132 
133 
134 
135