GCC Code Coverage Report
Directory: ./ Exec Total Coverage
File: gx_canvas_pixelmap_get.c Lines: 19 19 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
/**   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_canvas.h"
29
#include "gx_system.h"
30
31
/**************************************************************************/
32
/*                                                                        */
33
/*  FUNCTION                                               RELEASE        */
34
/*                                                                        */
35
/*    _gx_canvas_pixelmap_get                             PORTABLE C      */
36
/*                                                           6.1          */
37
/*  AUTHOR                                                                */
38
/*                                                                        */
39
/*    Kenneth Maxwell, Microsoft Corporation                              */
40
/*                                                                        */
41
/*  DESCRIPTION                                                           */
42
/*                                                                        */
43
/*    This function creates a GX_PIXELMAP structure pointing to the       */
44
/*    canvas data.                                                        */
45
/*                                                                        */
46
/*  INPUT                                                                 */
47
/*                                                                        */
48
/*    pixelmap                              Pointer to destination for    */
49
/*                                            the retrieved pixlemap      */
50
/*                                                                        */
51
/*  OUTPUT                                                                */
52
/*                                                                        */
53
/*    status                                Completion status             */
54
/*                                                                        */
55
/*  CALLS                                                                 */
56
/*                                                                        */
57
/*    None                                                                */
58
/*                                                                        */
59
/*  CALLED BY                                                             */
60
/*                                                                        */
61
/*    Application Code                                                    */
62
/*                                                                        */
63
/**************************************************************************/
64
557
UINT  _gx_canvas_pixelmap_get(GX_PIXELMAP *pixelmap)
65
{
66
GX_DRAW_CONTEXT *context;
67
GX_DISPLAY      *display;
68
GX_CANVAS       *canvas;
69
70
    /* pick up the current drawing context */
71
557
    context = _gx_system_current_draw_context;
72
557
    if (context == GX_NULL)
73
    {
74
1
        return GX_INVALID_CONTEXT;
75
    }
76
77
    /* pick up curren canvas. */
78
556
    canvas = context -> gx_draw_context_canvas;
79
556
    if (canvas == GX_NULL)
80
    {
81
1
        return GX_INVALID_CANVAS;
82
    }
83
84
    /* pick up current display driver */
85
555
    display = context -> gx_draw_context_display;
86
555
    if (display == GX_NULL)
87
    {
88
1
        return GX_INVALID_DISPLAY;
89
    }
90
91
554
    memset(pixelmap, 0, sizeof(GX_PIXELMAP));
92
93
554
    pixelmap -> gx_pixelmap_width = canvas -> gx_canvas_x_resolution;
94
554
    pixelmap -> gx_pixelmap_height = canvas -> gx_canvas_y_resolution;
95
554
    pixelmap -> gx_pixelmap_format = (GX_UBYTE)display -> gx_display_color_format;
96
554
    pixelmap -> gx_pixelmap_data = (GX_UBYTE *)canvas -> gx_canvas_memory;
97
554
    pixelmap -> gx_pixelmap_data_size = canvas -> gx_canvas_memory_size;
98
554
    pixelmap -> gx_pixelmap_version_major = 1;
99
554
    pixelmap -> gx_pixelmap_version_minor = 0;
100
101
    /* Return successful completion.  */
102
554
    return(GX_SUCCESS);
103
}
104