GCC Code Coverage Report
Directory: ./ Exec Total Coverage
File: gx_display_driver_4bpp_pixel_write.c Lines: 13 13 100.0 %
Date: 2024-12-05 08:52:37 Branches: 2 2 100.0 %

Line Branch Exec Source
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
/* Include necessary system files.  */
24
25
#include "gx_api.h"
26
#include "gx_display.h"
27
/**************************************************************************/
28
/*                                                                        */
29
/*  FUNCTION                                               RELEASE        */
30
/*                                                                        */
31
/*    _gx_display_driver_4bpp_pixel_write                 PORTABLE C      */
32
/*                                                           6.1          */
33
/*  AUTHOR                                                                */
34
/*                                                                        */
35
/*    Kenneth Maxwell, Microsoft Corporation                              */
36
/*                                                                        */
37
/*  DESCRIPTION                                                           */
38
/*                                                                        */
39
/*    Pixel write function for the 4bpp display driver.                   */
40
/*                                                                        */
41
/*  INPUT                                                                 */
42
/*                                                                        */
43
/*    context                               Drawing context               */
44
/*    x                                     X coordinate                  */
45
/*    y                                     Y coordinate                  */
46
/*    color                                 Color of pixel to write       */
47
/*                                                                        */
48
/*  OUTPUT                                                                */
49
/*                                                                        */
50
/*    None                                                                */
51
/*                                                                        */
52
/*  CALLS                                                                 */
53
/*                                                                        */
54
/*    _gx_display_driver_4bpp_pixel_write   Calculate row pitch           */
55
/*                                                                        */
56
/*  CALLED BY                                                             */
57
/*                                                                        */
58
/*    GUIX Internal Code                                                  */
59
/*                                                                        */
60
/*  RELEASE HISTORY                                                       */
61
/*                                                                        */
62
/*    DATE              NAME                      DESCRIPTION             */
63
/*                                                                        */
64
/*  05-19-2020     Kenneth Maxwell          Initial Version 6.0           */
65
/*  09-30-2020     Kenneth Maxwell          Modified comment(s),          */
66
/*                                            resulting in version 6.1    */
67
/*                                                                        */
68
/**************************************************************************/
69
172271
VOID _gx_display_driver_4bpp_pixel_write(GX_DRAW_CONTEXT *context, INT x, INT y, GX_COLOR color)
70
{
71
172271
GX_UBYTE *put = (GX_UBYTE *)context -> gx_draw_context_memory;
72
GX_UBYTE  mask;
73
UINT      stride;
74
GX_UBYTE  put_color;
75
76
    /* Get row pitch in bytes. */
77
172271
    stride = _gx_display_driver_4bpp_row_pitch_get((USHORT)(context -> gx_draw_context_pitch));
78
172271
    put_color = color & 0x0f;
79
172271
    put_color |= (GX_UBYTE)(put_color << 4);
80
81
    /* Calculate address of writing byte.  */
82
172271
    put = (GX_UBYTE *)((INT)put + y * (INT)stride);
83
172271
    put += x >> 1;
84
85
172271
    if (x & 0x01)
86
    {
87
86431
        mask = 0x0f;
88
    }
89
    else
90
    {
91
85840
        mask = 0xf0;
92
    }
93
94
172271
    *put &= (GX_UBYTE)(~mask);
95
172271
    *put |= mask & put_color;
96
172271
}
97