| 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_glyph_8bit_draw          PORTABLE C      */ | 
    
    | 37 |  |  | /*                                                           6.1          */ | 
    
    | 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_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 |  |  | /*  05-19-2020     Kenneth Maxwell          Initial Version 6.0           */ | 
    
    | 74 |  |  | /*  09-30-2020     Kenneth Maxwell          Modified comment(s),          */ | 
    
    | 75 |  |  | /*                                            resulting in version 6.1    */ | 
    
    | 76 |  |  | /*                                                                        */ | 
    
    | 77 |  |  | /**************************************************************************/ | 
    
    | 78 |  | 4668470 | VOID _gx_display_driver_generic_glyph_8bit_draw(GX_DRAW_CONTEXT *context, GX_RECTANGLE *draw_area, GX_POINT *map_offset, GX_CONST GX_GLYPH *glyph) | 
    
    | 79 |  |  | { | 
    
    | 80 |  |  | GX_DISPLAY *display; | 
    
    | 81 |  |  | GX_UBYTE   *glyph_row; | 
    
    | 82 |  |  | GX_UBYTE   *glyph_data; | 
    
    | 83 |  |  | UINT        row; | 
    
    | 84 |  |  | UINT        col; | 
    
    | 85 |  | 4668470 | UINT        pixel_width = 0; | 
    
    | 86 |  |  | GX_COLOR    text_color; | 
    
    | 87 |  |  | UINT        y_height; | 
    
    | 88 |  |  | GX_UBYTE    alpha1; | 
    
    | 89 |  | 4668470 | GX_UBYTE    brush_alpha = 0xff; | 
    
    | 90 |  |  |  | 
    
    | 91 |  |  | #if defined (GX_BRUSH_ALPHA_SUPPORT) | 
    
    | 92 |  | 4668470 |     brush_alpha = context -> gx_draw_context_brush.gx_brush_alpha; | 
    
    | 93 | ✓✓ | 4668470 |     if (brush_alpha == 0) | 
    
    | 94 |  |  |     { | 
    
    | 95 |  | 1876 |         return; | 
    
    | 96 |  |  |     } | 
    
    | 97 |  |  | #endif | 
    
    | 98 |  |  |  | 
    
    | 99 |  | 4666594 |     text_color =  context -> gx_draw_context_brush.gx_brush_line_color; | 
    
    | 100 |  | 4666594 |     pixel_width = (UINT)(draw_area -> gx_rectangle_right - draw_area -> gx_rectangle_left + 1); | 
    
    | 101 |  |  |  | 
    
    | 102 |  |  |     /* pickup pointer to current display driver */ | 
    
    | 103 |  | 4666594 |     display = context -> gx_draw_context_display; | 
    
    | 104 |  |  |  | 
    
    | 105 | ✓✓ | 4666594 |     if (display -> gx_display_driver_pixel_blend == GX_NULL) | 
    
    | 106 |  |  |     { | 
    
    | 107 |  | 8953 |         return; | 
    
    | 108 |  |  |     } | 
    
    | 109 |  |  |  | 
    
    | 110 |  | 4657641 |     glyph_row = (GX_UBYTE *)glyph -> gx_glyph_map; | 
    
    | 111 |  |  |  | 
    
    | 112 | ✓✓ | 4657641 |     if (map_offset -> gx_point_y) | 
    
    | 113 |  |  |     { | 
    
    | 114 |  | 16034 |         glyph_row = glyph_row + (glyph -> gx_glyph_width * map_offset -> gx_point_y); | 
    
    | 115 |  |  |     } | 
    
    | 116 |  |  |  | 
    
    | 117 |  | 4657641 |     glyph_row += map_offset -> gx_point_x; | 
    
    | 118 |  |  |  | 
    
    | 119 |  | 4657641 |     y_height = (UINT)(draw_area -> gx_rectangle_bottom - draw_area -> gx_rectangle_top + 1); | 
    
    | 120 |  |  |  | 
    
    | 121 | ✓✓ | 4657641 |     if (brush_alpha == 0xff) | 
    
    | 122 |  |  |     { | 
    
    | 123 | ✓✓ | 50786456 |         for (row = 0; row < y_height; row++) | 
    
    | 124 |  |  |         { | 
    
    | 125 |  | 46558140 |             glyph_data = glyph_row; | 
    
    | 126 |  |  |  | 
    
    | 127 | ✓✓ | 404973557 |             for (col = 0; col < pixel_width; col++) | 
    
    | 128 |  |  |             { | 
    
    | 129 |  | 358415417 |                 alpha1 = *glyph_data; | 
    
    | 130 |  |  |  | 
    
    | 131 | ✓✓ | 358415417 |                 if (alpha1 > 0) | 
    
    | 132 |  |  |                 { | 
    
    | 133 |  | 213772112 |                     display -> gx_display_driver_pixel_blend(context, | 
    
    | 134 |  | 213772112 |                                                            draw_area -> gx_rectangle_left + (GX_VALUE)col, | 
    
    | 135 |  | 213772112 |                                                            draw_area -> gx_rectangle_top + (GX_VALUE)row, | 
    
    | 136 |  |  |                                                            text_color, (GX_UBYTE)alpha1); | 
    
    | 137 |  |  |                 } | 
    
    | 138 |  | 358415417 |                 glyph_data++; | 
    
    | 139 |  |  |             } | 
    
    | 140 |  | 46558140 |             glyph_row += glyph -> gx_glyph_width; | 
    
    | 141 |  |  |         } | 
    
    | 142 |  |  |     } | 
    
    | 143 |  |  | #if defined (GX_BRUSH_ALPHA_SUPPORT) | 
    
    | 144 |  |  |     else | 
    
    | 145 |  |  |     { | 
    
    | 146 | ✓✓ | 5210071 |         for (row = 0; row < y_height; row++) | 
    
    | 147 |  |  |         { | 
    
    | 148 |  | 4780746 |             glyph_data = glyph_row; | 
    
    | 149 |  |  |  | 
    
    | 150 | ✓✓ | 41989827 |             for (col = 0; col < pixel_width; col++) | 
    
    | 151 |  |  |             { | 
    
    | 152 |  | 37209081 |                 alpha1 = *glyph_data; | 
    
    | 153 |  | 37209081 |                 alpha1 = (GX_UBYTE)(alpha1 * brush_alpha / 255); | 
    
    | 154 |  |  |  | 
    
    | 155 | ✓✓ | 37209081 |                 if (alpha1 > 0) | 
    
    | 156 |  |  |                 { | 
    
    | 157 |  | 21315988 |                     display -> gx_display_driver_pixel_blend(context, | 
    
    | 158 |  | 21315988 |                                                            draw_area -> gx_rectangle_left + (GX_VALUE)col, | 
    
    | 159 |  | 21315988 |                                                            draw_area -> gx_rectangle_top + (GX_VALUE)row, | 
    
    | 160 |  |  |                                                            text_color, (GX_UBYTE)alpha1); | 
    
    | 161 |  |  |                 } | 
    
    | 162 |  |  |  | 
    
    | 163 |  | 37209081 |                 glyph_data++; | 
    
    | 164 |  |  |             } | 
    
    | 165 |  | 4780746 |             glyph_row += glyph -> gx_glyph_width; | 
    
    | 166 |  |  |         } | 
    
    | 167 |  |  |     } | 
    
    | 168 |  |  | #endif | 
    
    | 169 |  |  | } | 
    
    | 170 |  |  |  |