GCC Code Coverage Report
Directory: ./ Exec Total Coverage
File: gxe_canvas_create.c Lines: 16 16 100.0 %
Date: 2026-03-06 19:21:09 Branches: 20 20 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
/**   Canvas Management (Canvas)                                          */
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_utility.h"
30
#include "gx_canvas.h"
31
32
/* Bring in externs for caller checking code.  */
33
GX_CALLER_CHECKING_EXTERNS
34
35
36
/**************************************************************************/
37
/*                                                                        */
38
/*  FUNCTION                                               RELEASE        */
39
/*                                                                        */
40
/*    _gxe_canvas_create                                  PORTABLE C      */
41
/*                                                           6.3.0        */
42
/*  AUTHOR                                                                */
43
/*                                                                        */
44
/*    Kenneth Maxwell, Microsoft Corporation                              */
45
/*                                                                        */
46
/*  DESCRIPTION                                                           */
47
/*                                                                        */
48
/*    This function checks for errors in the canvas function call.        */
49
/*                                                                        */
50
/*  INPUT                                                                 */
51
/*                                                                        */
52
/*    canvas                                Canvas control block          */
53
/*    name                                  Name of canvas                */
54
/*    display                               Display control block         */
55
/*    type                                  Type of canvas                */
56
/*    width                                 Width of canvas               */
57
/*    height                                Height of canvas              */
58
/*    memory_area                           Memory area of canvas with    */
59
/*                                            each pixel of GX_COLOR      */
60
/*    memory_size                           Size of canvas memory area    */
61
/*    canvas_control_block_size             Size of the canvas control    */
62
/*                                            block                       */
63
/*                                                                        */
64
/*  OUTPUT                                                                */
65
/*                                                                        */
66
/*    status                                Completion status             */
67
/*                                                                        */
68
/*  CALLS                                                                 */
69
/*                                                                        */
70
/*    _gx_canvas_create                     Actual canvas create call     */
71
/*                                                                        */
72
/*  CALLED BY                                                             */
73
/*                                                                        */
74
/*    Application Code                                                    */
75
/*                                                                        */
76
/**************************************************************************/
77
1288
UINT  _gxe_canvas_create(GX_CANVAS *canvas, GX_CONST GX_CHAR *name, GX_DISPLAY *display, UINT type,
78
                         UINT width, UINT height, GX_COLOR *memory_area, ULONG memory_size,
79
                         UINT canvas_control_block_size)
80
{
81
UINT status;
82
UINT pitch;
83
84
    /* Check for appropriate caller.  */
85

1288
    GX_INIT_AND_THREADS_CALLER_CHECKING
86
87
    /* Check for invalid input pointers.  */
88

1286
    if ((canvas == GX_NULL) || (display == GX_NULL))
89
    {
90
3
        return(GX_PTR_ERROR);
91
    }
92
93
1283
    if (canvas_control_block_size != sizeof(GX_CANVAS))
94
    {
95
1
        return(GX_INVALID_CANVAS_SIZE);
96
    }
97
98
    /* Check for widget already created.  */
99
1282
    if (canvas -> gx_canvas_display != GX_NULL)
100
    {
101
1
        return(GX_ALREADY_CREATED);
102
    }
103
104
1281
    if (memory_area)
105
    {
106
1277
        pitch = (UINT)(display -> gx_display_driver_row_pitch_get((USHORT)width));
107
1277
        if (memory_size < pitch * height)
108
        {
109
1
            return GX_INVALID_SIZE;
110
        }
111
    }
112
113
1280
    if (type & (~((UINT)(GX_CANVAS_SIMPLE | GX_CANVAS_MANAGED | GX_CANVAS_VISIBLE |
114
                         GX_CANVAS_MODIFIED | GX_CANVAS_COMPOSITE))))
115
    {
116
1
        return(GX_INVALID_TYPE);
117
    }
118
119
    /* Call the actual canvas create function.  */
120
1279
    status = _gx_canvas_create(canvas, name, display, type, width, height, memory_area, memory_size);
121
122
    /* Return completion status.  */
123
1279
    return status;
124
}
125