1 /* This is a small demo of the high-performance GUIX graphics framework. */
2
3
4 #include <stdio.h>
5 #include "tx_api.h"
6 #include "gx_api.h"
7 #include "gx_validation_utility.h"
8
9 TEST_PARAM test_parameter = {
10 "guix_text_rotation", /* Test name */
11 0, 0, 639, 479 /* 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_24xrgb
47 #undef win32_graphics_driver_setup_24xrgb
48 #endif
49 #define win32_graphics_driver_setup_24xrgb gx_validation_graphics_driver_setup_24xrgb
50
51
52 #ifdef WIN32
53 #undef WIN32
54 #endif
55
56 #include "gx_validation_wrapper.h"
57
58 #include "demo_text_rotation.c"
59
60 /*NOTICE: Number of xpos_value and ypos_valus should be same.*/
61 extern INT text_angle;
62 extern GX_RESOURCE_ID text_color;
63
64 char test_comment[256];
65 GX_CONST GX_UBYTE utf8_text[10] = {0xe5, 0xa4, 0x9a, 0xe8, 0xa1, 0x8c, 0 };
66
67 /* This thread simulates user input. Its priority is lower
68 than the GUIX thread, so that GUIX finishes an operation
69 before this thread is able to issue the next command. */
control_thread_entry(ULONG input)70 static VOID control_thread_entry(ULONG input)
71 {
72 int frame_id = 1;
73 int angle;
74 int xcenter, ycenter;
75 GX_WINDOW_ROOT *window_root = NULL;
76
77 gx_window_root_find((GX_WIDGET *)&screen_base.screen_base_text_window, &window_root);
78 if(window_root)
79 {
80 for(angle = 0; angle < 360; angle++)
81 {
82 if(angle < 180)
83 {
84 text_color = GX_COLOR_ID_RED;
85 if(angle == 0)
86 {
87 text_angle = 360;
88 }
89 else
90 {
91 text_angle = angle - 720;
92 }
93 }
94 else
95 {
96 text_color = GX_COLOR_ID_GREEN;
97 text_angle = angle + 360;
98 }
99
100 /* Inform the validation system
101 (1) Frame ID, which identifies a specific test configuration;
102 (2) Start recording frame on the next toggle operation.
103 */
104 gx_validation_set_frame_id(frame_id++);
105 sprintf(test_comment, "color id = %d, text angle = %d", (int)text_color, text_angle);
106 gx_validation_set_frame_comment(test_comment);
107
108 gx_system_dirty_mark((GX_WIDGET *)&screen_base.screen_base_text_window);
109 gx_system_dirty_mark((GX_WIDGET *)&screen_base.screen_base_text_window_4bpp);
110 gx_system_dirty_mark((GX_WIDGET *)&screen_base.screen_base_text_window_1bpp);
111 gx_system_dirty_mark((GX_WIDGET *)&screen_base.screen_base_dynamic_text_window);
112
113 /* Force a screen refresh. */
114 gx_validation_screen_refresh();
115 }
116
117 /* Test text rotation with text not availlable in font */
118 gx_canvas_drawing_initiate(window_root->gx_window_root_canvas, window_root->gx_widget_first_child, &window_root->gx_widget_size);
119 gx_context_line_color_set(text_color);
120 gx_context_fill_color_set(text_color);
121 gx_context_font_set(GX_FONT_ID_SMALL_BOLD);
122 xcenter = (window_root->gx_widget_size.gx_rectangle_left + window_root->gx_widget_size.gx_rectangle_right) >> 1;
123 ycenter = (window_root->gx_widget_size.gx_rectangle_top + window_root->gx_widget_size.gx_rectangle_bottom) >> 1;
124 gx_canvas_rotated_text_draw((GX_CHAR *)utf8_text, xcenter, ycenter, 30);
125 gx_canvas_drawing_complete(window_root->gx_window_root_canvas, GX_TRUE);
126 }
127 /* Signal the end of the test case. Verify the output. */
128 gx_validation_end();
129
130 exit(0);
131 }
132