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_display.h" |
31 |
|
|
#include "gx_canvas.h" |
32 |
|
|
|
33 |
|
|
/**************************************************************************/ |
34 |
|
|
/* */ |
35 |
|
|
/* FUNCTION RELEASE */ |
36 |
|
|
/* */ |
37 |
|
|
/* _gx_canvas_pixel_draw PORTABLE C */ |
38 |
|
|
/* 6.1 */ |
39 |
|
|
/* AUTHOR */ |
40 |
|
|
/* */ |
41 |
|
|
/* Kenneth Maxwell, Microsoft Corporation */ |
42 |
|
|
/* */ |
43 |
|
|
/* DESCRIPTION */ |
44 |
|
|
/* */ |
45 |
|
|
/* This function prepares to draw one pixel using current context */ |
46 |
|
|
/* */ |
47 |
|
|
/* INPUT */ |
48 |
|
|
/* */ |
49 |
|
|
/* position x,y coordinate to draw */ |
50 |
|
|
/* */ |
51 |
|
|
/* OUTPUT */ |
52 |
|
|
/* */ |
53 |
|
|
/* status Completion status */ |
54 |
|
|
/* */ |
55 |
|
|
/* CALLS */ |
56 |
|
|
/* */ |
57 |
|
|
/* _gx_utility_rectangle_point_detect Detect whether a pixel is */ |
58 |
|
|
/* inside rectangle */ |
59 |
|
|
/* [gx_display_driver_pixel_write] Actually write to canvas */ |
60 |
|
|
/* */ |
61 |
|
|
/* CALLED BY */ |
62 |
|
|
/* */ |
63 |
|
|
/* Application Code */ |
64 |
|
|
/* _gx_widget_border_draw */ |
65 |
|
|
/* */ |
66 |
|
|
/**************************************************************************/ |
67 |
|
9258553 |
UINT _gx_canvas_pixel_draw(GX_POINT position) |
68 |
|
|
{ |
69 |
|
|
GX_DRAW_CONTEXT *context; |
70 |
|
|
GX_DISPLAY *display; |
71 |
|
|
GX_VIEW *view; |
72 |
|
|
GX_COLOR pixcolor; |
73 |
|
|
#if defined(GX_BRUSH_ALPHA_SUPPORT) |
74 |
|
|
GX_UBYTE brush_alpha; |
75 |
|
|
#endif |
76 |
|
|
|
77 |
|
|
/* pick up the current drawing context */ |
78 |
|
9258553 |
context = _gx_system_current_draw_context; |
79 |
|
|
|
80 |
|
|
/* test to see if we can draw at this position */ |
81 |
✓✓ |
9258553 |
if (!_gx_utility_rectangle_point_detect(&context -> gx_draw_context_dirty, position)) |
82 |
|
|
{ |
83 |
|
|
/* nothing to draw, return */ |
84 |
|
691619 |
return GX_SUCCESS; |
85 |
|
|
} |
86 |
|
|
|
87 |
|
|
/* pick up current display driver */ |
88 |
|
8566934 |
display = context -> gx_draw_context_display; |
89 |
|
|
|
90 |
|
|
#if defined(GX_BRUSH_ALPHA_SUPPORT) |
91 |
|
8566934 |
brush_alpha = context -> gx_draw_context_brush.gx_brush_alpha; |
92 |
|
|
#endif |
93 |
|
|
|
94 |
|
|
/* pick up the pixel color */ |
95 |
|
8566934 |
pixcolor = context -> gx_draw_context_brush.gx_brush_line_color; |
96 |
|
|
|
97 |
|
|
/* test to determine if any viewport of the caller overlaps this pixel. |
98 |
|
|
For each view that overlaps the bounding rectangle, do some drawing. |
99 |
|
|
*/ |
100 |
|
8566934 |
view = context -> gx_draw_context_view_head; |
101 |
|
|
#if defined(GX_BRUSH_ALPHA_SUPPORT) |
102 |
✓✓ |
8566934 |
if (brush_alpha == 0) |
103 |
|
|
{ |
104 |
|
9701 |
return GX_SUCCESS; |
105 |
|
|
} |
106 |
✓✓ |
8692916 |
while (view) |
107 |
|
|
{ |
108 |
✓✓ |
8654166 |
if (_gx_utility_rectangle_point_detect(&view -> gx_view_rectangle, position)) |
109 |
|
|
{ |
110 |
✓✓ |
8518483 |
if (brush_alpha == 0xff) |
111 |
|
|
{ |
112 |
✓✓ |
8112270 |
if (display -> gx_display_driver_pixel_write) |
113 |
|
|
{ |
114 |
|
8112246 |
display -> gx_display_driver_pixel_write(context, position.gx_point_x, position.gx_point_y, pixcolor); |
115 |
|
|
} |
116 |
|
|
} |
117 |
|
|
else |
118 |
|
|
{ |
119 |
✓✓ |
406213 |
if (display -> gx_display_driver_pixel_blend) |
120 |
|
|
{ |
121 |
|
406005 |
display -> gx_display_driver_pixel_blend(context, position.gx_point_x, position.gx_point_y, pixcolor, brush_alpha); |
122 |
|
|
} |
123 |
|
|
} |
124 |
|
8518483 |
break; |
125 |
|
|
} |
126 |
|
135683 |
view = view->gx_view_next; |
127 |
|
|
} |
128 |
|
|
#else |
129 |
|
|
while (view) |
130 |
|
|
{ |
131 |
|
|
if (_gx_utility_rectangle_point_detect(&view -> gx_view_rectangle, position)) |
132 |
|
|
{ |
133 |
|
|
if (display -> gx_display_driver_pixel_write) |
134 |
|
|
{ |
135 |
|
|
display -> gx_display_driver_pixel_write(context, position.gx_point_x, position.gx_point_y, pixcolor); |
136 |
|
|
} |
137 |
|
|
break; |
138 |
|
|
} |
139 |
|
|
view = view->gx_view_next; |
140 |
|
|
} |
141 |
|
|
#endif |
142 |
|
|
|
143 |
|
|
/* Return successful completion. */ |
144 |
|
8557233 |
return(GX_SUCCESS); |
145 |
|
|
} |
146 |
|
|
|