diff options
Diffstat (limited to 'firmware/drivers/lcd-16bit-vert.c')
-rw-r--r-- | firmware/drivers/lcd-16bit-vert.c | 110 |
1 files changed, 8 insertions, 102 deletions
diff --git a/firmware/drivers/lcd-16bit-vert.c b/firmware/drivers/lcd-16bit-vert.c index 166af02791..c721ef6302 100644 --- a/firmware/drivers/lcd-16bit-vert.c +++ b/firmware/drivers/lcd-16bit-vert.c | |||
@@ -54,46 +54,23 @@ static void ICODE_ATTR lcd_alpha_bitmap_part_mix(const fb_data* image, | |||
54 | int stride_image, int stride_src); | 54 | int stride_image, int stride_src); |
55 | 55 | ||
56 | #include "lcd-color-common.c" | 56 | #include "lcd-color-common.c" |
57 | #include "lcd-16bit-common.c" | ||
58 | #include "lcd-bitmap-common.c" | 57 | #include "lcd-bitmap-common.c" |
58 | #include "lcd-16bit-common.c" | ||
59 | 59 | ||
60 | /*** drawing functions ***/ | 60 | /*** drawing functions ***/ |
61 | 61 | ||
62 | /* Draw a horizontal line (optimised) */ | 62 | /* Draw a horizontal line (optimised) */ |
63 | void lcd_hline(int x1, int x2, int y) | 63 | void lcd_hline(int x1, int x2, int y) |
64 | { | 64 | { |
65 | int x; | ||
66 | fb_data *dst, *dst_end; | 65 | fb_data *dst, *dst_end; |
67 | int stride_dst; | 66 | int stride_dst; |
68 | 67 | ||
69 | lcd_fastpixelfunc_type *pfunc = lcd_fastpixelfuncs[lcd_current_viewport->drawmode]; | 68 | lcd_fastpixelfunc_type *pfunc = lcd_fastpixelfuncs[lcd_current_viewport->drawmode]; |
70 | 69 | ||
71 | /* direction flip */ | 70 | if (!lcd_clip_viewport_hline(&x1, &x2, &y)) |
72 | if (x2 < x1) | ||
73 | { | ||
74 | x = x1; | ||
75 | x1 = x2; | ||
76 | x2 = x; | ||
77 | } | ||
78 | |||
79 | /******************** In viewport clipping **********************/ | ||
80 | /* nothing to draw? */ | ||
81 | if (((unsigned)y >= (unsigned)lcd_current_viewport->height) || | ||
82 | (x1 >= lcd_current_viewport->width) || | ||
83 | (x2 < 0)) | ||
84 | return; | 71 | return; |
85 | 72 | ||
86 | if (x1 < 0) | 73 | dst = FBADDR(x1, y); |
87 | x1 = 0; | ||
88 | if (x2 >= lcd_current_viewport->width) | ||
89 | x2 = lcd_current_viewport->width-1; | ||
90 | |||
91 | /* Adjust x1 and y to viewport */ | ||
92 | x1 += lcd_current_viewport->x; | ||
93 | x2 += lcd_current_viewport->x; | ||
94 | y += lcd_current_viewport->y; | ||
95 | |||
96 | dst = FBADDR(x1 , y ); | ||
97 | stride_dst = lcd_current_viewport->buffer->stride; | 74 | stride_dst = lcd_current_viewport->buffer->stride; |
98 | dst_end = dst + (x2 - x1) * stride_dst; | 75 | dst_end = dst + (x2 - x1) * stride_dst; |
99 | 76 | ||
@@ -108,36 +85,14 @@ void lcd_hline(int x1, int x2, int y) | |||
108 | /* Draw a vertical line (optimised) */ | 85 | /* Draw a vertical line (optimised) */ |
109 | void lcd_vline(int x, int y1, int y2) | 86 | void lcd_vline(int x, int y1, int y2) |
110 | { | 87 | { |
111 | int y, height; | 88 | int height; |
112 | unsigned bits = 0; | 89 | unsigned bits = 0; |
113 | enum fill_opt fillopt = OPT_NONE; | 90 | enum fill_opt fillopt = OPT_NONE; |
114 | fb_data *dst, *dst_end; | 91 | fb_data *dst, *dst_end; |
115 | 92 | ||
116 | /* direction flip */ | 93 | if(!lcd_clip_viewport_vline(&x, &y1, &y2)) |
117 | if (y2 < y1) | ||
118 | { | ||
119 | y = y1; | ||
120 | y1 = y2; | ||
121 | y2 = y; | ||
122 | } | ||
123 | |||
124 | /******************** In viewport clipping **********************/ | ||
125 | /* nothing to draw? */ | ||
126 | if (((unsigned)x >= (unsigned)lcd_current_viewport->width) || | ||
127 | (y1 >= lcd_current_viewport->height) || | ||
128 | (y2 < 0)) | ||
129 | return; | 94 | return; |
130 | 95 | ||
131 | if (y1 < 0) | ||
132 | y1 = 0; | ||
133 | if (y2 >= lcd_current_viewport->height) | ||
134 | y2 = lcd_current_viewport->height-1; | ||
135 | |||
136 | /* adjust for viewport */ | ||
137 | x += lcd_current_viewport->x; | ||
138 | y1 += lcd_current_viewport->y; | ||
139 | y2 += lcd_current_viewport->y; | ||
140 | |||
141 | height = y2 - y1 + 1; | 96 | height = y2 - y1 + 1; |
142 | 97 | ||
143 | /* drawmode and optimisation */ | 98 | /* drawmode and optimisation */ |
@@ -194,33 +149,9 @@ void ICODE_ATTR lcd_bitmap_part(const fb_data *src, int src_x, int src_y, | |||
194 | { | 149 | { |
195 | fb_data *dst; | 150 | fb_data *dst; |
196 | int stride_dst; | 151 | int stride_dst; |
197 | /******************** Image in viewport clipping **********************/ | ||
198 | /* nothing to draw? */ | ||
199 | if ((width <= 0) || (height <= 0) || (x >= lcd_current_viewport->width) || | ||
200 | (y >= lcd_current_viewport->height) || (x + width <= 0) || (y + height <= 0)) | ||
201 | return; | ||
202 | 152 | ||
203 | if (x < 0) | 153 | if (!lcd_clip_viewport_rect(&x, &y, &width, &height, &src_x, &src_y)) |
204 | { | 154 | return; |
205 | width += x; | ||
206 | src_x -= x; | ||
207 | x = 0; | ||
208 | } | ||
209 | if (y < 0) | ||
210 | { | ||
211 | height += y; | ||
212 | src_y -= y; | ||
213 | y = 0; | ||
214 | } | ||
215 | |||
216 | if (x + width > lcd_current_viewport->width) | ||
217 | width = lcd_current_viewport->width - x; | ||
218 | if (y + height > lcd_current_viewport->height) | ||
219 | height = lcd_current_viewport->height - y; | ||
220 | |||
221 | /* adjust for viewport */ | ||
222 | x += lcd_current_viewport->x; | ||
223 | y += lcd_current_viewport->y; | ||
224 | 155 | ||
225 | src += stride * src_x + src_y; /* move starting point */ | 156 | src += stride * src_x + src_y; /* move starting point */ |
226 | dst = FBADDR(x, y); | 157 | dst = FBADDR(x, y); |
@@ -244,34 +175,9 @@ void ICODE_ATTR lcd_bitmap_transparent_part(const fb_data *src, int src_x, | |||
244 | fb_data *dst, *dst_end; | 175 | fb_data *dst, *dst_end; |
245 | int stride_dst; | 176 | int stride_dst; |
246 | 177 | ||
247 | /******************** Image in viewport clipping **********************/ | 178 | if (!lcd_clip_viewport_rect(&x, &y, &width, &height, &src_x, &src_y)) |
248 | /* nothing to draw? */ | ||
249 | if ((width <= 0) || (height <= 0) || (x >= lcd_current_viewport->width) || | ||
250 | (y >= lcd_current_viewport->height) || (x + width <= 0) || (y + height <= 0)) | ||
251 | return; | 179 | return; |
252 | 180 | ||
253 | if (x < 0) | ||
254 | { | ||
255 | width += x; | ||
256 | src_x -= x; | ||
257 | x = 0; | ||
258 | } | ||
259 | if (y < 0) | ||
260 | { | ||
261 | height += y; | ||
262 | src_y -= y; | ||
263 | y = 0; | ||
264 | } | ||
265 | |||
266 | if (x + width > lcd_current_viewport->width) | ||
267 | width = lcd_current_viewport->width - x; | ||
268 | if (y + height > lcd_current_viewport->height) | ||
269 | height = lcd_current_viewport->height - y; | ||
270 | |||
271 | /* adjust for viewport */ | ||
272 | x += lcd_current_viewport->x; | ||
273 | y += lcd_current_viewport->y; | ||
274 | |||
275 | src += stride * src_x + src_y; /* move starting point */ | 181 | src += stride * src_x + src_y; /* move starting point */ |
276 | dst = FBADDR(x, y); | 182 | dst = FBADDR(x, y); |
277 | stride_dst = lcd_current_viewport->buffer->stride; | 183 | stride_dst = lcd_current_viewport->buffer->stride; |