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 #include "gx_canvas.h"
8
9 TEST_PARAM test_parameter = {
10 "guix_canvas_glyphs_draw", /* Test name */
11 0, 0, 640, 480 /* 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_dave2d_graphics_driver_setup_565rgb
47 #undef win32_dave2d_graphics_driver_setup_565rgb
48 #endif
49 #define win32_dave2d_graphics_driver_setup_565rgb gx_validation_dave2d_graphics_driver_setup_565rgb
50
51
52 #ifdef WIN32
53 #undef WIN32
54 #endif
55
56 #include "gx_validation_wrapper.h"
57
58 #include "demo_synergy_glyph_draw_16bpp.c"
59
60 char test_comment[256];
61
62 GX_PROMPT *test_prompt = &window.window_prompt_4;
63 GX_UBYTE test_string[] = {'c', 'h', 0xff, 0x00};
64 GX_UBYTE test_string_2[] = {'t', 'e', 's', 't', '2', 0xc0, 0x80, 0x00};
65
test_window_draw(GX_WINDOW * window)66 void test_window_draw(GX_WINDOW *window)
67 {
68 int xpos;
69 int ypos;
70 GX_DRAW_CONTEXT context;
71 GX_STRING string;
72
73 gx_window_background_draw(window);
74
75 xpos = window->gx_widget_size.gx_rectangle_left + 10;
76 ypos = window->gx_widget_size.gx_rectangle_top + 100;
77
78 /* Test compressed glyph clip. */
79 gx_prompt_draw(test_prompt);
80
81 gx_context_line_color_set(GX_COLOR_ID_TEXT);
82 gx_context_font_set(GX_FONT_ID_CHINESE_1BIT_COMPRESS);
83 gx_canvas_text_draw(xpos, ypos, "compress", 8);
84
85 /* Test draw width invalid glyph data. */
86 ypos += 60;
87 gx_canvas_text_draw(xpos, ypos, (char *)test_string_2, -1);
88
89 ypos += 60;
90 gx_canvas_text_draw(xpos, ypos, (char *)test_string, -1);
91
92 ypos += 100;
93 gx_context_font_set(GX_FONT_ID_SYSTEM);
94 gx_canvas_text_draw(xpos, ypos, (char *)test_string, -1);
95
96 /* Test draw width invalid glyph data. */
97 ypos += 60;
98 gx_canvas_text_draw(xpos, ypos, (char *)test_string_2, -1);
99
100 /* Test draw with invalid context. */
101 gx_context_font_set(100);
102 context.gx_draw_context_brush.gx_brush_font = GX_NULL;
103 string.gx_string_ptr = (char *)test_string;
104 string.gx_string_length = sizeof(test_string) - 1;
105 _gx_canvas_glyphs_draw(&context, GX_NULL, &string, GX_NULL, GX_NULL);
106 _gx_canvas_glyphs_draw(&context, GX_NULL, GX_NULL, GX_NULL, GX_NULL);
107 }
108
109 /* This thread simulates user input. Its priority is lower
110 than the GUIX thread, so that GUIX finishes an operation
111 before this thread is able to issue the next command. */
control_thread_entry(ULONG input)112 static VOID control_thread_entry(ULONG input)
113 {
114 int frame_id = 1;
115 GX_RECTANGLE size;
116
117 gx_widget_draw_set(&window, test_window_draw);
118
119 gx_utility_rectangle_define(&size, -71, -93, 444, 12);
120 gx_widget_resize(test_prompt, &size);
121
122 gx_validation_set_frame_id(frame_id++);
123 gx_validation_set_frame_comment("Test compressed glyph draw");
124 gx_validation_screen_refresh();
125
126 /* Signal the end of the test case. Verify the output. */
127 gx_validation_end();
128
129 exit(0);
130 }
131
132
133