GCC Code Coverage Report
Directory: ./ Exec Total Coverage
File: gx_display_driver_4bpp_pixel_write.c Lines: 13 13 100.0 %
Date: 2026-03-06 19:21:09 Branches: 2 2 100.0 %

Line Branch Exec Source
1
/***************************************************************************
2
 * Copyright (c) 2024 Microsoft Corporation
3
 * Copyright (c) 2026-present Eclipse ThreadX contributors
4
 *
5
 * This program and the accompanying materials are made available under the
6
 * terms of the MIT License which is available at
7
 * https://opensource.org/licenses/MIT.
8
 *
9
 * SPDX-License-Identifier: MIT
10
 **************************************************************************/
11
12
13
/**************************************************************************/
14
/**************************************************************************/
15
/**                                                                       */
16
/** GUIX Component                                                        */
17
/**                                                                       */
18
/**   Display Management (Display)                                        */
19
/**                                                                       */
20
/**************************************************************************/
21
22
#define GX_SOURCE_CODE
23
24
/* Include necessary system files.  */
25
26
#include "gx_api.h"
27
#include "gx_display.h"
28
/**************************************************************************/
29
/*                                                                        */
30
/*  FUNCTION                                               RELEASE        */
31
/*                                                                        */
32
/*    _gx_display_driver_4bpp_pixel_write                 PORTABLE C      */
33
/*                                                           6.1          */
34
/*  AUTHOR                                                                */
35
/*                                                                        */
36
/*    Kenneth Maxwell, Microsoft Corporation                              */
37
/*                                                                        */
38
/*  DESCRIPTION                                                           */
39
/*                                                                        */
40
/*    Pixel write function for the 4bpp display driver.                   */
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
/*    _gx_display_driver_4bpp_pixel_write   Calculate row pitch           */
56
/*                                                                        */
57
/*  CALLED BY                                                             */
58
/*                                                                        */
59
/*    GUIX Internal Code                                                  */
60
/*                                                                        */
61
/**************************************************************************/
62
172271
VOID _gx_display_driver_4bpp_pixel_write(GX_DRAW_CONTEXT *context, INT x, INT y, GX_COLOR color)
63
{
64
172271
GX_UBYTE *put = (GX_UBYTE *)context -> gx_draw_context_memory;
65
GX_UBYTE  mask;
66
UINT      stride;
67
GX_UBYTE  put_color;
68
69
    /* Get row pitch in bytes. */
70
172271
    stride = _gx_display_driver_4bpp_row_pitch_get((USHORT)(context -> gx_draw_context_pitch));
71
172271
    put_color = color & 0x0f;
72
172271
    put_color |= (GX_UBYTE)(put_color << 4);
73
74
    /* Calculate address of writing byte.  */
75
172271
    put = (GX_UBYTE *)((INT)put + y * (INT)stride);
76
172271
    put += x >> 1;
77
78
172271
    if (x & 0x01)
79
    {
80
86431
        mask = 0x0f;
81
    }
82
    else
83
    {
84
85840
        mask = 0xf0;
85
    }
86
87
172271
    *put &= (GX_UBYTE)(~mask);
88
172271
    *put |= mask & put_color;
89
172271
}
90