GCC Code Coverage Report
Directory: ./ Exec Total Coverage
File: gx_context_color_get.c Lines: 12 12 100.0 %
Date: 2026-03-06 19:21:09 Branches: 6 6 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
/**   Context Management (Context)                                        */
19
/**                                                                       */
20
/**************************************************************************/
21
22
#define GX_SOURCE_CODE
23
24
25
/* Include necessary system files.  */
26
27
#include "gx_api.h"
28
#include "gx_system.h"
29
#include "gx_context.h"
30
31
32
/**************************************************************************/
33
/*                                                                        */
34
/*  FUNCTION                                               RELEASE        */
35
/*                                                                        */
36
/*    _gx_context_color_get                               PORTABLE C      */
37
/*                                                           6.1          */
38
/*  AUTHOR                                                                */
39
/*                                                                        */
40
/*    Kenneth Maxwell, Microsoft Corporation                              */
41
/*                                                                        */
42
/*  DESCRIPTION                                                           */
43
/*                                                                        */
44
/*    This service gets the color associated with the supplied            */
45
/*    resource ID from the system color table.                            */
46
/*                                                                        */
47
/*  INPUT                                                                 */
48
/*                                                                        */
49
/*    color_id                              Resource ID of color          */
50
/*    return_color                          Pointer to destination for    */
51
/*                                            color                       */
52
/*                                                                        */
53
/*  OUTPUT                                                                */
54
/*                                                                        */
55
/*    status                                Completion status             */
56
/*                                                                        */
57
/*  CALLS                                                                 */
58
/*                                                                        */
59
/*    None                                                                */
60
/*                                                                        */
61
/*  CALLED BY                                                             */
62
/*                                                                        */
63
/*    Application Code                                                    */
64
/*    _gx_context_brush_define                                            */
65
/*    _gx_context_fill_color_set                                          */
66
/*    _gx_context_line_color_set                                          */
67
/*                                                                        */
68
/**************************************************************************/
69
6131480
UINT _gx_context_color_get(GX_RESOURCE_ID color_id, GX_COLOR *return_color)
70
{
71
UINT             status;
72
6131480
GX_DRAW_CONTEXT *context = _gx_system_current_draw_context;
73
GX_DISPLAY      *display;
74
75
6131480
    display = context -> gx_draw_context_display;
76
77
    /* Determine if the ID is within range.  */
78
6131480
    if (display == GX_NULL)
79
    {
80
1
        *return_color = 0;
81
1
        return GX_INVALID_DISPLAY;
82
    }
83
84

6131479
    if ((color_id < display -> gx_display_color_table_size) &&  (display -> gx_display_color_table != GX_NULL))
85
    {
86
        /* Yes, the ID is within range. Perform a table lookup and return the
87
            color.  */
88
6117499
        *return_color = display -> gx_display_color_table[color_id];
89
6117499
        status = GX_SUCCESS;
90
    }
91
    else
92
    {
93
13980
        *return_color = 0;
94
13980
        status = GX_INVALID_RESOURCE_ID;
95
    }
96
97
6131479
    return status;
98
}
99