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_display.h"
7 #include "gx_validation_utility.h"
8
9 TEST_PARAM test_parameter = {
10 "guix_332rgb_pixelmap_blend", /* Test name */
11 20, 30, 420, 400 /* 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_332rgb
47 #undef win32_graphics_driver_setup_332rgb
48 #endif
49 #define win32_graphics_driver_setup_332rgb gx_validation_graphics_driver_setup_332rgb
50
51
52 #ifdef WIN32
53 #undef WIN32
54 #endif
55
56 #include "gx_validation_wrapper.h"
57
58 #include "demo_all_widgets_332rgb.c"
59
60 char test_comment[256];
61
62 static int map_id_list[]={
63 GX_PIXELMAP_ID_SAVE_ICON_RAW,/*raw*/
64 GX_PIXELMAP_ID_ROTATE_APPLE,/*alpha*/
65 };
66
67 static int map_id = 0;
68
test_graphics_draw(GX_WINDOW * window)69 VOID test_graphics_draw(GX_WINDOW *window)
70 {
71 int xpos;
72 int ypos;
73 GX_BRUSH *brush;
74 GX_PIXELMAP *map;
75
76 gx_window_draw((GX_WINDOW*)window);
77
78 gx_context_brush_get(&brush);
79 brush->gx_brush_alpha = 128;
80
81 gx_context_pixelmap_get(map_id, &map);
82
83 xpos = window->gx_window_client.gx_rectangle_left;
84 ypos = window->gx_window_client.gx_rectangle_top;
85
86 gx_canvas_pixelmap_draw(xpos, ypos, map);
87
88 }
89
90 /* This thread simulates user input. Its priority is lower
91 than the GUIX thread, so that GUIX finishes an operation
92 before this thread is able to issue the next command. */
control_thread_entry(ULONG input)93 static VOID control_thread_entry(ULONG input)
94 {
95 int frame_id = 1;
96 int index;
97 GX_PIXELMAP invalid_map;
98
99 ToggleScreen(pShapesScreen, pButtonScreen);
100
101 gx_widget_draw_set((GX_WIDGET *)&shapes_screen.shapes_screen_graphics_window, test_graphics_draw);
102
103 root->gx_window_root_canvas->gx_canvas_display->gx_display_driver_pixel_blend = GX_NULL;
104 for(index = 0; index < (int)(sizeof(map_id_list)/sizeof(int)); index++)
105 {
106 map_id = map_id_list[index];
107 sprintf(test_comment, "set_pixel_blend_null = true, blend_alpha = 128, map_id = %d", map_id);
108 gx_validation_set_frame_id(frame_id++);
109 gx_validation_set_frame_comment(test_comment);
110 gx_validation_screen_refresh();
111 }
112
113 /* Set invalid format. */
114 invalid_map.gx_pixelmap_format = GX_COLOR_FORMAT_8BIT_PALETTE;
115 root->gx_window_root_canvas->gx_canvas_display->gx_display_driver_pixelmap_blend(GX_NULL, 0, 0, &invalid_map, 128);
116
117 /* Set invalid flag. */
118 invalid_map.gx_pixelmap_flags = GX_PIXELMAP_TRANSPARENT;
119 root->gx_window_root_canvas->gx_canvas_display->gx_display_driver_pixelmap_blend(GX_NULL, 0, 0, &invalid_map, 128);
120
121 /* Set invalid flag. */
122 invalid_map.gx_pixelmap_flags = GX_PIXELMAP_COMPRESSED;
123 root->gx_window_root_canvas->gx_canvas_display->gx_display_driver_pixelmap_blend(GX_NULL, 0, 0, &invalid_map, 128);
124
125 gx_validation_set_frame_id(frame_id++);
126 gx_validation_set_frame_comment("call pixelmap blend with invalid pixelmap");
127 gx_validation_screen_refresh();
128
129 /* Signal the end of the test case, Verify the outout. */
130 gx_validation_end();
131
132 exit(0);
133 }
134
135
136
137
138
139