diff options
Diffstat (limited to 'firmware/drivers/lcd-16bit-vert.c')
-rw-r--r-- | firmware/drivers/lcd-16bit-vert.c | 98 |
1 files changed, 52 insertions, 46 deletions
diff --git a/firmware/drivers/lcd-16bit-vert.c b/firmware/drivers/lcd-16bit-vert.c index ffe2b85b3c..b336e78c78 100644 --- a/firmware/drivers/lcd-16bit-vert.c +++ b/firmware/drivers/lcd-16bit-vert.c | |||
@@ -39,7 +39,7 @@ | |||
39 | #include "scroll_engine.h" | 39 | #include "scroll_engine.h" |
40 | 40 | ||
41 | #define ROW_INC 1 | 41 | #define ROW_INC 1 |
42 | #define COL_INC LCD_HEIGHT | 42 | #define COL_INC lcd_current_viewport->buffer->stride |
43 | 43 | ||
44 | extern lcd_fastpixelfunc_type* const lcd_fastpixelfuncs_backdrop[]; | 44 | extern lcd_fastpixelfunc_type* const lcd_fastpixelfuncs_backdrop[]; |
45 | extern lcd_fastpixelfunc_type* const lcd_fastpixelfuncs_bgcolor[]; | 45 | extern lcd_fastpixelfunc_type* const lcd_fastpixelfuncs_bgcolor[]; |
@@ -61,7 +61,9 @@ void lcd_hline(int x1, int x2, int y) | |||
61 | { | 61 | { |
62 | int x; | 62 | int x; |
63 | fb_data *dst, *dst_end; | 63 | fb_data *dst, *dst_end; |
64 | lcd_fastpixelfunc_type *pfunc = lcd_fastpixelfuncs[current_vp->drawmode]; | 64 | int stride_dst; |
65 | |||
66 | lcd_fastpixelfunc_type *pfunc = lcd_fastpixelfuncs[lcd_current_viewport->drawmode]; | ||
65 | 67 | ||
66 | /* direction flip */ | 68 | /* direction flip */ |
67 | if (x2 < x1) | 69 | if (x2 < x1) |
@@ -73,20 +75,20 @@ void lcd_hline(int x1, int x2, int y) | |||
73 | 75 | ||
74 | /******************** In viewport clipping **********************/ | 76 | /******************** In viewport clipping **********************/ |
75 | /* nothing to draw? */ | 77 | /* nothing to draw? */ |
76 | if (((unsigned)y >= (unsigned)current_vp->height) || | 78 | if (((unsigned)y >= (unsigned)lcd_current_viewport->height) || |
77 | (x1 >= current_vp->width) || | 79 | (x1 >= lcd_current_viewport->width) || |
78 | (x2 < 0)) | 80 | (x2 < 0)) |
79 | return; | 81 | return; |
80 | 82 | ||
81 | if (x1 < 0) | 83 | if (x1 < 0) |
82 | x1 = 0; | 84 | x1 = 0; |
83 | if (x2 >= current_vp->width) | 85 | if (x2 >= lcd_current_viewport->width) |
84 | x2 = current_vp->width-1; | 86 | x2 = lcd_current_viewport->width-1; |
85 | 87 | ||
86 | /* Adjust x1 and y to viewport */ | 88 | /* Adjust x1 and y to viewport */ |
87 | x1 += current_vp->x; | 89 | x1 += lcd_current_viewport->x; |
88 | x2 += current_vp->x; | 90 | x2 += lcd_current_viewport->x; |
89 | y += current_vp->y; | 91 | y += lcd_current_viewport->y; |
90 | 92 | ||
91 | #if defined(HAVE_VIEWPORT_CLIP) | 93 | #if defined(HAVE_VIEWPORT_CLIP) |
92 | /********************* Viewport on screen clipping ********************/ | 94 | /********************* Viewport on screen clipping ********************/ |
@@ -103,12 +105,13 @@ void lcd_hline(int x1, int x2, int y) | |||
103 | #endif | 105 | #endif |
104 | 106 | ||
105 | dst = FBADDR(x1 , y ); | 107 | dst = FBADDR(x1 , y ); |
106 | dst_end = dst + (x2 - x1) * LCD_HEIGHT; | 108 | stride_dst = lcd_current_viewport->buffer->stride; |
109 | dst_end = dst + (x2 - x1) * stride_dst; | ||
107 | 110 | ||
108 | do | 111 | do |
109 | { | 112 | { |
110 | pfunc(dst); | 113 | pfunc(dst); |
111 | dst += LCD_HEIGHT; | 114 | dst += stride_dst; |
112 | } | 115 | } |
113 | while (dst <= dst_end); | 116 | while (dst <= dst_end); |
114 | } | 117 | } |
@@ -131,20 +134,20 @@ void lcd_vline(int x, int y1, int y2) | |||
131 | 134 | ||
132 | /******************** In viewport clipping **********************/ | 135 | /******************** In viewport clipping **********************/ |
133 | /* nothing to draw? */ | 136 | /* nothing to draw? */ |
134 | if (((unsigned)x >= (unsigned)current_vp->width) || | 137 | if (((unsigned)x >= (unsigned)lcd_current_viewport->width) || |
135 | (y1 >= current_vp->height) || | 138 | (y1 >= lcd_current_viewport->height) || |
136 | (y2 < 0)) | 139 | (y2 < 0)) |
137 | return; | 140 | return; |
138 | 141 | ||
139 | if (y1 < 0) | 142 | if (y1 < 0) |
140 | y1 = 0; | 143 | y1 = 0; |
141 | if (y2 >= current_vp->height) | 144 | if (y2 >= lcd_current_viewport->height) |
142 | y2 = current_vp->height-1; | 145 | y2 = lcd_current_viewport->height-1; |
143 | 146 | ||
144 | /* adjust for viewport */ | 147 | /* adjust for viewport */ |
145 | x += current_vp->x; | 148 | x += lcd_current_viewport->x; |
146 | y1 += current_vp->y; | 149 | y1 += lcd_current_viewport->y; |
147 | y2 += current_vp->y; | 150 | y2 += lcd_current_viewport->y; |
148 | 151 | ||
149 | #if defined(HAVE_VIEWPORT_CLIP) | 152 | #if defined(HAVE_VIEWPORT_CLIP) |
150 | /********************* Viewport on screen clipping ********************/ | 153 | /********************* Viewport on screen clipping ********************/ |
@@ -163,14 +166,14 @@ void lcd_vline(int x, int y1, int y2) | |||
163 | height = y2 - y1 + 1; | 166 | height = y2 - y1 + 1; |
164 | 167 | ||
165 | /* drawmode and optimisation */ | 168 | /* drawmode and optimisation */ |
166 | if (current_vp->drawmode & DRMODE_INVERSEVID) | 169 | if (lcd_current_viewport->drawmode & DRMODE_INVERSEVID) |
167 | { | 170 | { |
168 | if (current_vp->drawmode & DRMODE_BG) | 171 | if (lcd_current_viewport->drawmode & DRMODE_BG) |
169 | { | 172 | { |
170 | if (!lcd_backdrop) | 173 | if (!lcd_backdrop) |
171 | { | 174 | { |
172 | fillopt = OPT_SET; | 175 | fillopt = OPT_SET; |
173 | bits = current_vp->bg_pattern; | 176 | bits = lcd_current_viewport->bg_pattern; |
174 | } | 177 | } |
175 | else | 178 | else |
176 | fillopt = OPT_COPY; | 179 | fillopt = OPT_COPY; |
@@ -178,13 +181,13 @@ void lcd_vline(int x, int y1, int y2) | |||
178 | } | 181 | } |
179 | else | 182 | else |
180 | { | 183 | { |
181 | if (current_vp->drawmode & DRMODE_FG) | 184 | if (lcd_current_viewport->drawmode & DRMODE_FG) |
182 | { | 185 | { |
183 | fillopt = OPT_SET; | 186 | fillopt = OPT_SET; |
184 | bits = current_vp->fg_pattern; | 187 | bits = lcd_current_viewport->fg_pattern; |
185 | } | 188 | } |
186 | } | 189 | } |
187 | if (fillopt == OPT_NONE && current_vp->drawmode != DRMODE_COMPLEMENT) | 190 | if (fillopt == OPT_NONE && lcd_current_viewport->drawmode != DRMODE_COMPLEMENT) |
188 | return; | 191 | return; |
189 | 192 | ||
190 | dst = FBADDR(x, y1); | 193 | dst = FBADDR(x, y1); |
@@ -215,11 +218,11 @@ void ICODE_ATTR lcd_bitmap_part(const fb_data *src, int src_x, int src_y, | |||
215 | int height) | 218 | int height) |
216 | { | 219 | { |
217 | fb_data *dst; | 220 | fb_data *dst; |
218 | 221 | int stride_dst; | |
219 | /******************** Image in viewport clipping **********************/ | 222 | /******************** Image in viewport clipping **********************/ |
220 | /* nothing to draw? */ | 223 | /* nothing to draw? */ |
221 | if ((width <= 0) || (height <= 0) || (x >= current_vp->width) || | 224 | if ((width <= 0) || (height <= 0) || (x >= lcd_current_viewport->width) || |
222 | (y >= current_vp->height) || (x + width <= 0) || (y + height <= 0)) | 225 | (y >= lcd_current_viewport->height) || (x + width <= 0) || (y + height <= 0)) |
223 | return; | 226 | return; |
224 | 227 | ||
225 | if (x < 0) | 228 | if (x < 0) |
@@ -235,14 +238,14 @@ void ICODE_ATTR lcd_bitmap_part(const fb_data *src, int src_x, int src_y, | |||
235 | y = 0; | 238 | y = 0; |
236 | } | 239 | } |
237 | 240 | ||
238 | if (x + width > current_vp->width) | 241 | if (x + width > lcd_current_viewport->width) |
239 | width = current_vp->width - x; | 242 | width = lcd_current_viewport->width - x; |
240 | if (y + height > current_vp->height) | 243 | if (y + height > lcd_current_viewport->height) |
241 | height = current_vp->height - y; | 244 | height = lcd_current_viewport->height - y; |
242 | 245 | ||
243 | /* adjust for viewport */ | 246 | /* adjust for viewport */ |
244 | x += current_vp->x; | 247 | x += lcd_current_viewport->x; |
245 | y += current_vp->y; | 248 | y += lcd_current_viewport->y; |
246 | 249 | ||
247 | #if defined(HAVE_VIEWPORT_CLIP) | 250 | #if defined(HAVE_VIEWPORT_CLIP) |
248 | /********************* Viewport on screen clipping ********************/ | 251 | /********************* Viewport on screen clipping ********************/ |
@@ -272,13 +275,14 @@ void ICODE_ATTR lcd_bitmap_part(const fb_data *src, int src_x, int src_y, | |||
272 | 275 | ||
273 | src += stride * src_x + src_y; /* move starting point */ | 276 | src += stride * src_x + src_y; /* move starting point */ |
274 | dst = FBADDR(x, y); | 277 | dst = FBADDR(x, y); |
275 | fb_data *dst_end = dst + width * LCD_HEIGHT; | 278 | stride_dst = lcd_current_viewport->buffer->stride; |
279 | fb_data *dst_end = dst + width * stride_dst; | ||
276 | 280 | ||
277 | do | 281 | do |
278 | { | 282 | { |
279 | memcpy(dst, src, height * sizeof(fb_data)); | 283 | memcpy(dst, src, height * sizeof(fb_data)); |
280 | src += stride; | 284 | src += stride; |
281 | dst += LCD_HEIGHT; | 285 | dst += stride_dst; |
282 | } | 286 | } |
283 | while (dst < dst_end); | 287 | while (dst < dst_end); |
284 | } | 288 | } |
@@ -289,11 +293,12 @@ void ICODE_ATTR lcd_bitmap_transparent_part(const fb_data *src, int src_x, | |||
289 | int y, int width, int height) | 293 | int y, int width, int height) |
290 | { | 294 | { |
291 | fb_data *dst, *dst_end; | 295 | fb_data *dst, *dst_end; |
296 | int stride_dst; | ||
292 | 297 | ||
293 | /******************** Image in viewport clipping **********************/ | 298 | /******************** Image in viewport clipping **********************/ |
294 | /* nothing to draw? */ | 299 | /* nothing to draw? */ |
295 | if ((width <= 0) || (height <= 0) || (x >= current_vp->width) || | 300 | if ((width <= 0) || (height <= 0) || (x >= lcd_current_viewport->width) || |
296 | (y >= current_vp->height) || (x + width <= 0) || (y + height <= 0)) | 301 | (y >= lcd_current_viewport->height) || (x + width <= 0) || (y + height <= 0)) |
297 | return; | 302 | return; |
298 | 303 | ||
299 | if (x < 0) | 304 | if (x < 0) |
@@ -309,14 +314,14 @@ void ICODE_ATTR lcd_bitmap_transparent_part(const fb_data *src, int src_x, | |||
309 | y = 0; | 314 | y = 0; |
310 | } | 315 | } |
311 | 316 | ||
312 | if (x + width > current_vp->width) | 317 | if (x + width > lcd_current_viewport->width) |
313 | width = current_vp->width - x; | 318 | width = lcd_current_viewport->width - x; |
314 | if (y + height > current_vp->height) | 319 | if (y + height > lcd_current_viewport->height) |
315 | height = current_vp->height - y; | 320 | height = lcd_current_viewport->height - y; |
316 | 321 | ||
317 | /* adjust for viewport */ | 322 | /* adjust for viewport */ |
318 | x += current_vp->x; | 323 | x += lcd_current_viewport->x; |
319 | y += current_vp->y; | 324 | y += lcd_current_viewport->y; |
320 | 325 | ||
321 | #if defined(HAVE_VIEWPORT_CLIP) | 326 | #if defined(HAVE_VIEWPORT_CLIP) |
322 | /********************* Viewport on screen clipping ********************/ | 327 | /********************* Viewport on screen clipping ********************/ |
@@ -346,7 +351,8 @@ void ICODE_ATTR lcd_bitmap_transparent_part(const fb_data *src, int src_x, | |||
346 | 351 | ||
347 | src += stride * src_x + src_y; /* move starting point */ | 352 | src += stride * src_x + src_y; /* move starting point */ |
348 | dst = FBADDR(x, y); | 353 | dst = FBADDR(x, y); |
349 | dst_end = dst + width * LCD_HEIGHT; | 354 | stride_dst = lcd_current_viewport->buffer->stride; |
355 | dst_end = dst + width * stride_dst; | ||
350 | 356 | ||
351 | do | 357 | do |
352 | { | 358 | { |
@@ -354,12 +360,12 @@ void ICODE_ATTR lcd_bitmap_transparent_part(const fb_data *src, int src_x, | |||
354 | for(i = 0;i < height;i++) | 360 | for(i = 0;i < height;i++) |
355 | { | 361 | { |
356 | if (src[i] == REPLACEWITHFG_COLOR) | 362 | if (src[i] == REPLACEWITHFG_COLOR) |
357 | dst[i] = current_vp->fg_pattern; | 363 | dst[i] = lcd_current_viewport->fg_pattern; |
358 | else if(src[i] != TRANSPARENT_COLOR) | 364 | else if(src[i] != TRANSPARENT_COLOR) |
359 | dst[i] = src[i]; | 365 | dst[i] = src[i]; |
360 | } | 366 | } |
361 | src += stride; | 367 | src += stride; |
362 | dst += LCD_HEIGHT; | 368 | dst += stride_dst; |
363 | } | 369 | } |
364 | while (dst < dst_end); | 370 | while (dst < dst_end); |
365 | } | 371 | } |