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 |
|
|
|
33 |
|
|
/**************************************************************************/ |
34 |
|
|
/* */ |
35 |
|
|
/* FUNCTION RELEASE */ |
36 |
|
|
/* */ |
37 |
|
|
/* _gx_canvas_pixelmap_tile PORTABLE C */ |
38 |
|
|
/* 6.1 */ |
39 |
|
|
/* AUTHOR */ |
40 |
|
|
/* */ |
41 |
|
|
/* Kenneth Maxwell, Microsoft Corporation */ |
42 |
|
|
/* */ |
43 |
|
|
/* DESCRIPTION */ |
44 |
|
|
/* */ |
45 |
|
|
/* This function prepares to draw the specified pixelmap at the */ |
46 |
|
|
/* requested position. */ |
47 |
|
|
/* */ |
48 |
|
|
/* INPUT */ |
49 |
|
|
/* */ |
50 |
|
|
/* fill Area to fill with pixelmap */ |
51 |
|
|
/* pixelmap Pointer to actual pixelmap */ |
52 |
|
|
/* to draw */ |
53 |
|
|
/* */ |
54 |
|
|
/* OUTPUT */ |
55 |
|
|
/* */ |
56 |
|
|
/* status Completion status */ |
57 |
|
|
/* */ |
58 |
|
|
/* CALLS */ |
59 |
|
|
/* */ |
60 |
|
|
/* _gx_utility_rectangle_overlap_detect Detect rectangle overlap */ |
61 |
|
|
/* _gx_canvas_pixelmap_draw Screen pixelmap draw routine */ |
62 |
|
|
/* */ |
63 |
|
|
/* CALLED BY */ |
64 |
|
|
/* */ |
65 |
|
|
/* Application Code */ |
66 |
|
|
/* */ |
67 |
|
|
/**************************************************************************/ |
68 |
|
29337 |
UINT _gx_canvas_pixelmap_tile(GX_RECTANGLE *fill, GX_PIXELMAP *pixelmap) |
69 |
|
|
{ |
70 |
|
|
GX_VALUE xpos; |
71 |
|
|
GX_VALUE ypos; |
72 |
|
|
GX_DRAW_CONTEXT *context; |
73 |
|
|
GX_RECTANGLE oldclip; |
74 |
|
|
|
75 |
|
|
/* pick up the current drawing context */ |
76 |
|
29337 |
context = _gx_system_current_draw_context; |
77 |
|
|
|
78 |
|
|
/* save the current dirty area */ |
79 |
|
29337 |
oldclip = context -> gx_draw_context_dirty; |
80 |
|
|
|
81 |
|
|
/* clip to the fill rectangle */ |
82 |
✓✓ |
29337 |
if (!_gx_utility_rectangle_overlap_detect(fill, &context -> gx_draw_context_dirty, |
83 |
|
|
&context -> gx_draw_context_dirty)) |
84 |
|
|
{ |
85 |
|
158 |
context -> gx_draw_context_dirty = oldclip; |
86 |
|
|
|
87 |
|
|
/* nothing to draw, return */ |
88 |
|
158 |
return GX_SUCCESS; |
89 |
|
|
} |
90 |
|
|
|
91 |
✓✓ |
29179 |
if (!pixelmap -> gx_pixelmap_width || |
92 |
✓✓ |
29178 |
!pixelmap -> gx_pixelmap_height) |
93 |
|
|
{ |
94 |
|
2 |
context -> gx_draw_context_dirty = oldclip; |
95 |
|
2 |
return GX_FAILURE; |
96 |
|
|
} |
97 |
|
|
|
98 |
|
|
/* pickup starting y position */ |
99 |
|
29177 |
ypos = fill -> gx_rectangle_top; |
100 |
|
|
|
101 |
|
|
/* loop from top to bottom */ |
102 |
✓✓ |
91719 |
while (ypos <= fill -> gx_rectangle_bottom) |
103 |
|
|
{ |
104 |
|
|
/* pickup starting x position */ |
105 |
|
62542 |
xpos = fill -> gx_rectangle_left; |
106 |
|
|
|
107 |
|
|
/* loop from left to right */ |
108 |
✓✓ |
1065195 |
while (xpos <= fill -> gx_rectangle_right) |
109 |
|
|
{ |
110 |
|
|
/* draw one tile */ |
111 |
|
1002653 |
_gx_canvas_pixelmap_draw(xpos, ypos, pixelmap); |
112 |
|
|
|
113 |
|
|
/* move to the right by one tile width */ |
114 |
|
1002653 |
xpos = (GX_VALUE)(xpos + pixelmap -> gx_pixelmap_width); |
115 |
|
|
} |
116 |
|
|
|
117 |
|
|
/* move down by one tile height */ |
118 |
|
62542 |
ypos = (GX_VALUE)(ypos + pixelmap -> gx_pixelmap_height); |
119 |
|
|
} |
120 |
|
|
|
121 |
|
|
/* restore dirty rectangle */ |
122 |
|
29177 |
context -> gx_draw_context_dirty = oldclip; |
123 |
|
|
|
124 |
|
|
/* Return successful completion. */ |
125 |
|
|
|
126 |
|
29177 |
return(GX_SUCCESS); |
127 |
|
|
} |
128 |
|
|
|