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

6131457
    if ((color_id < display -> gx_display_color_table_size) &&  (display -> gx_display_color_table != GX_NULL))
92
    {
93
        /* Yes, the ID is within range. Perform a table lookup and return the
94
            color.  */
95
6117477
        *return_color = display -> gx_display_color_table[color_id];
96
6117477
        status = GX_SUCCESS;
97
    }
98
    else
99
    {
100
13980
        *return_color = 0;
101
13980
        status = GX_INVALID_RESOURCE_ID;
102
    }
103
104
6131457
    return status;
105
}
106