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_4444argb_pixelmap_draw", /* Test name */
10     18, 178, 102, 216  /* 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_4444argb
46 #undef win32_graphics_driver_setup_4444argb
47 #endif
48 #define win32_graphics_driver_setup_4444argb  gx_validation_graphics_driver_setup_4444argb
49 
50 
51 #ifdef WIN32
52 #undef WIN32
53 #endif
54 
55 #include "gx_validation_wrapper.h"
56 
57 #include "demo_guix_pixelmaps_4444argb.c"
58 
59 char test_comment[256];
60 
61 static int pixelmap_id = GX_PIXELMAP_ID_COMPRESS_ALPHA_4444ARGB;
62 static GX_BOOL test_wrong_map_format = GX_FALSE;
63 static GX_BOOL test_blend_wrong_map_format = GX_FALSE;
64 static GX_PIXELMAP test_map;
65 
66 static int x_shift = -50;
67 static int blend_alpha = 255;
window_1_draw(GX_WINDOW * window)68 VOID window_1_draw(GX_WINDOW *window)
69 {
70 int xpos;
71 int ypos;
72 GX_PIXELMAP *map;
73 
74     xpos = window->gx_window_client.gx_rectangle_left + x_shift;
75     ypos = window->gx_window_client.gx_rectangle_top - 10;
76 
77     gx_widget_pixelmap_get((GX_WIDGET *)window, pixelmap_id, &map);
78 
79     if(test_wrong_map_format || test_blend_wrong_map_format)
80     {
81         xpos = window->gx_window_client.gx_rectangle_left;
82         ypos = window->gx_window_client.gx_rectangle_top;
83 
84         memset(&test_map, 0, sizeof(GX_PIXELMAP));
85         test_map.gx_pixelmap_format = GX_COLOR_FORMAT_8BIT_PALETTE;
86         test_map.gx_pixelmap_width = 100;
87         test_map.gx_pixelmap_height = 100;
88         map = &test_map;
89     }
90 
91     if(test_blend_wrong_map_format)
92     {
93         /* Test blend pixlemap that is not suported. */
94         root->gx_window_root_canvas->gx_canvas_display->gx_display_driver_pixelmap_blend(GX_NULL, xpos, ypos, map, blend_alpha);
95 
96         /* Test blend when pixelmap has alpha. */
97         test_map.gx_pixelmap_format = GX_COLOR_FORMAT_4444ARGB;
98         test_map.gx_pixelmap_flags = GX_PIXELMAP_ALPHA;
99         root->gx_window_root_canvas->gx_canvas_display->gx_display_driver_pixelmap_blend(GX_NULL, xpos, ypos, map, blend_alpha);
100     }
101     else
102     {
103         gx_canvas_pixelmap_draw(xpos, ypos, map);
104     }
105 }
106 
107 /* This thread simulates user input.  Its priority is lower
108    than the GUIX thread, so that GUIX finishes an operation
109    before this thread is able to issue the next command. */
control_thread_entry(ULONG input)110 static VOID control_thread_entry(ULONG input)
111 {
112 int frame_id = 1;
113 
114     gx_widget_draw_set((GX_WIDGET *)&main_window.main_window_window_1, window_1_draw);
115 
116     for(x_shift = -50; x_shift <= 50; x_shift += 100)
117     {
118         sprintf(test_comment, "draw pixelmap, compressed, with alpha, x_shift = %d", x_shift);
119     	gx_validation_set_frame_id(frame_id++);
120     	gx_validation_set_frame_comment(test_comment);
121     	gx_validation_screen_refresh();
122     }
123 
124     test_wrong_map_format = GX_TRUE;
125     gx_validation_set_frame_id(frame_id++);
126     gx_validation_set_frame_comment("draw wrong map format");
127     gx_validation_screen_refresh();
128 
129     test_blend_wrong_map_format = GX_TRUE;
130     gx_validation_set_frame_id(frame_id++);
131     gx_validation_set_frame_comment("blend wrong map format");
132     gx_validation_screen_refresh();
133     /* Signal the end of the test case.  Verify the output. */
134     gx_validation_end();
135 
136     exit(0);
137 }
138 
139 
140 
141 
142 
143