1 /**************************************************************************/ 2 /* */ 3 /* Copyright (c) Microsoft Corporation. All rights reserved. */ 4 /* */ 5 /* This software is licensed under the Microsoft Software License */ 6 /* Terms for Microsoft Azure RTOS. Full text of the license can be */ 7 /* found in the LICENSE file at https://aka.ms/AzureRTOS_EULA */ 8 /* and in the root directory of this software. */ 9 /* */ 10 /**************************************************************************/ 11 12 13 /**************************************************************************/ 14 /**************************************************************************/ 15 /** */ 16 /** GUIX Component */ 17 /** */ 18 /** Display Management (Display) */ 19 /** */ 20 /**************************************************************************/ 21 22 #define GX_SOURCE_CODE 23 24 25 /* Include necessary system files. */ 26 27 #include "gx_api.h" 28 #include "gx_system.h" 29 #include "gx_utility.h" 30 #include "gx_display.h" 31 32 33 /**************************************************************************/ 34 /* */ 35 /* FUNCTION RELEASE */ 36 /* */ 37 /* _gx_display_driver_8bpp_rotated_glyph_4bit_draw PORTABLE C */ 38 /* 6.1.4 */ 39 /* AUTHOR */ 40 /* */ 41 /* Kenneth Maxwell, Microsoft Corporation */ 42 /* */ 43 /* DESCRIPTION */ 44 /* */ 45 /* This draws the specified text using the current context, */ 46 /* clipped to one viewport */ 47 /* */ 48 /* INPUT */ 49 /* */ 50 /* context Draw context */ 51 /* draw_position The X and Y coordinate where */ 52 /* the glyph is drawn to */ 53 /* string String to draw */ 54 /* count Count of string characters */ 55 /* view view to clip drawing within */ 56 /* */ 57 /* OUTPUT */ 58 /* */ 59 /* None */ 60 /* */ 61 /* CALLS */ 62 /* */ 63 /* None */ 64 /* */ 65 /* CALLED BY */ 66 /* */ 67 /* _gx_canvas_text_draw */ 68 /* */ 69 /* RELEASE HISTORY */ 70 /* */ 71 /* DATE NAME DESCRIPTION */ 72 /* */ 73 /* 02-02-2021 Kenneth Maxwell Initial Version 6.1.4 */ 74 /* */ 75 /**************************************************************************/ _gx_display_driver_8bpp_rotated_glyph_4bit_draw(GX_DRAW_CONTEXT * context,GX_RECTANGLE * draw_area,GX_POINT * map_offset,GX_CONST GX_GLYPH * glyph)76VOID _gx_display_driver_8bpp_rotated_glyph_4bit_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 pixel_width = 0; 82 UINT leading_pixel; 83 UINT trailing_pixel; 84 GX_UBYTE text_color; 85 UINT y_height; 86 GX_UBYTE alpha; 87 UINT pitch; 88 UINT index; 89 GX_UBYTE *put; 90 GX_UBYTE *draw_start; 91 GX_VALUE rotated_map_offset_x; 92 GX_VALUE rotated_map_offset_y; 93 GX_VALUE rotated_left; 94 GX_VALUE rotated_top; 95 96 text_color = (GX_UBYTE)(context -> gx_draw_context_brush.gx_brush_line_color + 15); 97 pixel_width = (UINT)(draw_area -> gx_rectangle_bottom - draw_area -> gx_rectangle_top + 1); 98 99 y_height = (UINT)(draw_area -> gx_rectangle_right - draw_area -> gx_rectangle_left + 1); 100 101 if (context -> gx_draw_context_display -> gx_display_rotation_angle == GX_SCREEN_ROTATION_CW) 102 { 103 rotated_left = draw_area -> gx_rectangle_top; 104 rotated_top = (GX_VALUE)(context -> gx_draw_context_canvas -> gx_canvas_x_resolution - draw_area -> gx_rectangle_right - 1); 105 106 rotated_map_offset_x = map_offset -> gx_point_y; 107 rotated_map_offset_y = (GX_VALUE)(glyph -> gx_glyph_width - map_offset -> gx_point_x - (GX_VALUE)y_height); 108 } 109 else 110 { 111 rotated_left = (GX_VALUE)(context -> gx_draw_context_canvas -> gx_canvas_display_offset_y - draw_area -> gx_rectangle_bottom - 1); 112 rotated_top = draw_area -> gx_rectangle_left; 113 114 rotated_map_offset_x = (GX_VALUE)(glyph -> gx_glyph_height - map_offset -> gx_point_y - (GX_VALUE)pixel_width); 115 rotated_map_offset_y = map_offset -> gx_point_x; 116 } 117 118 leading_pixel = (rotated_map_offset_x & 1); 119 120 pixel_width -= leading_pixel; 121 122 trailing_pixel = pixel_width & 1; 123 124 pixel_width = pixel_width >> 1; 125 126 /* Find the width of the glyph. */ 127 pitch = glyph -> gx_glyph_height; 128 129 /* Make it byte-aligned. */ 130 pitch = (pitch + 1) >> 1; 131 132 glyph_row = (GX_UBYTE *)glyph -> gx_glyph_map; 133 134 if (rotated_map_offset_y) 135 { 136 glyph_row = glyph_row + ((INT)pitch * rotated_map_offset_y); 137 } 138 139 glyph_row += (rotated_map_offset_x >> 1); 140 141 draw_start = (GX_UBYTE *)context -> gx_draw_context_memory; 142 draw_start += context -> gx_draw_context_pitch * rotated_top; 143 draw_start += rotated_left; 144 145 for (row = 0; row < y_height; row++) 146 { 147 glyph_data = glyph_row; 148 149 put = draw_start; 150 151 if (leading_pixel) 152 { 153 alpha = (*glyph_data) & 0x0f; 154 155 *put = (GX_UBYTE)(text_color - alpha); 156 put++; 157 158 glyph_data++; 159 } 160 for (index = 0; index < pixel_width; index++) 161 { 162 alpha = (*glyph_data) & 0xf0; 163 164 *put = (GX_UBYTE)(text_color - (alpha >> 4)); 165 put++; 166 167 alpha = (*glyph_data) & 0x0f; 168 *put = (GX_UBYTE)(text_color - alpha); 169 put++; 170 glyph_data++; 171 } 172 173 if (trailing_pixel) 174 { 175 alpha = (*glyph_data) & 0xf0; 176 *put = (GX_UBYTE)(text_color - (alpha >> 4)); 177 put++; 178 } 179 180 glyph_row += pitch; 181 draw_start += context -> gx_draw_context_pitch; 182 } 183 } 184 185