summaryrefslogtreecommitdiff
path: root/firmware/drivers/lcd-16bit.c
diff options
context:
space:
mode:
Diffstat (limited to 'firmware/drivers/lcd-16bit.c')
-rw-r--r--firmware/drivers/lcd-16bit.c93
1 files changed, 49 insertions, 44 deletions
diff --git a/firmware/drivers/lcd-16bit.c b/firmware/drivers/lcd-16bit.c
index b792be4e02..03c50f8ebf 100644
--- a/firmware/drivers/lcd-16bit.c
+++ b/firmware/drivers/lcd-16bit.c
@@ -38,7 +38,7 @@
38#include "bidi.h" 38#include "bidi.h"
39#include "scroll_engine.h" 39#include "scroll_engine.h"
40 40
41#define ROW_INC LCD_WIDTH 41#define ROW_INC lcd_current_viewport->buffer->stride
42#define COL_INC 1 42#define COL_INC 1
43 43
44extern lcd_fastpixelfunc_type* const lcd_fastpixelfuncs_backdrop[]; 44extern lcd_fastpixelfunc_type* const lcd_fastpixelfuncs_backdrop[];
@@ -74,20 +74,20 @@ void lcd_hline(int x1, int x2, int y)
74 74
75 /******************** In viewport clipping **********************/ 75 /******************** In viewport clipping **********************/
76 /* nothing to draw? */ 76 /* nothing to draw? */
77 if (((unsigned)y >= (unsigned)current_vp->height) || 77 if (((unsigned)y >= (unsigned)lcd_current_viewport->height) ||
78 (x1 >= current_vp->width) || 78 (x1 >= lcd_current_viewport->width) ||
79 (x2 < 0)) 79 (x2 < 0))
80 return; 80 return;
81 81
82 if (x1 < 0) 82 if (x1 < 0)
83 x1 = 0; 83 x1 = 0;
84 if (x2 >= current_vp->width) 84 if (x2 >= lcd_current_viewport->width)
85 x2 = current_vp->width-1; 85 x2 = lcd_current_viewport->width-1;
86 86
87 /* Adjust x1 and y to viewport */ 87 /* Adjust x1 and y to viewport */
88 x1 += current_vp->x; 88 x1 += lcd_current_viewport->x;
89 x2 += current_vp->x; 89 x2 += lcd_current_viewport->x;
90 y += current_vp->y; 90 y += lcd_current_viewport->y;
91 91
92#if defined(HAVE_VIEWPORT_CLIP) 92#if defined(HAVE_VIEWPORT_CLIP)
93 /********************* Viewport on screen clipping ********************/ 93 /********************* Viewport on screen clipping ********************/
@@ -106,14 +106,14 @@ void lcd_hline(int x1, int x2, int y)
106 width = x2 - x1 + 1; 106 width = x2 - x1 + 1;
107 107
108 /* drawmode and optimisation */ 108 /* drawmode and optimisation */
109 if (current_vp->drawmode & DRMODE_INVERSEVID) 109 if (lcd_current_viewport->drawmode & DRMODE_INVERSEVID)
110 { 110 {
111 if (current_vp->drawmode & DRMODE_BG) 111 if (lcd_current_viewport->drawmode & DRMODE_BG)
112 { 112 {
113 if (!lcd_backdrop) 113 if (!lcd_backdrop)
114 { 114 {
115 fillopt = OPT_SET; 115 fillopt = OPT_SET;
116 bits = current_vp->bg_pattern; 116 bits = lcd_current_viewport->bg_pattern;
117 } 117 }
118 else 118 else
119 fillopt = OPT_COPY; 119 fillopt = OPT_COPY;
@@ -121,13 +121,13 @@ void lcd_hline(int x1, int x2, int y)
121 } 121 }
122 else 122 else
123 { 123 {
124 if (current_vp->drawmode & DRMODE_FG) 124 if (lcd_current_viewport->drawmode & DRMODE_FG)
125 { 125 {
126 fillopt = OPT_SET; 126 fillopt = OPT_SET;
127 bits = current_vp->fg_pattern; 127 bits = lcd_current_viewport->fg_pattern;
128 } 128 }
129 } 129 }
130 if (fillopt == OPT_NONE && current_vp->drawmode != DRMODE_COMPLEMENT) 130 if (fillopt == OPT_NONE && lcd_current_viewport->drawmode != DRMODE_COMPLEMENT)
131 return; 131 return;
132 132
133 dst = FBADDR(x1, y); 133 dst = FBADDR(x1, y);
@@ -157,7 +157,8 @@ void lcd_vline(int x, int y1, int y2)
157{ 157{
158 int y; 158 int y;
159 fb_data *dst, *dst_end; 159 fb_data *dst, *dst_end;
160 lcd_fastpixelfunc_type *pfunc = lcd_fastpixelfuncs[current_vp->drawmode]; 160 int stride_dst;
161 lcd_fastpixelfunc_type *pfunc = lcd_fastpixelfuncs[lcd_current_viewport->drawmode];
161 162
162 /* direction flip */ 163 /* direction flip */
163 if (y2 < y1) 164 if (y2 < y1)
@@ -169,20 +170,20 @@ void lcd_vline(int x, int y1, int y2)
169 170
170 /******************** In viewport clipping **********************/ 171 /******************** In viewport clipping **********************/
171 /* nothing to draw? */ 172 /* nothing to draw? */
172 if (((unsigned)x >= (unsigned)current_vp->width) || 173 if (((unsigned)x >= (unsigned)lcd_current_viewport->width) ||
173 (y1 >= current_vp->height) || 174 (y1 >= lcd_current_viewport->height) ||
174 (y2 < 0)) 175 (y2 < 0))
175 return; 176 return;
176 177
177 if (y1 < 0) 178 if (y1 < 0)
178 y1 = 0; 179 y1 = 0;
179 if (y2 >= current_vp->height) 180 if (y2 >= lcd_current_viewport->height)
180 y2 = current_vp->height-1; 181 y2 = lcd_current_viewport->height-1;
181 182
182 /* adjust for viewport */ 183 /* adjust for viewport */
183 x += current_vp->x; 184 x += lcd_current_viewport->x;
184 y1 += current_vp->y; 185 y1 += lcd_current_viewport->y;
185 y2 += current_vp->y; 186 y2 += lcd_current_viewport->y;
186 187
187#if defined(HAVE_VIEWPORT_CLIP) 188#if defined(HAVE_VIEWPORT_CLIP)
188 /********************* Viewport on screen clipping ********************/ 189 /********************* Viewport on screen clipping ********************/
@@ -199,12 +200,13 @@ void lcd_vline(int x, int y1, int y2)
199#endif 200#endif
200 201
201 dst = FBADDR(x , y1); 202 dst = FBADDR(x , y1);
202 dst_end = dst + (y2 - y1) * LCD_WIDTH; 203 stride_dst = lcd_current_viewport->buffer->stride;
204 dst_end = dst + (y2 - y1) * stride_dst;
203 205
204 do 206 do
205 { 207 {
206 pfunc(dst); 208 pfunc(dst);
207 dst += LCD_WIDTH; 209 dst += stride_dst;
208 } 210 }
209 while (dst <= dst_end); 211 while (dst <= dst_end);
210} 212}
@@ -215,11 +217,12 @@ void ICODE_ATTR lcd_bitmap_part(const fb_data *src, int src_x, int src_y,
215 int height) 217 int height)
216{ 218{
217 fb_data *dst; 219 fb_data *dst;
220 int stride_dst;
218 221
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,12 +275,13 @@ void ICODE_ATTR lcd_bitmap_part(const fb_data *src, int src_x, int src_y,
272 275
273 src += stride * src_y + src_x; /* move starting point */ 276 src += stride * src_y + src_x; /* move starting point */
274 dst = FBADDR(x, y); 277 dst = FBADDR(x, y);
278 stride_dst = lcd_current_viewport->buffer->stride;
275 279
276 do 280 do
277 { 281 {
278 memcpy(dst, src, width * sizeof(fb_data)); 282 memcpy(dst, src, width * sizeof(fb_data));
279 src += stride; 283 src += stride;
280 dst += LCD_WIDTH; 284 dst += stride_dst;
281 } 285 }
282 while (--height > 0); 286 while (--height > 0);
283} 287}
@@ -288,12 +292,13 @@ void ICODE_ATTR lcd_bitmap_transparent_part(const fb_data *src, int src_x,
288 int y, int width, int height) 292 int y, int width, int height)
289{ 293{
290 fb_data *dst; 294 fb_data *dst;
291 unsigned fg = current_vp->fg_pattern; 295 unsigned fg = lcd_current_viewport->fg_pattern;
296 int stride_dst = lcd_current_viewport->buffer->stride;
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 ********************/
@@ -371,7 +376,7 @@ void ICODE_ATTR lcd_bitmap_transparent_part(const fb_data *src, int src_x,
371 [s]"+&r"(src), [d]"+&r"(dst) 376 [s]"+&r"(src), [d]"+&r"(dst)
372 : [width]"r"(width), 377 : [width]"r"(width),
373 [sstp]"r"(stride - width), 378 [sstp]"r"(stride - width),
374 [dstp]"r"(LCD_WIDTH - width), 379 [dstp]"r"(stride_dst - width),
375 [transcolor]"r"(TRANSPARENT_COLOR), 380 [transcolor]"r"(TRANSPARENT_COLOR),
376 [fgcolor]"r"(REPLACEWITHFG_COLOR), 381 [fgcolor]"r"(REPLACEWITHFG_COLOR),
377 [fgpat]"r"(fg) 382 [fgpat]"r"(fg)
@@ -395,7 +400,7 @@ void ICODE_ATTR lcd_bitmap_transparent_part(const fb_data *src, int src_x,
395 } 400 }
396 while (++dst_row < row_end); 401 while (++dst_row < row_end);
397 src += stride; 402 src += stride;
398 dst += LCD_WIDTH; 403 dst += stride_dst;
399 } 404 }
400 while (--height > 0); 405 while (--height > 0);
401#endif 406#endif