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_jpeg_draw_32bpp", /* Test name */
10    0 , 0, 800, 480  /* 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_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_jpeg_draw_32bpp.c"
57 
58 #define TEST_MEMORY_SIZE 100
59 
60 GX_UBYTE test_memory[TEST_MEMORY_SIZE];
61 char     test_comment[255];
62 
63 typedef struct MAP_INFO_STRUCT{
64     GX_RESOURCE_ID map_id;
65     char id_name[30];
66 }MAP_INFO;
67 
68 static MAP_INFO test_map_info_list[] ={
69     {GX_PIXELMAP_ID_RED_APPLE, "GX_PIXELMAP_ID_RED_APPLE"},
70     {GX_PIXELMAP_ID_FISH_SMALL_411, "GX_PIXELMAP_ID_FISH_SMALL_411"},
71     {GX_PIXELMAP_ID_FISH_SMALL_420, "GX_PIXELMAP_ID_FISH_SMALL_420"},
72     {GX_PIXELMAP_ID_FISH_SMALL_422, "GX_PIXELMAP_ID_FISH_SMALL_422"},
73     {GX_PIXELMAP_ID_FISH_SMALL_444, "GX_PIXELMAP_ID_FISH_SMALL_444"},
74     {GX_NULL, ""}
75 };
76 
test_pic_win_draw(GX_WINDOW * window)77 VOID test_pic_win_draw(GX_WINDOW *window)
78 {
79 int xpos;
80 int ypos;
81 GX_PIXELMAP *map;
82 
83     xpos = window->gx_window_client.gx_rectangle_left - 10;
84     ypos = window->gx_window_client.gx_rectangle_top - 10;
85 
86     gx_window_draw(window);
87 
88     gx_widget_pixelmap_get((GX_WIDGET *)window, window->gx_window_wallpaper, &map);
89     gx_canvas_pixelmap_draw(xpos, ypos, map);
90 }
91 /* This thread simulates user input.  Its priority is lower
92    than the GUIX thread, so that GUIX finishes an operation
93    before this thread is able to issue the next command. */
control_thread_entry(ULONG input)94 static VOID control_thread_entry(ULONG input)
95 {
96 int frame_id = 1;
97 int index = 0;
98 
99     gx_widget_draw_set((GX_WIDGET *)&main_window.main_window_pic_window, test_pic_win_draw);
100 
101     while(test_map_info_list[index].map_id != GX_NULL)
102     {
103         gx_validation_set_frame_id(frame_id++);
104 
105         /* Set the wallpaper of the window.  */
106         gx_window_wallpaper_set(&main_window.main_window_pic_window, test_map_info_list[index].map_id, test_map_info_list[index].map_id);
107 
108         /* Set test comment.  */
109         gx_validation_set_frame_comment(test_map_info_list[index].id_name);
110 
111         /* Force a screen refresh. */
112         gx_validation_screen_refresh();
113 
114         index++;
115     }
116 
117     for(index = 0; index < 3; index++)
118     {
119         switch(index)
120         {
121         case 0:
122             gx_system_memory_allocator_set(GX_NULL, decode_memory_free);
123             sprintf(test_comment, "set memory allocate function to GX_NULL");
124             break;
125 
126         case 1:
127             gx_system_memory_allocator_set(decode_memory_allocate, GX_NULL);
128             sprintf(test_comment, "set memory free function to GX_NULL");
129             break;
130 
131         case 2:
132             tx_byte_pool_delete(&decode_pool);
133             tx_byte_pool_create(&decode_pool, "test_memory", test_memory, TEST_MEMORY_SIZE);
134             gx_system_memory_allocator_set(decode_memory_allocate, decode_memory_free);
135             sprintf(test_comment, "resize memory pool to not enought for decode");
136             break;
137         }
138 
139         gx_validation_set_frame_id(frame_id++);
140 
141         gx_validation_set_frame_comment(test_comment);
142 
143         /* Force a screen refresh. */
144         gx_validation_screen_refresh();
145     }
146     /* Signal the end of the test case.  Verify the output. */
147     gx_validation_end();
148 
149     exit(0);
150 }
151 
152 
153 
154 
155 
156