1 /**************************************************************************/
2 /* */
3 /* Copyright (c) Microsoft Corporation. All rights reserved. */
4 /* */
5 /* This software is licensed under the Microsoft Software License */
6 /* Terms for Microsoft Azure RTOS. Full text of the license can be */
7 /* found in the LICENSE file at https://aka.ms/AzureRTOS_EULA */
8 /* and in the root directory of this software. */
9 /* */
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 /* 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 /**************************************************************************/
_gx_canvas_pixel_draw(GX_POINT position)75 UINT _gx_canvas_pixel_draw(GX_POINT position)
76 {
77 GX_DRAW_CONTEXT *context;
78 GX_DISPLAY *display;
79 GX_VIEW *view;
80 GX_COLOR pixcolor;
81 GX_UBYTE brush_alpha;
82
83 /* pick up the current drawing context */
84 context = _gx_system_current_draw_context;
85
86 /* test to see if we can draw at this position */
87 if (!_gx_utility_rectangle_point_detect(&context -> gx_draw_context_dirty, position))
88 {
89 /* nothing to draw, return */
90 return GX_SUCCESS;
91 }
92
93 /* pick up current display driver */
94 display = context -> gx_draw_context_display;
95
96 brush_alpha = context -> gx_draw_context_brush.gx_brush_alpha;
97
98 /* pick up the pixel color */
99 pixcolor = context -> gx_draw_context_brush.gx_brush_line_color;
100
101 /* test to determine if any viewport of the caller overlaps this pixel.
102 For each view that overlaps the bounding rectangle, do some drawing.
103 */
104 view = context -> gx_draw_context_view_head;
105 #if defined(GX_BRUSH_ALPHA_SUPPORT)
106 if (brush_alpha == 0)
107 {
108 return GX_SUCCESS;
109 }
110 while (view)
111 {
112 if (_gx_utility_rectangle_point_detect(&view -> gx_view_rectangle, position))
113 {
114 if (brush_alpha == 0xff)
115 {
116 if (display -> gx_display_driver_pixel_write)
117 {
118 display -> gx_display_driver_pixel_write(context, position.gx_point_x, position.gx_point_y, pixcolor);
119 }
120 }
121 else
122 {
123 if (display -> gx_display_driver_pixel_blend)
124 {
125 display -> gx_display_driver_pixel_blend(context, position.gx_point_x, position.gx_point_y, pixcolor, brush_alpha);
126 }
127 }
128 break;
129 }
130 view = view->gx_view_next;
131 }
132 #else
133 while (view)
134 {
135 if (_gx_utility_rectangle_point_detect(&view -> gx_view_rectangle, position))
136 {
137 if (display -> gx_display_driver_pixel_write)
138 {
139 display -> gx_display_driver_pixel_write(context, position.gx_point_x, position.gx_point_y, pixcolor);
140 }
141 break;
142 }
143 view = view->gx_view_next;
144 }
145 #endif
146
147 /* Return successful completion. */
148 return(GX_SUCCESS);
149 }
150
151