GCC Code Coverage Report
Directory: ./ Exec Total Coverage
File: gx_canvas_pixelmap_tile.c Lines: 19 19 100.0 %
Date: 2024-12-05 08:52:37 Branches: 10 10 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_system.h"
28
#include "gx_utility.h"
29
#include "gx_canvas.h"
30
31
32
/**************************************************************************/
33
/*                                                                        */
34
/*  FUNCTION                                               RELEASE        */
35
/*                                                                        */
36
/*    _gx_canvas_pixelmap_tile                            PORTABLE C      */
37
/*                                                           6.1          */
38
/*  AUTHOR                                                                */
39
/*                                                                        */
40
/*    Kenneth Maxwell, Microsoft Corporation                              */
41
/*                                                                        */
42
/*  DESCRIPTION                                                           */
43
/*                                                                        */
44
/*    This function prepares to draw the specified pixelmap at the        */
45
/*    requested position.                                                 */
46
/*                                                                        */
47
/*  INPUT                                                                 */
48
/*                                                                        */
49
/*    fill                                  Area to fill with pixelmap    */
50
/*    pixelmap                              Pointer to actual pixelmap    */
51
/*                                            to draw                     */
52
/*                                                                        */
53
/*  OUTPUT                                                                */
54
/*                                                                        */
55
/*    status                                Completion status             */
56
/*                                                                        */
57
/*  CALLS                                                                 */
58
/*                                                                        */
59
/*    _gx_utility_rectangle_overlap_detect  Detect rectangle overlap      */
60
/*    _gx_canvas_pixelmap_draw              Screen pixelmap draw routine  */
61
/*                                                                        */
62
/*  CALLED BY                                                             */
63
/*                                                                        */
64
/*    Application Code                                                    */
65
/*                                                                        */
66
/*  RELEASE HISTORY                                                       */
67
/*                                                                        */
68
/*    DATE              NAME                      DESCRIPTION             */
69
/*                                                                        */
70
/*  05-19-2020     Kenneth Maxwell          Initial Version 6.0           */
71
/*  09-30-2020     Kenneth Maxwell          Modified comment(s),          */
72
/*                                            resulting in version 6.1    */
73
/*                                                                        */
74
/**************************************************************************/
75
29334
UINT  _gx_canvas_pixelmap_tile(GX_RECTANGLE *fill, GX_PIXELMAP *pixelmap)
76
{
77
GX_VALUE         xpos;
78
GX_VALUE         ypos;
79
GX_DRAW_CONTEXT *context;
80
GX_RECTANGLE     oldclip;
81
82
    /* pick up the current drawing context */
83
29334
    context = _gx_system_current_draw_context;
84
85
    /* save the current dirty area */
86
29334
    oldclip = context -> gx_draw_context_dirty;
87
88
    /* clip to the fill rectangle */
89
29334
    if (!_gx_utility_rectangle_overlap_detect(fill, &context -> gx_draw_context_dirty,
90
                                              &context -> gx_draw_context_dirty))
91
    {
92
158
        context -> gx_draw_context_dirty = oldclip;
93
94
        /* nothing to draw, return */
95
158
        return GX_SUCCESS;
96
    }
97
98
29176
    if (!pixelmap -> gx_pixelmap_width ||
99
29175
        !pixelmap -> gx_pixelmap_height)
100
    {
101
2
        context -> gx_draw_context_dirty = oldclip;
102
2
        return GX_FAILURE;
103
    }
104
105
    /* pickup starting y position */
106
29174
    ypos = fill -> gx_rectangle_top;
107
108
    /* loop from top to bottom */
109
91713
    while (ypos <= fill -> gx_rectangle_bottom)
110
    {
111
        /* pickup starting x position */
112
62539
        xpos = fill -> gx_rectangle_left;
113
114
        /* loop from left to right */
115
1065129
        while (xpos <= fill -> gx_rectangle_right)
116
        {
117
            /* draw one tile */
118
1002590
            _gx_canvas_pixelmap_draw(xpos, ypos, pixelmap);
119
120
            /* move to the right by one tile width */
121
1002590
            xpos = (GX_VALUE)(xpos + pixelmap -> gx_pixelmap_width);
122
        }
123
124
        /* move down by one tile height */
125
62539
        ypos = (GX_VALUE)(ypos + pixelmap -> gx_pixelmap_height);
126
    }
127
128
    /* restore dirty rectangle */
129
29174
    context -> gx_draw_context_dirty = oldclip;
130
131
    /* Return successful completion.  */
132
133
29174
    return(GX_SUCCESS);
134
}
135