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 |
|
|
/** Sprite Management (Sprite) */ |
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_display.h" |
29 |
|
|
#include "gx_context.h" |
30 |
|
|
#include "gx_canvas.h" |
31 |
|
|
#include "gx_widget.h" |
32 |
|
|
#include "gx_sprite.h" |
33 |
|
|
|
34 |
|
|
|
35 |
|
|
/**************************************************************************/ |
36 |
|
|
/* */ |
37 |
|
|
/* FUNCTION RELEASE */ |
38 |
|
|
/* */ |
39 |
|
|
/* _gx_sprite_draw PORTABLE C */ |
40 |
|
|
/* 6.1.9 */ |
41 |
|
|
/* AUTHOR */ |
42 |
|
|
/* */ |
43 |
|
|
/* Kenneth Maxwell, Microsoft Corporation */ |
44 |
|
|
/* */ |
45 |
|
|
/* DESCRIPTION */ |
46 |
|
|
/* */ |
47 |
|
|
/* This service draws a sprite widget. */ |
48 |
|
|
/* */ |
49 |
|
|
/* INPUT */ |
50 |
|
|
/* */ |
51 |
|
|
/* sprite Pointer to sprite widget */ |
52 |
|
|
/* control block */ |
53 |
|
|
/* */ |
54 |
|
|
/* OUTPUT */ |
55 |
|
|
/* */ |
56 |
|
|
/* None */ |
57 |
|
|
/* */ |
58 |
|
|
/* CALLS */ |
59 |
|
|
/* */ |
60 |
|
|
/* _gx_context_pixelmap_get Get the pixelmap in the */ |
61 |
|
|
/* current context */ |
62 |
|
|
/* _gx_canvas_pixelmap_blend Blend pixelmap */ |
63 |
|
|
/* _gx_canvas_pixelmap_draw Draw pixelmap */ |
64 |
|
|
/* _gx_widget_children_draw Draw the children of a widget */ |
65 |
|
|
/* */ |
66 |
|
|
/* */ |
67 |
|
|
/* CALLED BY */ |
68 |
|
|
/* */ |
69 |
|
|
/* Application Code */ |
70 |
|
|
/* GUIX Internal Code */ |
71 |
|
|
/* */ |
72 |
|
|
/* RELEASE HISTORY */ |
73 |
|
|
/* */ |
74 |
|
|
/* DATE NAME DESCRIPTION */ |
75 |
|
|
/* */ |
76 |
|
|
/* 05-19-2020 Kenneth Maxwell Initial Version 6.0 */ |
77 |
|
|
/* 09-30-2020 Kenneth Maxwell Modified comment(s), */ |
78 |
|
|
/* resulting in version 6.1 */ |
79 |
|
|
/* 10-15-2021 Ting Zhu Modified comment(s), */ |
80 |
|
|
/* supported alphamap draw, */ |
81 |
|
|
/* resulting in version 6.1.9 */ |
82 |
|
|
/* */ |
83 |
|
|
/**************************************************************************/ |
84 |
|
853 |
VOID _gx_sprite_draw(GX_SPRITE *sprite) |
85 |
|
|
{ |
86 |
|
|
GX_SPRITE_FRAME *frame; |
87 |
|
|
GX_PIXELMAP *map; |
88 |
|
|
GX_VALUE xpos; |
89 |
|
|
GX_VALUE ypos; |
90 |
|
|
|
91 |
|
|
/* Draw sprite background. */ |
92 |
|
853 |
_gx_widget_background_draw((GX_WIDGET *)sprite); |
93 |
|
|
|
94 |
✓✓ |
853 |
if (sprite -> gx_sprite_frame_list) |
95 |
|
|
{ |
96 |
✓✓ |
839 |
if (sprite -> gx_sprite_current_frame < sprite -> gx_sprite_frame_count) |
97 |
|
|
{ |
98 |
|
838 |
frame = &sprite -> gx_sprite_frame_list[sprite -> gx_sprite_current_frame]; |
99 |
✓✓ |
838 |
if (frame -> gx_sprite_frame_pixelmap) |
100 |
|
|
{ |
101 |
|
837 |
_gx_widget_context_fill_set((GX_WIDGET *)sprite); |
102 |
|
|
|
103 |
|
837 |
_gx_context_pixelmap_get(frame -> gx_sprite_frame_pixelmap, &map); |
104 |
✓✓ |
837 |
if (map) |
105 |
|
|
{ |
106 |
|
835 |
xpos = (GX_VALUE)(sprite -> gx_widget_size.gx_rectangle_left + frame -> gx_sprite_frame_x_offset); |
107 |
|
835 |
ypos = (GX_VALUE)(sprite -> gx_widget_size.gx_rectangle_top + frame -> gx_sprite_frame_y_offset); |
108 |
|
|
|
109 |
✓✓ |
835 |
if (frame -> gx_sprite_frame_alpha != GX_ALPHA_VALUE_OPAQUE) |
110 |
|
|
{ |
111 |
|
4 |
_gx_canvas_pixelmap_blend(xpos, ypos, map, frame -> gx_sprite_frame_alpha); |
112 |
|
|
} |
113 |
|
|
else |
114 |
|
|
{ |
115 |
|
831 |
_gx_canvas_pixelmap_draw(xpos, ypos, map); |
116 |
|
|
} |
117 |
|
|
} |
118 |
|
|
} |
119 |
|
|
} |
120 |
|
|
} |
121 |
|
|
|
122 |
|
|
/* Draw children widgets of prompt widget. */ |
123 |
|
853 |
_gx_widget_children_draw((GX_WIDGET *)sprite); |
124 |
|
853 |
} |
125 |
|
|
|