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 
23 #define GX_SOURCE_CODE
24 
25 
26 /* Include necessary system files.  */
27 
28 #include "gx_api.h"
29 #include "gx_display.h"
30 
31 /**************************************************************************/
32 /*                                                                        */
33 /*  FUNCTION                                               RELEASE        */
34 /*                                                                        */
35 /*    _gx_display_driver_16bpp_horizontal_line_draw       PORTABLE C      */
36 /*                                                           6.1          */
37 /*  AUTHOR                                                                */
38 /*                                                                        */
39 /*    Kenneth Maxwell, Microsoft Corporation                              */
40 /*                                                                        */
41 /*  DESCRIPTION                                                           */
42 /*                                                                        */
43 /*    Generic 16bpp horizontal line draw function.                        */
44 /*                                                                        */
45 /*  INPUT                                                                 */
46 /*                                                                        */
47 /*    context                               Drawing context               */
48 /*    xstart                                x-coord of left endpoint      */
49 /*    xend                                  x-coord of right endpoint     */
50 /*    ypos                                  y-coord of line top           */
51 /*    width                                 Width (height) of the line    */
52 /*    color                                 Color of line to write        */
53 /*                                                                        */
54 /*  OUTPUT                                                                */
55 /*                                                                        */
56 /*    NOne                                                                */
57 /*                                                                        */
58 /*  CALLS                                                                 */
59 /*                                                                        */
60 /*    _gx_display_driver_horizontal_line_alpha_draw                       */
61 /*                                          Display driver basic          */
62 /*                                            horiztonal alpha line draw  */
63 /*                                            route                       */
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 /**************************************************************************/
_gx_display_driver_16bpp_horizontal_line_draw(GX_DRAW_CONTEXT * context,INT xstart,INT xend,INT ypos,INT width,GX_COLOR color)78 VOID _gx_display_driver_16bpp_horizontal_line_draw(GX_DRAW_CONTEXT *context, INT xstart, INT xend, INT ypos, INT width, GX_COLOR color)
79 {
80 INT     row;
81 INT     column;
82 USHORT *put;
83 USHORT *rowstart;
84 INT     len = xend - xstart + 1;
85 
86 #if defined GX_BRUSH_ALPHA_SUPPORT
87 GX_UBYTE alpha;
88 
89     alpha = context -> gx_draw_context_brush.gx_brush_alpha;
90     if (alpha == 0)
91     {
92         /* Nothing to drawn. Just return. */
93         return;
94     }
95 
96     if (alpha != 0xff)
97     {
98         _gx_display_driver_horizontal_line_alpha_draw(context, xstart, xend, ypos, width, color, alpha);
99         return;
100     }
101 #endif
102 
103     /* pick up start address of canvas memory */
104     rowstart = (USHORT *)context -> gx_draw_context_memory;
105 
106     /* calculate start of row address */
107     rowstart += context -> gx_draw_context_pitch * ypos;
108 
109     /* calculate pixel address */
110     rowstart += xstart;
111     /* draw 1-pixel hi lines to fill width */
112     for (row = 0; row < width; row++)
113     {
114         put = rowstart;
115 
116         /* draw one line, left to right */
117         for (column = 0; column < len; column++)
118         {
119             *put++ = (USHORT)color;
120         }
121         rowstart += context -> gx_draw_context_pitch;
122     }
123 
124 }
125