1 /***************************************************************************
2 * Copyright (c) 2024 Microsoft Corporation
3 *
4 * This program and the accompanying materials are made available under the
5 * terms of the MIT License which is available at
6 * https://opensource.org/licenses/MIT.
7 *
8 * SPDX-License-Identifier: MIT
9 **************************************************************************/
10
11
12 /**************************************************************************/
13 /**************************************************************************/
14 /** */
15 /** GUIX Component */
16 /** */
17 /** Display Management (Display) */
18 /** */
19 /**************************************************************************/
20
21 #define GX_SOURCE_CODE
22
23
24 /* Include necessary system files. */
25
26 #include "gx_api.h"
27 #include "gx_system.h"
28 #include "gx_utility.h"
29 #include "gx_display.h"
30
31
32 /**************************************************************************/
33 /* */
34 /* FUNCTION RELEASE */
35 /* */
36 /* _gx_display_driver_generic_rotated_glyph_8bit_draw PORTABLE C */
37 /* 6.1.3 */
38 /* AUTHOR */
39 /* */
40 /* Kenneth Maxwell, Microsoft Corporation */
41 /* */
42 /* DESCRIPTION */
43 /* */
44 /* This function draws the specified text using the current context, */
45 /* clipped to one viewport */
46 /* */
47 /* INPUT */
48 /* */
49 /* context Draw context */
50 /* draw_position The X and Y coordinate where */
51 /* the glyph is drawn to */
52 /* string String to draw */
53 /* count Count of string characters */
54 /* view view to clip drawing within */
55 /* */
56 /* OUTPUT */
57 /* */
58 /* None */
59 /* */
60 /* CALLS */
61 /* */
62 /* _gx_display_driver_565rgb_pixel_blend Call display driver pixel */
63 /* blend function */
64 /* */
65 /* CALLED BY */
66 /* */
67 /* GUIX internal code */
68 /* */
69 /* RELEASE HISTORY */
70 /* */
71 /* DATE NAME DESCRIPTION */
72 /* */
73 /* 12-31-2020 Kenneth Maxwell Initial Version 6.1.3 */
74 /* */
75 /**************************************************************************/
_gx_display_driver_generic_rotated_glyph_8bit_draw(GX_DRAW_CONTEXT * context,GX_RECTANGLE * draw_area,GX_POINT * map_offset,GX_CONST GX_GLYPH * glyph)76 VOID _gx_display_driver_generic_rotated_glyph_8bit_draw(GX_DRAW_CONTEXT *context, GX_RECTANGLE *draw_area, GX_POINT *map_offset, GX_CONST GX_GLYPH *glyph)
77 {
78 GX_UBYTE *glyph_row;
79 GX_UBYTE *glyph_data;
80 UINT row;
81 UINT col;
82 UINT pixel_width = 0;
83 GX_COLOR text_color;
84 UINT y_height;
85 GX_UBYTE alpha1;
86 GX_UBYTE brush_alpha = 0xff;
87 GX_VALUE rotated_map_offset_x;
88 GX_VALUE rotated_map_offset_y;
89 GX_VALUE rotated_left;
90 GX_VALUE rotated_top;
91 VOID (*blend_func)(GX_DRAW_CONTEXT *context, INT x, INT y, GX_COLOR color, GX_UBYTE alpha);
92
93 #if defined(GX_BRUSH_ALPHA_SUPPORT)
94 brush_alpha = context -> gx_draw_context_brush.gx_brush_alpha;
95 if (brush_alpha == 0)
96 {
97 return;
98 }
99 #endif
100
101 GX_SET_BLEND_FUNCTION(blend_func, context->gx_draw_context_display->gx_display_color_format)
102
103 text_color = context -> gx_draw_context_brush.gx_brush_line_color;
104
105 pixel_width = (UINT)(draw_area -> gx_rectangle_bottom - draw_area -> gx_rectangle_top + 1);
106 y_height = (UINT)(draw_area -> gx_rectangle_right - draw_area -> gx_rectangle_left + 1);
107
108 if (context -> gx_draw_context_display -> gx_display_rotation_angle == GX_SCREEN_ROTATION_CW)
109 {
110 rotated_left = draw_area -> gx_rectangle_top;
111 rotated_top = (GX_VALUE)(context -> gx_draw_context_canvas -> gx_canvas_x_resolution - draw_area -> gx_rectangle_right - 1);
112
113 rotated_map_offset_x = map_offset -> gx_point_y;
114 rotated_map_offset_y = (GX_VALUE)(glyph -> gx_glyph_width - map_offset -> gx_point_x - (GX_VALUE)y_height);
115 }
116 else
117 {
118 rotated_left = (GX_VALUE)(context -> gx_draw_context_canvas -> gx_canvas_display_offset_y - draw_area -> gx_rectangle_bottom - 1);
119 rotated_top = draw_area -> gx_rectangle_left;
120
121 rotated_map_offset_x = (GX_VALUE)(glyph -> gx_glyph_height - map_offset -> gx_point_y - (GX_VALUE)pixel_width);
122 rotated_map_offset_y = map_offset -> gx_point_x;
123 }
124
125 glyph_row = (GX_UBYTE *)glyph -> gx_glyph_map;
126
127 if (rotated_map_offset_y)
128 {
129 glyph_row = glyph_row + (glyph -> gx_glyph_height * rotated_map_offset_y);
130 }
131
132 glyph_row += rotated_map_offset_x;
133
134 if (brush_alpha == 0xff)
135 {
136 for (row = 0; row < y_height; row++)
137 {
138 glyph_data = glyph_row;
139
140 for (col = 0; col < pixel_width; col++)
141 {
142 alpha1 = *glyph_data;
143
144 if (alpha1 > 0)
145 {
146 blend_func(context,
147 rotated_left + (GX_VALUE)col,
148 rotated_top + (GX_VALUE)row,
149 text_color, (GX_UBYTE)alpha1);
150 }
151 glyph_data++;
152 }
153 glyph_row += glyph -> gx_glyph_height;
154 }
155 }
156 #if defined(GX_BRUSH_ALPHA_SUPPORT)
157 else
158 {
159 for (row = 0; row < y_height; row++)
160 {
161 glyph_data = glyph_row;
162
163 for (col = 0; col < pixel_width; col++)
164 {
165 alpha1 = *glyph_data;
166 alpha1 = (GX_UBYTE)(alpha1 * brush_alpha / 255);
167
168 if (alpha1 > 0)
169 {
170 blend_func(context,
171 rotated_left + (GX_VALUE)col,
172 rotated_top + (GX_VALUE)row,
173 text_color, (GX_UBYTE)alpha1);
174 }
175
176 glyph_data++;
177 }
178 glyph_row += glyph -> gx_glyph_height;
179 }
180 }
181 #endif
182 }
183
184