GCC Code Coverage Report
Directory: ./ Exec Total Coverage
File: gx_utility_pixelmap_simple_rotate.c Lines: 42 42 100.0 %
Date: 2026-03-06 19:21:09 Branches: 22 22 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
/**   Utility (Utility)                                                   */
19
/**                                                                       */
20
/**************************************************************************/
21
22
#define GX_SOURCE_CODE
23
24
25
/* Include necessary system files.  */
26
27
#include "gx_api.h"
28
#include "gx_context.h"
29
#include "gx_system.h"
30
#include "gx_utility.h"
31
32
/**************************************************************************/
33
/*                                                                        */
34
/*  FUNCTION                                               RELEASE        */
35
/*                                                                        */
36
/*    _gx_utility_pixelmap_simple_rotation                PORTABLE C      */
37
/*                                                           6.1          */
38
/*  AUTHOR                                                                */
39
/*                                                                        */
40
/*    Kenneth Maxwell, Microsoft Corporation                              */
41
/*                                                                        */
42
/*  DESCRIPTION                                                           */
43
/*                                                                        */
44
/*    This service rotate a pixelmap by 90, 180 or 270 degree.            */
45
/*                                                                        */
46
/*  INPUT                                                                 */
47
/*                                                                        */
48
/*    src                                   The pixelmap to rotate        */
49
/*    angle                                 The angle to rotate           */
50
/*    destination                           Destination buffer for        */
51
/*                                            rotated pixelmap.           */
52
/*    rot_cx                                X coordinate of rotation      */
53
/*                                            center                      */
54
/*    rot_cy                                Y coordinate of rotation      */
55
/*                                            center                      */
56
/*                                                                        */
57
/*  OUTPUT                                                                */
58
/*                                                                        */
59
/*    status                                Completion status             */
60
/*                                                                        */
61
/*  CALLS                                                                 */
62
/*                                                                        */
63
/*    _gx_utility_32argb_pixelmap_simple_rotate                           */
64
/*                                          Rotate 32bpp pixelmap with    */
65
/*                                            simple case                 */
66
/*    _gx_utility_565rgb_pixelmap_simple_rotate                           */
67
/*                                          Rotate 565rgb pixelmap with   */
68
/*                                            simple case                 */
69
/*    _gx_utility_4444argb_pixelmap_simple_rotate                         */
70
/*                                          Rotate 4444argb pixelmap with */
71
/*                                            simple case                 */
72
/*    _gx_utility_8bpp_pixelmap_simple_rotate                             */
73
/*                                          Rotate 8bit palette pixelmap  */
74
/*                                            with simple case            */
75
/*    _gx_utility_332rgb_pixelmap_simple_rotate                           */
76
/*                                          Rotate 332rgb pixelmap with   */
77
/*                                            simple case                 */
78
/*    _gx_utility_4bpp_pixelmap_simple_rotate                             */
79
/*                                          Rotate 4bpp pixelmap with     */
80
/*                                            simple case                 */
81
/*    _gx_utility_1bpp_pixelmap_simple_rotate                             */
82
/*                                          Rotate 1bpp pixelmap with     */
83
/*                                            simple case                 */
84
/*                                                                        */
85
/*  CALLED BY                                                             */
86
/*                                                                        */
87
/*    Application Code                                                    */
88
/*    GUIX Internal Code                                                  */
89
/*                                                                        */
90
/**************************************************************************/
91
451
UINT _gx_utility_pixelmap_simple_rotate(GX_PIXELMAP *src, INT angle, GX_PIXELMAP *destination, INT *rot_cx, INT *rot_cy)
92
{
93
451
    angle = angle % 360;
94
95

451
    if ((angle == 0) || (angle % 90))
96
    {
97
2
        return GX_INVALID_VALUE;
98
    }
99
449
    else if (angle < 0)
100
    {
101
8
        angle += 360;
102
    }
103
104

449
    if ((_gx_system_memory_allocator == GX_NULL) || (_gx_system_memory_free == GX_NULL))
105
    {
106
2
        return GX_SYSTEM_MEMORY_ERROR;
107
    }
108
109
447
    if (src -> gx_pixelmap_flags & GX_PIXELMAP_COMPRESSED)
110
    {
111
2
        return GX_INVALID_FORMAT;
112
    }
113
114
445
    memset(destination, 0, sizeof(GX_PIXELMAP));
115
445
    destination -> gx_pixelmap_format = src -> gx_pixelmap_format;
116
445
    destination -> gx_pixelmap_version_major = src -> gx_pixelmap_version_major;
117
445
    destination -> gx_pixelmap_version_minor = src -> gx_pixelmap_version_major;
118
445
    destination -> gx_pixelmap_flags = src -> gx_pixelmap_flags;
119
120


445
    switch (src -> gx_pixelmap_format)
121
    {
122
86
    case GX_COLOR_FORMAT_32ARGB:
123
    case GX_COLOR_FORMAT_24XRGB:
124
        /* Call 32argb pixelmap rotate. */
125
86
        _gx_utility_32argb_pixelmap_simple_rotate(src, angle, destination, rot_cx, rot_cy);
126
86
        break;
127
128
96
    case GX_COLOR_FORMAT_565RGB:
129
    case GX_COLOR_FORMAT_565BGR:
130
    case GX_COLOR_FORMAT_1555XRGB:
131
        /* Call 565rgb pixelmap rotate.  */
132
96
        _gx_utility_565rgb_pixelmap_simple_rotate(src, angle, destination, rot_cx, rot_cy);
133
96
        break;
134
135
30
    case GX_COLOR_FORMAT_4444ARGB:
136
30
        _gx_utility_4444argb_pixelmap_simple_rotate(src, angle, destination, rot_cx, rot_cy);
137
30
        break;
138
139
60
    case  GX_COLOR_FORMAT_8BIT_PACKED_PIXEL:
140
        /* Call 332rgb pixelmap rotate.  */
141
60
        _gx_utility_332rgb_pixelmap_simple_rotate(src, angle, destination, rot_cx, rot_cy);
142
60
        break;
143
144
81
    case GX_COLOR_FORMAT_8BIT_PALETTE:
145
    case GX_COLOR_FORMAT_8BIT_ALPHAMAP:
146
        /* Call 8bpp pixelmap rotate.  */
147
81
        _gx_utility_8bpp_pixelmap_simple_rotate(src, angle, destination, rot_cx, rot_cy);
148
81
        break;
149
150
60
    case GX_COLOR_FORMAT_4BIT_GRAY:
151
60
        _gx_utility_4bpp_pixelmap_simple_rotate(src, angle, destination, rot_cx, rot_cy);
152
60
        break;
153
154
30
    case GX_COLOR_FORMAT_MONOCHROME:
155
30
        _gx_utility_1bpp_pixelmap_simple_rotate(src, angle, destination, rot_cx, rot_cy);
156
30
        break;
157
158
2
    default:
159
2
        return GX_INVALID_FORMAT;
160
    }
161
443
    if (destination -> gx_pixelmap_data)
162
    {
163
317
        return GX_SUCCESS;
164
    }
165
126
    return GX_FAILURE;
166
}
167