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 #define GX_SOURCE_CODE
21 
22 
23 /* Include necessary system files.  */
24 
25 #include "gx_api.h"
26 #include "gx_display.h"
27 
28 /**************************************************************************/
29 /*                                                                        */
30 /*  FUNCTION                                               RELEASE        */
31 /*                                                                        */
32 /*    _gx_display_driver_8bpp_rotated_pixel_write         PORTABLE C      */
33 /*                                                           6.1.4        */
34 /*  AUTHOR                                                                */
35 /*                                                                        */
36 /*    Kenneth Maxwell, Microsoft Corporation                              */
37 /*                                                                        */
38 /*  DESCRIPTION                                                           */
39 /*                                                                        */
40 /*    Generic 8bpp color format rotated pixel write function.             */
41 /*                                                                        */
42 /*  INPUT                                                                 */
43 /*                                                                        */
44 /*    context                               Drawing context               */
45 /*    x                                     X coordinate                  */
46 /*    y                                     Y coordinate                  */
47 /*    color                                 Color of pixel to write       */
48 /*                                                                        */
49 /*  OUTPUT                                                                */
50 /*                                                                        */
51 /*    None                                                                */
52 /*                                                                        */
53 /*  CALLS                                                                 */
54 /*                                                                        */
55 /*    None                                                                */
56 /*                                                                        */
57 /*  CALLED BY                                                             */
58 /*                                                                        */
59 /*    GUIX Internal Code                                                  */
60 /*                                                                        */
61 /*  RELEASE HISTORY                                                       */
62 /*                                                                        */
63 /*    DATE              NAME                      DESCRIPTION             */
64 /*                                                                        */
65 /*  02-02-2021     Kenneth Maxwell          Initial Version 6.1.4         */
66 /*                                                                        */
67 /**************************************************************************/
_gx_display_driver_8bpp_rotated_pixel_write(GX_DRAW_CONTEXT * context,INT x,INT y,GX_COLOR color)68 VOID _gx_display_driver_8bpp_rotated_pixel_write(GX_DRAW_CONTEXT *context, INT x, INT y, GX_COLOR color)
69 {
70 GX_UBYTE *put = (GX_UBYTE *)context -> gx_draw_context_memory;
71 
72     /* Calculate address of scan line.  */
73     if (context -> gx_draw_context_display -> gx_display_rotation_angle == GX_SCREEN_ROTATION_CW)
74     {
75         put += context -> gx_draw_context_pitch * (context -> gx_draw_context_canvas -> gx_canvas_x_resolution - x - 1);
76 
77         /* Step in by y coordinate.  */
78         put += y;
79     }
80     else
81     {
82         put += context -> gx_draw_context_pitch * x;
83 
84         /* Step in by y coordinate.  */
85         put += (context -> gx_draw_context_canvas -> gx_canvas_y_resolution - y - 1);
86     }
87 
88     /* write the pixel value */
89     *put = (GX_UBYTE)color;
90 }
91 
92