GCC Code Coverage Report
Directory: ./ Exec Total Coverage
File: gxe_canvas_rotated_text_draw.c Lines: 24 24 100.0 %
Date: 2024-12-05 08:52:37 Branches: 32 32 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
/**   Canvas Management (Canvas)                                          */
18
/**                                                                       */
19
/**************************************************************************/
20
21
#define GX_SOURCE_CODE
22
23
24
/* Include necessary system files.  */
25
26
#include "gx_api.h"
27
#include "gx_canvas.h"
28
#include "gx_system.h"
29
#include "gx_utility.h"
30
31
/* Bring in externs for caller checking code.  */
32
GX_CALLER_CHECKING_EXTERNS
33
34
/**************************************************************************/
35
/*                                                                        */
36
/*  FUNCTION                                               RELEASE        */
37
/*                                                                        */
38
/*    _gxe_canvas_rotated_text_draw                       PORTABLE C      */
39
/*                                                           6.1          */
40
/*  AUTHOR                                                                */
41
/*                                                                        */
42
/*    Kenneth Maxwell, Microsoft Corporation                              */
43
/*                                                                        */
44
/*  DESCRIPTION                                                           */
45
/*                                                                        */
46
/*    This function checks error in canvas rotated text draw function.    */
47
/*                                                                        */
48
/*  INPUT                                                                 */
49
/*                                                                        */
50
/*    text                                  pointer to string             */
51
/*    xcenter                               center point for text drawing */
52
/*    ycenter                               center point for text drawing */
53
/*    angle                                 angle at which to rotate text */
54
/*                                                                        */
55
/*  OUTPUT                                                                */
56
/*                                                                        */
57
/*    status                                Completion status             */
58
/*                                                                        */
59
/*  CALLS                                                                 */
60
/*                                                                        */
61
/*    _gx_canvas_rotated_text_draw          The actual canvas rotated     */
62
/*                                            text draw function          */
63
/*                                                                        */
64
/*  CALLED BY                                                             */
65
/*                                                                        */
66
/*    Application Code                                                    */
67
/*                                                                        */
68
/*  RELEASE HISTORY                                                       */
69
/*                                                                        */
70
/*    DATE              NAME                      DESCRIPTION             */
71
/*                                                                        */
72
/*  05-19-2020     Kenneth Maxwell          Initial Version 6.0           */
73
/*  09-30-2020     Kenneth Maxwell          Modified comment(s),          */
74
/*                                            resulting in version 6.1    */
75
/*                                                                        */
76
/**************************************************************************/
77
#if defined(GX_ENABLE_DEPRECATED_STRING_API)
78
12
UINT _gxe_canvas_rotated_text_draw(GX_CONST GX_CHAR *text,
79
                                   GX_VALUE xcenter,
80
                                   GX_VALUE ycenter,
81
                                   INT angle)
82
{
83
UINT status;
84
85
    /* Check for invalid caller.  */
86

12
    GX_INIT_AND_THREADS_CALLER_CHECKING
87
88
    /* Check for invalid pointer.  */
89
10
    if (text == GX_NULL)
90
    {
91
2
        return GX_PTR_ERROR;
92
    }
93
94

8
    if (!_gx_system_memory_allocator || !_gx_system_memory_free)
95
    {
96
2
        return GX_SYSTEM_MEMORY_ERROR;
97
    }
98
99
6
    status = _gx_canvas_rotated_text_draw(text, xcenter, ycenter, angle);
100
101
    /* Return completion status code. */
102
6
    return(status);
103
}
104
#endif
105
106
/**************************************************************************/
107
/*                                                                        */
108
/*  FUNCTION                                               RELEASE        */
109
/*                                                                        */
110
/*    _gxe_canvas_rotated_text_draw_ext                   PORTABLE C      */
111
/*                                                           6.1          */
112
/*  AUTHOR                                                                */
113
/*                                                                        */
114
/*    Kenneth Maxwell, Microsoft Corporation                              */
115
/*                                                                        */
116
/*  DESCRIPTION                                                           */
117
/*                                                                        */
118
/*    This function checks error in canvas rotated text draw function.    */
119
/*                                                                        */
120
/*  INPUT                                                                 */
121
/*                                                                        */
122
/*    text                                  pointer to string             */
123
/*    xcenter                               center point for text drawing */
124
/*    ycenter                               center point for text drawing */
125
/*    angle                                 angle at which to rotate text */
126
/*                                                                        */
127
/*  OUTPUT                                                                */
128
/*                                                                        */
129
/*    status                                Completion status             */
130
/*                                                                        */
131
/*  CALLS                                                                 */
132
/*                                                                        */
133
/*    _gx_canvas_rotated_text_draw_ext      The actual canvas rotated     */
134
/*                                            text draw function          */
135
/*                                                                        */
136
/*  CALLED BY                                                             */
137
/*                                                                        */
138
/*    Application Code                                                    */
139
/*                                                                        */
140
/*  RELEASE HISTORY                                                       */
141
/*                                                                        */
142
/*    DATE              NAME                      DESCRIPTION             */
143
/*                                                                        */
144
/*  05-19-2020     Kenneth Maxwell          Initial Version 6.0           */
145
/*  09-30-2020     Kenneth Maxwell          Modified comment(s),          */
146
/*                                            resulting in version 6.1    */
147
/*                                                                        */
148
/**************************************************************************/
149
372
UINT _gxe_canvas_rotated_text_draw_ext(GX_CONST GX_STRING *text, GX_VALUE xcenter, GX_VALUE ycenter, INT angle)
150
{
151
UINT status;
152
372
UINT text_length = 0;
153
154
    /* Check for invalid caller.  */
155

372
    GX_INIT_AND_THREADS_CALLER_CHECKING
156
157
    /* Check for invalid pointer.  */
158

370
    if ((text == GX_NULL) || (text -> gx_string_ptr == GX_NULL))
159
    {
160
2
        return GX_PTR_ERROR;
161
    }
162
163
368
    if (_gx_system_current_draw_context == GX_NULL)
164
    {
165
1
        return GX_INVALID_CONTEXT;
166
    }
167
168

367
    if (!_gx_system_memory_allocator || !_gx_system_memory_free)
169
    {
170
2
        return GX_SYSTEM_MEMORY_ERROR;
171
    }
172
173
365
    status = _gx_utility_string_length_check(text -> gx_string_ptr, &text_length, text -> gx_string_length);
174
175
365
    if (status != GX_SUCCESS)
176
    {
177
1
        return status;
178
    }
179
180
364
    if (text_length != text -> gx_string_length)
181
    {
182
1
        return GX_INVALID_STRING_LENGTH;
183
    }
184
185
363
    status = _gx_canvas_rotated_text_draw_ext(text, xcenter, ycenter, angle);
186
187
    /* Return completion status code. */
188
363
    return(status);
189
}
190