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_display.h" 28 29 30 /**************************************************************************/ 31 /* */ 32 /* FUNCTION RELEASE */ 33 /* */ 34 /* _gx_display_driver_1bpp_vertical_pattern_line_draw PORTABLE C */ 35 /* 6.1 */ 36 /* AUTHOR */ 37 /* */ 38 /* Kenneth Maxwell, Microsoft Corporation */ 39 /* */ 40 /* DESCRIPTION */ 41 /* */ 42 /* Vertical pattern line draw function for 1bpp display driver. */ 43 /* */ 44 /* INPUT */ 45 /* */ 46 /* context Drawing context */ 47 /* ystart y-coord of top endpoint */ 48 /* yend y-coord of bottom endpoint */ 49 /* xpos x-coord of left edge */ 50 /* */ 51 /* OUTPUT */ 52 /* */ 53 /* None */ 54 /* */ 55 /* CALLS */ 56 /* */ 57 /* None */ 58 /* */ 59 /* CALLED BY */ 60 /* */ 61 /* GUIX Internal Code */ 62 /* */ 63 /* RELEASE HISTORY */ 64 /* */ 65 /* DATE NAME DESCRIPTION */ 66 /* */ 67 /* 05-19-2020 Kenneth Maxwell Initial Version 6.0 */ 68 /* 09-30-2020 Kenneth Maxwell Modified comment(s), */ 69 /* resulting in version 6.1 */ 70 /* */ 71 /**************************************************************************/ _gx_display_driver_1bpp_vertical_pattern_line_draw(GX_DRAW_CONTEXT * context,INT ystart,INT yend,INT xpos)72VOID _gx_display_driver_1bpp_vertical_pattern_line_draw(GX_DRAW_CONTEXT *context, INT ystart, INT yend, INT xpos) 73 { 74 INT row; 75 GX_UBYTE *put; 76 GX_UBYTE *putrow; 77 ULONG pattern; 78 ULONG pattern_mask; 79 GX_UBYTE on_color; 80 GX_UBYTE off_color; 81 GX_UBYTE draw_mask; 82 INT stride; 83 84 /* pick up row pitch in bytes. */ 85 stride = (context -> gx_draw_context_pitch + 7) >> 3; 86 87 /* pick up starting address of canvas memory */ 88 putrow = (GX_UBYTE *)context -> gx_draw_context_memory; 89 putrow += ystart * stride; 90 putrow += (xpos >> 3); 91 92 /* pick up the requested pattern and mask */ 93 pattern = context -> gx_draw_context_brush.gx_brush_line_pattern; 94 pattern_mask = context -> gx_draw_context_brush.gx_brush_pattern_mask; 95 96 on_color = (GX_UBYTE)context -> gx_draw_context_brush.gx_brush_line_color & 0x01; 97 off_color = (GX_UBYTE)context -> gx_draw_context_brush.gx_brush_fill_color & 0x01; 98 draw_mask = (GX_UBYTE)(0x80 >> (xpos & 0x07)); 99 100 /* draw line from top to bottom */ 101 for (row = ystart; row <= yend; row++) 102 { 103 put = putrow; 104 105 if (pattern & pattern_mask) 106 { 107 if (on_color == 0x00) 108 { 109 *put = (GX_UBYTE)((*put) & (~draw_mask)); 110 } 111 else 112 { 113 *put |= draw_mask; 114 } 115 } 116 else 117 { 118 if (off_color == 0x00) 119 { 120 *put = (GX_UBYTE)((*put) & (~draw_mask)); 121 } 122 else 123 { 124 *put |= draw_mask; 125 } 126 } 127 128 pattern_mask >>= 1; 129 if (!pattern_mask) 130 { 131 pattern_mask = 0x80000000; 132 } 133 134 /* advance to the next scaneline */ 135 putrow += stride; 136 } 137 138 /* save current masks value back to brush */ 139 context -> gx_draw_context_brush.gx_brush_pattern_mask = pattern_mask; 140 } 141 142