summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAidan MacDonald <amachronic@protonmail.com>2022-09-21 16:13:38 +0100
committerAidan MacDonald <amachronic@protonmail.com>2022-09-27 14:13:15 +0100
commit09cb3c7843d1bfe24f8259a73441c6398d2c0339 (patch)
tree2eebb6c411b93e29661bf3287a8f0bb597032181
parent24daa265985756122e0cb551c57af621ddee4b60 (diff)
downloadrockbox-09cb3c7843d1bfe24f8259a73441c6398d2c0339.tar.gz
rockbox-09cb3c7843d1bfe24f8259a73441c6398d2c0339.zip
lcd: Remove HAVE_VIEWPORT_CLIP
This was only enabled for the mrobe500 and sansaconnect targets. Most targets are therefore running without this "safety" measure, and presumably we'd have noticed long ago if there was a problem. So in all likelihood this is just a bunch of dead code that we don't need to carry around. Change-Id: I7d27701a38b1c2a985ee73fa6f277ad215d8d385
-rw-r--r--firmware/drivers/lcd-16bit-common.c103
-rw-r--r--firmware/drivers/lcd-16bit-vert.c80
-rw-r--r--firmware/drivers/lcd-16bit.c80
-rw-r--r--firmware/drivers/lcd-1bit-vert.c86
-rw-r--r--firmware/drivers/lcd-24bit.c180
-rw-r--r--firmware/drivers/lcd-2bit-horz.c112
-rw-r--r--firmware/drivers/lcd-2bit-vert.c111
-rw-r--r--firmware/drivers/lcd-2bit-vi.c113
-rw-r--r--firmware/drivers/lcd-bitmap-common.c4
-rw-r--r--firmware/drivers/lcd-color-common.c8
-rw-r--r--firmware/export/config/mrobe500.h3
-rw-r--r--firmware/export/config/sansaconnect.h3
12 files changed, 0 insertions, 883 deletions
diff --git a/firmware/drivers/lcd-16bit-common.c b/firmware/drivers/lcd-16bit-common.c
index 1b84847929..523354d5d2 100644
--- a/firmware/drivers/lcd-16bit-common.c
+++ b/firmware/drivers/lcd-16bit-common.c
@@ -40,30 +40,6 @@ void lcd_clear_viewport(void)
40 width = lcd_current_viewport->width; 40 width = lcd_current_viewport->width;
41 height = lcd_current_viewport->height; 41 height = lcd_current_viewport->height;
42 42
43#if defined(HAVE_VIEWPORT_CLIP)
44 /********************* Viewport on screen clipping ********************/
45 /* nothing to draw? */
46 if ((x >= LCD_WIDTH) || (y >= LCD_HEIGHT)
47 || (x + width <= 0) || (y + height <= 0))
48 return;
49
50 /* clip image in viewport in screen */
51 if (x < 0)
52 {
53 width += x;
54 x = 0;
55 }
56 if (y < 0)
57 {
58 height += y;
59 y = 0;
60 }
61 if (x + width > LCD_WIDTH)
62 width = LCD_WIDTH - x;
63 if (y + height > LCD_HEIGHT)
64 height = LCD_HEIGHT - y;
65#endif
66
67 len = STRIDE_MAIN(width, height); 43 len = STRIDE_MAIN(width, height);
68 step = STRIDE_MAIN(ROW_INC, COL_INC); 44 step = STRIDE_MAIN(ROW_INC, COL_INC);
69 45
@@ -182,30 +158,6 @@ void lcd_fillrect(int x, int y, int width, int height)
182 x += lcd_current_viewport->x; 158 x += lcd_current_viewport->x;
183 y += lcd_current_viewport->y; 159 y += lcd_current_viewport->y;
184 160
185#if defined(HAVE_VIEWPORT_CLIP)
186 /********************* Viewport on screen clipping ********************/
187 /* nothing to draw? */
188 if ((x >= LCD_WIDTH) || (y >= LCD_HEIGHT)
189 || (x + width <= 0) || (y + height <= 0))
190 return;
191
192 /* clip image in viewport in screen */
193 if (x < 0)
194 {
195 width += x;
196 x = 0;
197 }
198 if (y < 0)
199 {
200 height += y;
201 y = 0;
202 }
203 if (x + width > LCD_WIDTH)
204 width = LCD_WIDTH - x;
205 if (y + height > LCD_HEIGHT)
206 height = LCD_HEIGHT - y;
207#endif
208
209 /* drawmode and optimisation */ 161 /* drawmode and optimisation */
210 if (lcd_current_viewport->drawmode & DRMODE_INVERSEVID) 162 if (lcd_current_viewport->drawmode & DRMODE_INVERSEVID)
211 { 163 {
@@ -310,32 +262,6 @@ void ICODE_ATTR lcd_mono_bitmap_part(const unsigned char *src, int src_x,
310 x += lcd_current_viewport->x; 262 x += lcd_current_viewport->x;
311 y += lcd_current_viewport->y; 263 y += lcd_current_viewport->y;
312 264
313#if defined(HAVE_VIEWPORT_CLIP)
314 /********************* Viewport on screen clipping ********************/
315 /* nothing to draw? */
316 if ((x >= LCD_WIDTH) || (y >= LCD_HEIGHT)
317 || (x + width <= 0) || (y + height <= 0))
318 return;
319
320 /* clip image in viewport in screen */
321 if (x < 0)
322 {
323 width += x;
324 src_x -= x;
325 x = 0;
326 }
327 if (y < 0)
328 {
329 height += y;
330 src_y -= y;
331 y = 0;
332 }
333 if (x + width > LCD_WIDTH)
334 width = LCD_WIDTH - x;
335 if (y + height > LCD_HEIGHT)
336 height = LCD_HEIGHT - y;
337#endif
338
339 /* move starting point */ 265 /* move starting point */
340 src += stride * (src_y >> 3) + src_x; 266 src += stride * (src_y >> 3) + src_x;
341 src_y &= 7; 267 src_y &= 7;
@@ -568,35 +494,6 @@ static void ICODE_ATTR lcd_alpha_bitmap_part_mix(const fb_data* image,
568 x += lcd_current_viewport->x; 494 x += lcd_current_viewport->x;
569 y += lcd_current_viewport->y; 495 y += lcd_current_viewport->y;
570 496
571#if defined(HAVE_VIEWPORT_CLIP)
572 /********************* Viewport on screen clipping ********************/
573 /* nothing to draw? */
574 if ((x >= LCD_WIDTH) || (y >= LCD_HEIGHT)
575 || (x + width <= 0) || (y + height <= 0))
576 {
577 BLEND_FINISH;
578 return;
579 }
580
581 /* clip image in viewport in screen */
582 if (x < 0)
583 {
584 width += x;
585 src_x -= x;
586 x = 0;
587 }
588 if (y < 0)
589 {
590 height += y;
591 src_y -= y;
592 y = 0;
593 }
594 if (x + width > LCD_WIDTH)
595 width = LCD_WIDTH - x;
596 if (y + height > LCD_HEIGHT)
597 height = LCD_HEIGHT - y;
598#endif
599
600 /* the following drawmode combinations are possible: 497 /* the following drawmode combinations are possible:
601 * 1) COMPLEMENT: just negates the framebuffer contents 498 * 1) COMPLEMENT: just negates the framebuffer contents
602 * 2) BG and BG+backdrop: draws _only_ background pixels with either 499 * 2) BG and BG+backdrop: draws _only_ background pixels with either
diff --git a/firmware/drivers/lcd-16bit-vert.c b/firmware/drivers/lcd-16bit-vert.c
index 4422fdea50..166af02791 100644
--- a/firmware/drivers/lcd-16bit-vert.c
+++ b/firmware/drivers/lcd-16bit-vert.c
@@ -93,20 +93,6 @@ void lcd_hline(int x1, int x2, int y)
93 x2 += lcd_current_viewport->x; 93 x2 += lcd_current_viewport->x;
94 y += lcd_current_viewport->y; 94 y += lcd_current_viewport->y;
95 95
96#if defined(HAVE_VIEWPORT_CLIP)
97 /********************* Viewport on screen clipping ********************/
98 /* nothing to draw? */
99 if (((unsigned)y >= (unsigned) LCD_HEIGHT) || (x1 >= LCD_WIDTH)
100 || (x2 < 0))
101 return;
102
103 /* clipping */
104 if (x1 < 0)
105 x1 = 0;
106 if (x2 >= LCD_WIDTH)
107 x2 = LCD_WIDTH-1;
108#endif
109
110 dst = FBADDR(x1 , y ); 96 dst = FBADDR(x1 , y );
111 stride_dst = lcd_current_viewport->buffer->stride; 97 stride_dst = lcd_current_viewport->buffer->stride;
112 dst_end = dst + (x2 - x1) * stride_dst; 98 dst_end = dst + (x2 - x1) * stride_dst;
@@ -152,20 +138,6 @@ void lcd_vline(int x, int y1, int y2)
152 y1 += lcd_current_viewport->y; 138 y1 += lcd_current_viewport->y;
153 y2 += lcd_current_viewport->y; 139 y2 += lcd_current_viewport->y;
154 140
155#if defined(HAVE_VIEWPORT_CLIP)
156 /********************* Viewport on screen clipping ********************/
157 /* nothing to draw? */
158 if (( (unsigned) x >= (unsigned)LCD_WIDTH) || (y1 >= LCD_HEIGHT)
159 || (y2 < 0))
160 return;
161
162 /* clipping */
163 if (y1 < 0)
164 y1 = 0;
165 if (y2 >= LCD_HEIGHT)
166 y2 = LCD_HEIGHT-1;
167#endif
168
169 height = y2 - y1 + 1; 141 height = y2 - y1 + 1;
170 142
171 /* drawmode and optimisation */ 143 /* drawmode and optimisation */
@@ -250,32 +222,6 @@ void ICODE_ATTR lcd_bitmap_part(const fb_data *src, int src_x, int src_y,
250 x += lcd_current_viewport->x; 222 x += lcd_current_viewport->x;
251 y += lcd_current_viewport->y; 223 y += lcd_current_viewport->y;
252 224
253#if defined(HAVE_VIEWPORT_CLIP)
254 /********************* Viewport on screen clipping ********************/
255 /* nothing to draw? */
256 if ((x >= LCD_WIDTH) || (y >= LCD_HEIGHT)
257 || (x + width <= 0) || (y + height <= 0))
258 return;
259
260 /* clip image in viewport in screen */
261 if (x < 0)
262 {
263 width += x;
264 src_x -= x;
265 x = 0;
266 }
267 if (y < 0)
268 {
269 height += y;
270 src_y -= y;
271 y = 0;
272 }
273 if (x + width > LCD_WIDTH)
274 width = LCD_WIDTH - x;
275 if (y + height > LCD_HEIGHT)
276 height = LCD_HEIGHT - y;
277#endif
278
279 src += stride * src_x + src_y; /* move starting point */ 225 src += stride * src_x + src_y; /* move starting point */
280 dst = FBADDR(x, y); 226 dst = FBADDR(x, y);
281 stride_dst = lcd_current_viewport->buffer->stride; 227 stride_dst = lcd_current_viewport->buffer->stride;
@@ -326,32 +272,6 @@ void ICODE_ATTR lcd_bitmap_transparent_part(const fb_data *src, int src_x,
326 x += lcd_current_viewport->x; 272 x += lcd_current_viewport->x;
327 y += lcd_current_viewport->y; 273 y += lcd_current_viewport->y;
328 274
329#if defined(HAVE_VIEWPORT_CLIP)
330 /********************* Viewport on screen clipping ********************/
331 /* nothing to draw? */
332 if ((x >= LCD_WIDTH) || (y >= LCD_HEIGHT)
333 || (x + width <= 0) || (y + height <= 0))
334 return;
335
336 /* clip image in viewport in screen */
337 if (x < 0)
338 {
339 width += x;
340 src_x -= x;
341 x = 0;
342 }
343 if (y < 0)
344 {
345 height += y;
346 src_y -= y;
347 y = 0;
348 }
349 if (x + width > LCD_WIDTH)
350 width = LCD_WIDTH - x;
351 if (y + height > LCD_HEIGHT)
352 height = LCD_HEIGHT - y;
353#endif
354
355 src += stride * src_x + src_y; /* move starting point */ 275 src += stride * src_x + src_y; /* move starting point */
356 dst = FBADDR(x, y); 276 dst = FBADDR(x, y);
357 stride_dst = lcd_current_viewport->buffer->stride; 277 stride_dst = lcd_current_viewport->buffer->stride;
diff --git a/firmware/drivers/lcd-16bit.c b/firmware/drivers/lcd-16bit.c
index d6bf5a500d..6dff6f3b50 100644
--- a/firmware/drivers/lcd-16bit.c
+++ b/firmware/drivers/lcd-16bit.c
@@ -92,20 +92,6 @@ void lcd_hline(int x1, int x2, int y)
92 x2 += lcd_current_viewport->x; 92 x2 += lcd_current_viewport->x;
93 y += lcd_current_viewport->y; 93 y += lcd_current_viewport->y;
94 94
95#if defined(HAVE_VIEWPORT_CLIP)
96 /********************* Viewport on screen clipping ********************/
97 /* nothing to draw? */
98 if (((unsigned)y >= (unsigned) LCD_HEIGHT) || (x1 >= LCD_WIDTH)
99 || (x2 < 0))
100 return;
101
102 /* clipping */
103 if (x1 < 0)
104 x1 = 0;
105 if (x2 >= LCD_WIDTH)
106 x2 = LCD_WIDTH-1;
107#endif
108
109 width = x2 - x1 + 1; 95 width = x2 - x1 + 1;
110 96
111 /* drawmode and optimisation */ 97 /* drawmode and optimisation */
@@ -188,20 +174,6 @@ void lcd_vline(int x, int y1, int y2)
188 y1 += lcd_current_viewport->y; 174 y1 += lcd_current_viewport->y;
189 y2 += lcd_current_viewport->y; 175 y2 += lcd_current_viewport->y;
190 176
191#if defined(HAVE_VIEWPORT_CLIP)
192 /********************* Viewport on screen clipping ********************/
193 /* nothing to draw? */
194 if (( (unsigned) x >= (unsigned)LCD_WIDTH) || (y1 >= LCD_HEIGHT)
195 || (y2 < 0))
196 return;
197
198 /* clipping */
199 if (y1 < 0)
200 y1 = 0;
201 if (y2 >= LCD_HEIGHT)
202 y2 = LCD_HEIGHT-1;
203#endif
204
205 dst = FBADDR(x , y1); 177 dst = FBADDR(x , y1);
206 stride_dst = lcd_current_viewport->buffer->stride; 178 stride_dst = lcd_current_viewport->buffer->stride;
207 dst_end = dst + (y2 - y1) * stride_dst; 179 dst_end = dst + (y2 - y1) * stride_dst;
@@ -250,32 +222,6 @@ void ICODE_ATTR lcd_bitmap_part(const fb_data *src, int src_x, int src_y,
250 x += lcd_current_viewport->x; 222 x += lcd_current_viewport->x;
251 y += lcd_current_viewport->y; 223 y += lcd_current_viewport->y;
252 224
253#if defined(HAVE_VIEWPORT_CLIP)
254 /********************* Viewport on screen clipping ********************/
255 /* nothing to draw? */
256 if ((x >= LCD_WIDTH) || (y >= LCD_HEIGHT)
257 || (x + width <= 0) || (y + height <= 0))
258 return;
259
260 /* clip image in viewport in screen */
261 if (x < 0)
262 {
263 width += x;
264 src_x -= x;
265 x = 0;
266 }
267 if (y < 0)
268 {
269 height += y;
270 src_y -= y;
271 y = 0;
272 }
273 if (x + width > LCD_WIDTH)
274 width = LCD_WIDTH - x;
275 if (y + height > LCD_HEIGHT)
276 height = LCD_HEIGHT - y;
277#endif
278
279 src += stride * src_y + src_x; /* move starting point */ 225 src += stride * src_y + src_x; /* move starting point */
280 dst = FBADDR(x, y); 226 dst = FBADDR(x, y);
281 stride_dst = lcd_current_viewport->buffer->stride; 227 stride_dst = lcd_current_viewport->buffer->stride;
@@ -326,32 +272,6 @@ void ICODE_ATTR lcd_bitmap_transparent_part(const fb_data *src, int src_x,
326 x += lcd_current_viewport->x; 272 x += lcd_current_viewport->x;
327 y += lcd_current_viewport->y; 273 y += lcd_current_viewport->y;
328 274
329#if defined(HAVE_VIEWPORT_CLIP)
330 /********************* Viewport on screen clipping ********************/
331 /* nothing to draw? */
332 if ((x >= LCD_WIDTH) || (y >= LCD_HEIGHT)
333 || (x + width <= 0) || (y + height <= 0))
334 return;
335
336 /* clip image in viewport in screen */
337 if (x < 0)
338 {
339 width += x;
340 src_x -= x;
341 x = 0;
342 }
343 if (y < 0)
344 {
345 height += y;
346 src_y -= y;
347 y = 0;
348 }
349 if (x + width > LCD_WIDTH)
350 width = LCD_WIDTH - x;
351 if (y + height > LCD_HEIGHT)
352 height = LCD_HEIGHT - y;
353#endif
354
355 src += stride * src_y + src_x; /* move starting point */ 275 src += stride * src_y + src_x; /* move starting point */
356 dst = FBADDR(x, y); 276 dst = FBADDR(x, y);
357 277
diff --git a/firmware/drivers/lcd-1bit-vert.c b/firmware/drivers/lcd-1bit-vert.c
index dcf5e49504..ff95eacdbc 100644
--- a/firmware/drivers/lcd-1bit-vert.c
+++ b/firmware/drivers/lcd-1bit-vert.c
@@ -274,10 +274,6 @@ void LCDFN(drawpixel)(int x, int y)
274{ 274{
275 if ( ((unsigned)x < (unsigned)CURRENT_VP->width) 275 if ( ((unsigned)x < (unsigned)CURRENT_VP->width)
276 && ((unsigned)y < (unsigned)CURRENT_VP->height) 276 && ((unsigned)y < (unsigned)CURRENT_VP->height)
277#if defined(HAVE_VIEWPORT_CLIP)
278 && ((unsigned)x < (unsigned)LCDM(WIDTH))
279 && ((unsigned)y < (unsigned)LCDM(HEIGHT))
280#endif
281 ) 277 )
282 LCDFN(pixelfuncs)[CURRENT_VP->drawmode](CURRENT_VP->x + x, CURRENT_VP->y + y); 278 LCDFN(pixelfuncs)[CURRENT_VP->drawmode](CURRENT_VP->x + x, CURRENT_VP->y + y);
283} 279}
@@ -349,10 +345,6 @@ void LCDFN(drawline)(int x1, int y1, int x2, int y2)
349 { 345 {
350 if ( ((unsigned)x < (unsigned)CURRENT_VP->width) 346 if ( ((unsigned)x < (unsigned)CURRENT_VP->width)
351 && ((unsigned)y < (unsigned)CURRENT_VP->height) 347 && ((unsigned)y < (unsigned)CURRENT_VP->height)
352#if defined(HAVE_VIEWPORT_CLIP)
353 && ((unsigned)x < (unsigned)LCDM(WIDTH))
354 && ((unsigned)y < (unsigned)LCDM(HEIGHT))
355#endif
356 ) 348 )
357 pfunc(CURRENT_VP->x + x, CURRENT_VP->y + y); 349 pfunc(CURRENT_VP->x + x, CURRENT_VP->y + y);
358 350
@@ -403,20 +395,6 @@ void LCDFN(hline)(int x1, int x2, int y)
403 x2 += CURRENT_VP->x; 395 x2 += CURRENT_VP->x;
404 y += CURRENT_VP->y; 396 y += CURRENT_VP->y;
405 397
406#if defined(HAVE_VIEWPORT_CLIP)
407 /********************* Viewport on screen clipping ********************/
408 /* nothing to draw? */
409 if (((unsigned)y >= (unsigned) LCDM(HEIGHT)) || (x1 >= LCDM(WIDTH))
410 || (x2 < 0))
411 return;
412
413 /* clipping */
414 if (x1 < 0)
415 x1 = 0;
416 if (x2 >= LCDM(WIDTH))
417 x2 = LCDM(WIDTH)-1;
418#endif
419
420 width = x2 - x1 + 1; 398 width = x2 - x1 + 1;
421 399
422 bfunc = LCDFN(blockfuncs)[CURRENT_VP->drawmode]; 400 bfunc = LCDFN(blockfuncs)[CURRENT_VP->drawmode];
@@ -462,20 +440,6 @@ void LCDFN(vline)(int x, int y1, int y2)
462 y2 += CURRENT_VP->y; 440 y2 += CURRENT_VP->y;
463 x += CURRENT_VP->x; 441 x += CURRENT_VP->x;
464 442
465#if defined(HAVE_VIEWPORT_CLIP)
466 /********************* Viewport on screen clipping ********************/
467 /* nothing to draw? */
468 if (( (unsigned) x >= (unsigned)LCDM(WIDTH)) || (y1 >= LCDM(HEIGHT))
469 || (y2 < 0))
470 return;
471
472 /* clipping */
473 if (y1 < 0)
474 y1 = 0;
475 if (y2 >= LCDM(HEIGHT))
476 y2 = LCDM(HEIGHT)-1;
477#endif
478
479 bfunc = LCDFN(blockfuncs)[CURRENT_VP->drawmode]; 443 bfunc = LCDFN(blockfuncs)[CURRENT_VP->drawmode];
480 dst = LCDFB(x,y1>>3); 444 dst = LCDFB(x,y1>>3);
481 ny = y2 - (y1 & ~7); 445 ny = y2 - (y1 & ~7);
@@ -544,30 +508,6 @@ void LCDFN(fillrect)(int x, int y, int width, int height)
544 x += CURRENT_VP->x; 508 x += CURRENT_VP->x;
545 y += CURRENT_VP->y; 509 y += CURRENT_VP->y;
546 510
547#if defined(HAVE_VIEWPORT_CLIP)
548 /********************* Viewport on screen clipping ********************/
549 /* nothing to draw? */
550 if ((x >= LCDM(WIDTH)) || (y >= LCDM(HEIGHT))
551 || (x + width <= 0) || (y + height <= 0))
552 return;
553
554 /* clip image in viewport in screen */
555 if (x < 0)
556 {
557 width += x;
558 x = 0;
559 }
560 if (y < 0)
561 {
562 height += y;
563 y = 0;
564 }
565 if (x + width > LCDM(WIDTH))
566 width = LCDM(WIDTH) - x;
567 if (y + height > LCDM(HEIGHT))
568 height = LCDM(HEIGHT) - y;
569#endif
570
571 if (CURRENT_VP->drawmode & DRMODE_INVERSEVID) 511 if (CURRENT_VP->drawmode & DRMODE_INVERSEVID)
572 { 512 {
573 if (CURRENT_VP->drawmode & DRMODE_BG) 513 if (CURRENT_VP->drawmode & DRMODE_BG)
@@ -670,32 +610,6 @@ void ICODE_ATTR LCDFN(bitmap_part)(const unsigned char *src, int src_x,
670 x += CURRENT_VP->x; 610 x += CURRENT_VP->x;
671 y += CURRENT_VP->y; 611 y += CURRENT_VP->y;
672 612
673#if defined(HAVE_VIEWPORT_CLIP)
674 /********************* Viewport on screen clipping ********************/
675 /* nothing to draw? */
676 if ((x >= LCDM(WIDTH)) || (y >= LCDM(HEIGHT))
677 || (x + width <= 0) || (y + height <= 0))
678 return;
679
680 /* clip image in viewport in screen */
681 if (x < 0)
682 {
683 width += x;
684 src_x -= x;
685 x = 0;
686 }
687 if (y < 0)
688 {
689 height += y;
690 src_y -= y;
691 y = 0;
692 }
693 if (x + width > LCDM(WIDTH))
694 width = LCDM(WIDTH) - x;
695 if (y + height > LCDM(HEIGHT))
696 height = LCDM(HEIGHT) - y;
697#endif
698
699 src += stride * (src_y >> 3) + src_x; /* move starting point */ 613 src += stride * (src_y >> 3) + src_x; /* move starting point */
700 src_y &= 7; 614 src_y &= 7;
701 y -= src_y; 615 y -= src_y;
diff --git a/firmware/drivers/lcd-24bit.c b/firmware/drivers/lcd-24bit.c
index c3aa27f7ce..279ed5924a 100644
--- a/firmware/drivers/lcd-24bit.c
+++ b/firmware/drivers/lcd-24bit.c
@@ -70,30 +70,6 @@ void lcd_clear_viewport(void)
70 width = lcd_current_viewport->width; 70 width = lcd_current_viewport->width;
71 height = lcd_current_viewport->height; 71 height = lcd_current_viewport->height;
72 72
73#if defined(HAVE_VIEWPORT_CLIP)
74 /********************* Viewport on screen clipping ********************/
75 /* nothing to draw? */
76 if ((x >= LCD_WIDTH) || (y >= LCD_HEIGHT)
77 || (x + width <= 0) || (y + height <= 0))
78 return;
79
80 /* clip image in viewport in screen */
81 if (x < 0)
82 {
83 width += x;
84 x = 0;
85 }
86 if (y < 0)
87 {
88 height += y;
89 y = 0;
90 }
91 if (x + width > LCD_WIDTH)
92 width = LCD_WIDTH - x;
93 if (y + height > LCD_HEIGHT)
94 height = LCD_HEIGHT - y;
95#endif
96
97 len = STRIDE_MAIN(width, height); 73 len = STRIDE_MAIN(width, height);
98 step = STRIDE_MAIN(ROW_INC, COL_INC); 74 step = STRIDE_MAIN(ROW_INC, COL_INC);
99 75
@@ -222,30 +198,6 @@ void lcd_fillrect(int x, int y, int width, int height)
222 x += lcd_current_viewport->x; 198 x += lcd_current_viewport->x;
223 y += lcd_current_viewport->y; 199 y += lcd_current_viewport->y;
224 200
225#if defined(HAVE_VIEWPORT_CLIP)
226 /********************* Viewport on screen clipping ********************/
227 /* nothing to draw? */
228 if ((x >= LCD_WIDTH) || (y >= LCD_HEIGHT)
229 || (x + width <= 0) || (y + height <= 0))
230 return;
231
232 /* clip image in viewport in screen */
233 if (x < 0)
234 {
235 width += x;
236 x = 0;
237 }
238 if (y < 0)
239 {
240 height += y;
241 y = 0;
242 }
243 if (x + width > LCD_WIDTH)
244 width = LCD_WIDTH - x;
245 if (y + height > LCD_HEIGHT)
246 height = LCD_HEIGHT - y;
247#endif
248
249 /* drawmode and optimisation */ 201 /* drawmode and optimisation */
250 if (lcd_current_viewport->drawmode & DRMODE_INVERSEVID) 202 if (lcd_current_viewport->drawmode & DRMODE_INVERSEVID)
251 { 203 {
@@ -362,32 +314,6 @@ void ICODE_ATTR lcd_mono_bitmap_part(const unsigned char *src, int src_x,
362 x += lcd_current_viewport->x; 314 x += lcd_current_viewport->x;
363 y += lcd_current_viewport->y; 315 y += lcd_current_viewport->y;
364 316
365#if defined(HAVE_VIEWPORT_CLIP)
366 /********************* Viewport on screen clipping ********************/
367 /* nothing to draw? */
368 if ((x >= LCD_WIDTH) || (y >= LCD_HEIGHT)
369 || (x + width <= 0) || (y + height <= 0))
370 return;
371
372 /* clip image in viewport in screen */
373 if (x < 0)
374 {
375 width += x;
376 src_x -= x;
377 x = 0;
378 }
379 if (y < 0)
380 {
381 height += y;
382 src_y -= y;
383 y = 0;
384 }
385 if (x + width > LCD_WIDTH)
386 width = LCD_WIDTH - x;
387 if (y + height > LCD_HEIGHT)
388 height = LCD_HEIGHT - y;
389#endif
390
391 src += stride * (src_y >> 3) + src_x; /* move starting point */ 317 src += stride * (src_y >> 3) + src_x; /* move starting point */
392 src_y &= 7; 318 src_y &= 7;
393 src_end = src + width; 319 src_end = src + width;
@@ -592,32 +518,6 @@ static void ICODE_ATTR lcd_alpha_bitmap_part_mix(const fb_data* image,
592 x += lcd_current_viewport->x; 518 x += lcd_current_viewport->x;
593 y += lcd_current_viewport->y; 519 y += lcd_current_viewport->y;
594 520
595#if defined(HAVE_VIEWPORT_CLIP)
596 /********************* Viewport on screen clipping ********************/
597 /* nothing to draw? */
598 if ((x >= LCD_WIDTH) || (y >= LCD_HEIGHT)
599 || (x + width <= 0) || (y + height <= 0))
600 return;
601
602 /* clip image in viewport in screen */
603 if (x < 0)
604 {
605 width += x;
606 src_x -= x;
607 x = 0;
608 }
609 if (y < 0)
610 {
611 height += y;
612 src_y -= y;
613 y = 0;
614 }
615 if (x + width > LCD_WIDTH)
616 width = LCD_WIDTH - x;
617 if (y + height > LCD_HEIGHT)
618 height = LCD_HEIGHT - y;
619#endif
620
621 /* the following drawmode combinations are possible: 521 /* the following drawmode combinations are possible:
622 * 1) COMPLEMENT: just negates the framebuffer contents 522 * 1) COMPLEMENT: just negates the framebuffer contents
623 * 2) BG and BG+backdrop: draws _only_ background pixels with either 523 * 2) BG and BG+backdrop: draws _only_ background pixels with either
@@ -887,20 +787,6 @@ void lcd_hline(int x1, int x2, int y)
887 x2 += lcd_current_viewport->x; 787 x2 += lcd_current_viewport->x;
888 y += lcd_current_viewport->y; 788 y += lcd_current_viewport->y;
889 789
890#if defined(HAVE_VIEWPORT_CLIP)
891 /********************* Viewport on screen clipping ********************/
892 /* nothing to draw? */
893 if (((unsigned)y >= (unsigned) LCD_HEIGHT) || (x1 >= LCD_WIDTH)
894 || (x2 < 0))
895 return;
896
897 /* clipping */
898 if (x1 < 0)
899 x1 = 0;
900 if (x2 >= LCD_WIDTH)
901 x2 = LCD_WIDTH-1;
902#endif
903
904 width = x2 - x1 + 1; 790 width = x2 - x1 + 1;
905 791
906 dst = FBADDR(x1 , y); 792 dst = FBADDR(x1 , y);
@@ -944,20 +830,6 @@ void lcd_vline(int x, int y1, int y2)
944 y1 += lcd_current_viewport->y; 830 y1 += lcd_current_viewport->y;
945 y2 += lcd_current_viewport->y; 831 y2 += lcd_current_viewport->y;
946 832
947#if defined(HAVE_VIEWPORT_CLIP)
948 /********************* Viewport on screen clipping ********************/
949 /* nothing to draw? */
950 if (( (unsigned) x >= (unsigned)LCD_WIDTH) || (y1 >= LCD_HEIGHT)
951 || (y2 < 0))
952 return;
953
954 /* clipping */
955 if (y1 < 0)
956 y1 = 0;
957 if (y2 >= LCD_HEIGHT)
958 y2 = LCD_HEIGHT-1;
959#endif
960
961 dst = FBADDR(x , y1); 833 dst = FBADDR(x , y1);
962 dst_end = dst + (y2 - y1) * LCD_WIDTH; 834 dst_end = dst + (y2 - y1) * LCD_WIDTH;
963 835
@@ -1004,32 +876,6 @@ void ICODE_ATTR lcd_bitmap_part(const fb_data *src, int src_x, int src_y,
1004 x += lcd_current_viewport->x; 876 x += lcd_current_viewport->x;
1005 y += lcd_current_viewport->y; 877 y += lcd_current_viewport->y;
1006 878
1007#if defined(HAVE_VIEWPORT_CLIP)
1008 /********************* Viewport on screen clipping ********************/
1009 /* nothing to draw? */
1010 if ((x >= LCD_WIDTH) || (y >= LCD_HEIGHT)
1011 || (x + width <= 0) || (y + height <= 0))
1012 return;
1013
1014 /* clip image in viewport in screen */
1015 if (x < 0)
1016 {
1017 width += x;
1018 src_x -= x;
1019 x = 0;
1020 }
1021 if (y < 0)
1022 {
1023 height += y;
1024 src_y -= y;
1025 y = 0;
1026 }
1027 if (x + width > LCD_WIDTH)
1028 width = LCD_WIDTH - x;
1029 if (y + height > LCD_HEIGHT)
1030 height = LCD_HEIGHT - y;
1031#endif
1032
1033 src += stride * src_y + src_x; /* move starting point */ 879 src += stride * src_y + src_x; /* move starting point */
1034 dst = FBADDR(x, y); 880 dst = FBADDR(x, y);
1035 881
@@ -1078,32 +924,6 @@ void ICODE_ATTR lcd_bitmap_transparent_part(const fb_data *src, int src_x,
1078 x += lcd_current_viewport->x; 924 x += lcd_current_viewport->x;
1079 y += lcd_current_viewport->y; 925 y += lcd_current_viewport->y;
1080 926
1081#if defined(HAVE_VIEWPORT_CLIP)
1082 /********************* Viewport on screen clipping ********************/
1083 /* nothing to draw? */
1084 if ((x >= LCD_WIDTH) || (y >= LCD_HEIGHT)
1085 || (x + width <= 0) || (y + height <= 0))
1086 return;
1087
1088 /* clip image in viewport in screen */
1089 if (x < 0)
1090 {
1091 width += x;
1092 src_x -= x;
1093 x = 0;
1094 }
1095 if (y < 0)
1096 {
1097 height += y;
1098 src_y -= y;
1099 y = 0;
1100 }
1101 if (x + width > LCD_WIDTH)
1102 width = LCD_WIDTH - x;
1103 if (y + height > LCD_HEIGHT)
1104 height = LCD_HEIGHT - y;
1105#endif
1106
1107 src += stride * src_y + src_x; /* move starting point */ 927 src += stride * src_y + src_x; /* move starting point */
1108 dst = FBADDR(x, y); 928 dst = FBADDR(x, y);
1109 929
diff --git a/firmware/drivers/lcd-2bit-horz.c b/firmware/drivers/lcd-2bit-horz.c
index 85918a735c..66313d624b 100644
--- a/firmware/drivers/lcd-2bit-horz.c
+++ b/firmware/drivers/lcd-2bit-horz.c
@@ -420,10 +420,6 @@ void lcd_drawpixel(int x, int y)
420{ 420{
421 if ( ((unsigned)x < (unsigned)lcd_current_viewport->width) 421 if ( ((unsigned)x < (unsigned)lcd_current_viewport->width)
422 && ((unsigned)y < (unsigned)lcd_current_viewport->height) 422 && ((unsigned)y < (unsigned)lcd_current_viewport->height)
423#if defined(HAVE_VIEWPORT_CLIP)
424 && ((unsigned)x < (unsigned)LCD_WIDTH)
425 && ((unsigned)y < (unsigned)LCD_HEIGHT)
426#endif
427 ) 423 )
428 lcd_pixelfuncs[lcd_current_viewport->drawmode](lcd_current_viewport->x + x, lcd_current_viewport->y + y); 424 lcd_pixelfuncs[lcd_current_viewport->drawmode](lcd_current_viewport->x + x, lcd_current_viewport->y + y);
429} 425}
@@ -495,10 +491,6 @@ void lcd_drawline(int x1, int y1, int x2, int y2)
495 { 491 {
496 if ( ((unsigned)x < (unsigned)lcd_current_viewport->width) 492 if ( ((unsigned)x < (unsigned)lcd_current_viewport->width)
497 && ((unsigned)y < (unsigned)lcd_current_viewport->height) 493 && ((unsigned)y < (unsigned)lcd_current_viewport->height)
498#if defined(HAVE_VIEWPORT_CLIP)
499 && ((unsigned)x < (unsigned)LCD_WIDTH)
500 && ((unsigned)y < (unsigned)LCD_HEIGHT)
501#endif
502 ) 494 )
503 pfunc(lcd_current_viewport->x + x, lcd_current_viewport->y + y); 495 pfunc(lcd_current_viewport->x + x, lcd_current_viewport->y + y);
504 496
@@ -549,20 +541,6 @@ void lcd_hline(int x1, int x2, int y)
549 x2 += lcd_current_viewport->x; 541 x2 += lcd_current_viewport->x;
550 y += lcd_current_viewport->y; 542 y += lcd_current_viewport->y;
551 543
552#if defined(HAVE_VIEWPORT_CLIP)
553 /********************* Viewport on screen clipping ********************/
554 /* nothing to draw? */
555 if (((unsigned)y >= (unsigned) LCD_HEIGHT) || (x1 >= LCD_WIDTH)
556 || (x2 < 0))
557 return;
558
559 /* clipping */
560 if (x1 < 0)
561 x1 = 0;
562 if (x2 >= LCD_WIDTH)
563 x2 = LCD_WIDTH-1;
564#endif
565
566 bfunc = lcd_blockfuncs[lcd_current_viewport->drawmode]; 544 bfunc = lcd_blockfuncs[lcd_current_viewport->drawmode];
567 dst = FBADDR(x1>>2,y); 545 dst = FBADDR(x1>>2,y);
568 nx = x2 - (x1 & ~3); 546 nx = x2 - (x1 & ~3);
@@ -611,20 +589,6 @@ void lcd_vline(int x, int y1, int y2)
611 y2 += lcd_current_viewport->y; 589 y2 += lcd_current_viewport->y;
612 x += lcd_current_viewport->x; 590 x += lcd_current_viewport->x;
613 591
614#if defined(HAVE_VIEWPORT_CLIP)
615 /********************* Viewport on screen clipping ********************/
616 /* nothing to draw? */
617 if (( (unsigned) x >= (unsigned)LCD_WIDTH) || (y1 >= LCD_HEIGHT)
618 || (y2 < 0))
619 return;
620
621 /* clipping */
622 if (y1 < 0)
623 y1 = 0;
624 if (y2 >= LCD_HEIGHT)
625 y2 = LCD_HEIGHT-1;
626#endif
627
628 bfunc = lcd_blockfuncs[lcd_current_viewport->drawmode]; 592 bfunc = lcd_blockfuncs[lcd_current_viewport->drawmode];
629 dst = FBADDR(x>>2,y1); 593 dst = FBADDR(x>>2,y1);
630 stride_dst = LCD_FBSTRIDE(lcd_current_viewport->buffer->stride, 0); 594 stride_dst = LCD_FBSTRIDE(lcd_current_viewport->buffer->stride, 0);
@@ -688,30 +652,6 @@ void lcd_fillrect(int x, int y, int width, int height)
688 x += lcd_current_viewport->x; 652 x += lcd_current_viewport->x;
689 y += lcd_current_viewport->y; 653 y += lcd_current_viewport->y;
690 654
691#if defined(HAVE_VIEWPORT_CLIP)
692 /********************* Viewport on screen clipping ********************/
693 /* nothing to draw? */
694 if ((x >= LCD_WIDTH) || (y >= LCD_HEIGHT)
695 || (x + width <= 0) || (y + height <= 0))
696 return;
697
698 /* clip image in viewport in screen */
699 if (x < 0)
700 {
701 width += x;
702 x = 0;
703 }
704 if (y < 0)
705 {
706 height += y;
707 y = 0;
708 }
709 if (x + width > LCD_WIDTH)
710 width = LCD_WIDTH - x;
711 if (y + height > LCD_HEIGHT)
712 height = LCD_HEIGHT - y;
713#endif
714
715 bfunc = lcd_blockfuncs[lcd_current_viewport->drawmode]; 655 bfunc = lcd_blockfuncs[lcd_current_viewport->drawmode];
716 dst = FBADDR(x>>2,y); 656 dst = FBADDR(x>>2,y);
717 stride_dst = LCD_FBSTRIDE(lcd_current_viewport->buffer->stride, 0); 657 stride_dst = LCD_FBSTRIDE(lcd_current_viewport->buffer->stride, 0);
@@ -792,32 +732,6 @@ void ICODE_ATTR lcd_mono_bitmap_part(const unsigned char *src, int src_x,
792 x += lcd_current_viewport->x; /* adjust for viewport */ 732 x += lcd_current_viewport->x; /* adjust for viewport */
793 y += lcd_current_viewport->y; /* adjust for viewport */ 733 y += lcd_current_viewport->y; /* adjust for viewport */
794 734
795#if defined(HAVE_VIEWPORT_CLIP)
796 /********************* Viewport on screen clipping ********************/
797 /* nothing to draw? */
798 if ((x >= LCD_WIDTH) || (y >= LCD_HEIGHT)
799 || (x + width <= 0) || (y + height <= 0))
800 return;
801
802 /* clip image in viewport in screen */
803 if (x < 0)
804 {
805 width += x;
806 src_x -= x;
807 x = 0;
808 }
809 if (y < 0)
810 {
811 height += y;
812 src_y -= y;
813 y = 0;
814 }
815 if (x + width > LCD_WIDTH)
816 width = LCD_WIDTH - x;
817 if (y + height > LCD_HEIGHT)
818 height = LCD_HEIGHT - y;
819#endif
820
821 src += stride * (src_y >> 3) + src_x; /* move starting point */ 735 src += stride * (src_y >> 3) + src_x; /* move starting point */
822 src_y &= 7; 736 src_y &= 7;
823 src_end = src + width; 737 src_end = src + width;
@@ -1007,32 +921,6 @@ void ICODE_ATTR lcd_bitmap_part(const unsigned char *src, int src_x,
1007 x += lcd_current_viewport->x; 921 x += lcd_current_viewport->x;
1008 y += lcd_current_viewport->y; 922 y += lcd_current_viewport->y;
1009 923
1010#if defined(HAVE_VIEWPORT_CLIP)
1011 /********************* Viewport on screen clipping ********************/
1012 /* nothing to draw? */
1013 if ((x >= LCD_WIDTH) || (y >= LCD_HEIGHT)
1014 || (x + width <= 0) || (y + height <= 0))
1015 return;
1016
1017 /* clip image in viewport in screen */
1018 if (x < 0)
1019 {
1020 width += x;
1021 src_x -= x;
1022 x = 0;
1023 }
1024 if (y < 0)
1025 {
1026 height += y;
1027 src_y -= y;
1028 y = 0;
1029 }
1030 if (x + width > LCD_WIDTH)
1031 width = LCD_WIDTH - x;
1032 if (y + height > LCD_HEIGHT)
1033 height = LCD_HEIGHT - y;
1034#endif
1035
1036 stride = LCD_FBSTRIDE(stride, 0); /* convert to no. of bytes */ 924 stride = LCD_FBSTRIDE(stride, 0); /* convert to no. of bytes */
1037 925
1038 src += stride * src_y + (src_x >> 2); /* move starting point */ 926 src += stride * src_y + (src_x >> 2); /* move starting point */
diff --git a/firmware/drivers/lcd-2bit-vert.c b/firmware/drivers/lcd-2bit-vert.c
index a059e3b512..4ce9960419 100644
--- a/firmware/drivers/lcd-2bit-vert.c
+++ b/firmware/drivers/lcd-2bit-vert.c
@@ -422,10 +422,6 @@ void lcd_drawpixel(int x, int y)
422{ 422{
423 if ( ((unsigned)x < (unsigned)lcd_current_viewport->width) 423 if ( ((unsigned)x < (unsigned)lcd_current_viewport->width)
424 && ((unsigned)y < (unsigned)lcd_current_viewport->height) 424 && ((unsigned)y < (unsigned)lcd_current_viewport->height)
425#if defined(HAVE_VIEWPORT_CLIP)
426 && ((unsigned)x < (unsigned)LCD_WIDTH)
427 && ((unsigned)y < (unsigned)LCD_HEIGHT)
428#endif
429 ) 425 )
430 lcd_pixelfuncs[lcd_current_viewport->drawmode](lcd_current_viewport->x + x, lcd_current_viewport->y + y); 426 lcd_pixelfuncs[lcd_current_viewport->drawmode](lcd_current_viewport->x + x, lcd_current_viewport->y + y);
431} 427}
@@ -497,10 +493,6 @@ void lcd_drawline(int x1, int y1, int x2, int y2)
497 { 493 {
498 if ( ((unsigned)x < (unsigned)lcd_current_viewport->width) 494 if ( ((unsigned)x < (unsigned)lcd_current_viewport->width)
499 && ((unsigned)y < (unsigned)lcd_current_viewport->height) 495 && ((unsigned)y < (unsigned)lcd_current_viewport->height)
500#if defined(HAVE_VIEWPORT_CLIP)
501 && ((unsigned)x < (unsigned)LCD_WIDTH)
502 && ((unsigned)y < (unsigned)LCD_HEIGHT)
503#endif
504 ) 496 )
505 pfunc(lcd_current_viewport->x + x, lcd_current_viewport->y + y); 497 pfunc(lcd_current_viewport->x + x, lcd_current_viewport->y + y);
506 498
@@ -552,20 +544,6 @@ void lcd_hline(int x1, int x2, int y)
552 x2 += lcd_current_viewport->x; 544 x2 += lcd_current_viewport->x;
553 y += lcd_current_viewport->y; 545 y += lcd_current_viewport->y;
554 546
555#if defined(HAVE_VIEWPORT_CLIP)
556 /********************* Viewport on screen clipping ********************/
557 /* nothing to draw? */
558 if (((unsigned)y >= (unsigned) LCD_HEIGHT) || (x1 >= LCD_WIDTH)
559 || (x2 < 0))
560 return;
561
562 /* clipping */
563 if (x1 < 0)
564 x1 = 0;
565 if (x2 >= LCD_WIDTH)
566 x2 = LCD_WIDTH-1;
567#endif
568
569 width = x2 - x1 + 1; 547 width = x2 - x1 + 1;
570 548
571 bfunc = lcd_blockfuncs[lcd_current_viewport->drawmode]; 549 bfunc = lcd_blockfuncs[lcd_current_viewport->drawmode];
@@ -611,20 +589,6 @@ void lcd_vline(int x, int y1, int y2)
611 y2 += lcd_current_viewport->y; 589 y2 += lcd_current_viewport->y;
612 x += lcd_current_viewport->x; 590 x += lcd_current_viewport->x;
613 591
614#if defined(HAVE_VIEWPORT_CLIP)
615 /********************* Viewport on screen clipping ********************/
616 /* nothing to draw? */
617 if (( (unsigned) x >= (unsigned)LCD_WIDTH) || (y1 >= LCD_HEIGHT)
618 || (y2 < 0))
619 return;
620
621 /* clipping */
622 if (y1 < 0)
623 y1 = 0;
624 if (y2 >= LCD_HEIGHT)
625 y2 = LCD_HEIGHT-1;
626#endif
627
628 bfunc = lcd_blockfuncs[lcd_current_viewport->drawmode]; 592 bfunc = lcd_blockfuncs[lcd_current_viewport->drawmode];
629 dst = FBADDR(x,y1>>2); 593 dst = FBADDR(x,y1>>2);
630 stride_dst = lcd_current_viewport->buffer->stride; 594 stride_dst = lcd_current_viewport->buffer->stride;
@@ -693,30 +657,6 @@ void lcd_fillrect(int x, int y, int width, int height)
693 x += lcd_current_viewport->x; 657 x += lcd_current_viewport->x;
694 y += lcd_current_viewport->y; 658 y += lcd_current_viewport->y;
695 659
696#if defined(HAVE_VIEWPORT_CLIP)
697 /********************* Viewport on screen clipping ********************/
698 /* nothing to draw? */
699 if ((x >= LCD_WIDTH) || (y >= LCD_HEIGHT)
700 || (x + width <= 0) || (y + height <= 0))
701 return;
702
703 /* clip image in viewport in screen */
704 if (x < 0)
705 {
706 width += x;
707 x = 0;
708 }
709 if (y < 0)
710 {
711 height += y;
712 y = 0;
713 }
714 if (x + width > LCD_WIDTH)
715 width = LCD_WIDTH - x;
716 if (y + height > LCD_HEIGHT)
717 height = LCD_HEIGHT - y;
718#endif
719
720 if (lcd_current_viewport->drawmode & DRMODE_INVERSEVID) 660 if (lcd_current_viewport->drawmode & DRMODE_INVERSEVID)
721 { 661 {
722 if ((lcd_current_viewport->drawmode & DRMODE_BG) && !lcd_backdrop) 662 if ((lcd_current_viewport->drawmode & DRMODE_BG) && !lcd_backdrop)
@@ -819,32 +759,6 @@ void ICODE_ATTR lcd_mono_bitmap_part(const unsigned char *src, int src_x,
819 x += lcd_current_viewport->x; 759 x += lcd_current_viewport->x;
820 y += lcd_current_viewport->y; 760 y += lcd_current_viewport->y;
821 761
822#if defined(HAVE_VIEWPORT_CLIP)
823 /********************* Viewport on screen clipping ********************/
824 /* nothing to draw? */
825 if ((x >= LCD_WIDTH) || (y >= LCD_HEIGHT)
826 || (x + width <= 0) || (y + height <= 0))
827 return;
828
829 /* clip image in viewport in screen */
830 if (x < 0)
831 {
832 width += x;
833 src_x -= x;
834 x = 0;
835 }
836 if (y < 0)
837 {
838 height += y;
839 src_y -= y;
840 y = 0;
841 }
842 if (x + width > LCD_WIDTH)
843 width = LCD_WIDTH - x;
844 if (y + height > LCD_HEIGHT)
845 height = LCD_HEIGHT - y;
846#endif
847
848 src += stride * (src_y >> 3) + src_x; /* move starting point */ 762 src += stride * (src_y >> 3) + src_x; /* move starting point */
849 src_y &= 7; 763 src_y &= 7;
850 y -= src_y; 764 y -= src_y;
@@ -1018,31 +932,6 @@ void ICODE_ATTR lcd_bitmap_part(const fb_data *src, int src_x, int src_y,
1018 x += lcd_current_viewport->x; 932 x += lcd_current_viewport->x;
1019 y += lcd_current_viewport->y; 933 y += lcd_current_viewport->y;
1020 934
1021#if defined(HAVE_VIEWPORT_CLIP)
1022 /********************* Viewport on screen clipping ********************/
1023 /* nothing to draw? */
1024 if ((x >= LCD_WIDTH) || (y >= LCD_HEIGHT)
1025 || (x + width <= 0) || (y + height <= 0))
1026 return;
1027
1028 /* clip image in viewport in screen */
1029 if (x < 0)
1030 {
1031 width += x;
1032 src_x -= x;
1033 x = 0;
1034 }
1035 if (y < 0)
1036 {
1037 height += y;
1038 src_y -= y;
1039 y = 0;
1040 }
1041 if (x + width > LCD_WIDTH)
1042 width = LCD_WIDTH - x;
1043 if (y + height > LCD_HEIGHT)
1044 height = LCD_HEIGHT - y;
1045#endif
1046 src += stride * (src_y >> 2) + src_x; /* move starting point */ 935 src += stride * (src_y >> 2) + src_x; /* move starting point */
1047 src_y &= 3; 936 src_y &= 3;
1048 y -= src_y; 937 y -= src_y;
diff --git a/firmware/drivers/lcd-2bit-vi.c b/firmware/drivers/lcd-2bit-vi.c
index 423f4536d4..b969c93216 100644
--- a/firmware/drivers/lcd-2bit-vi.c
+++ b/firmware/drivers/lcd-2bit-vi.c
@@ -455,10 +455,6 @@ void LCDFN(drawpixel)(int x, int y)
455{ 455{
456 if ( ((unsigned)x < (unsigned)CURRENT_VP->width) 456 if ( ((unsigned)x < (unsigned)CURRENT_VP->width)
457 && ((unsigned)y < (unsigned)CURRENT_VP->height) 457 && ((unsigned)y < (unsigned)CURRENT_VP->height)
458#if defined(HAVE_VIEWPORT_CLIP)
459 && ((unsigned)x < (unsigned)LCDM(WIDTH))
460 && ((unsigned)y < (unsigned)LCDM(HEIGHT))
461#endif
462 ) 458 )
463 LCDFN(pixelfuncs)[CURRENT_VP->drawmode](CURRENT_VP->x+x, CURRENT_VP->y+y); 459 LCDFN(pixelfuncs)[CURRENT_VP->drawmode](CURRENT_VP->x+x, CURRENT_VP->y+y);
464} 460}
@@ -530,10 +526,6 @@ void LCDFN(drawline)(int x1, int y1, int x2, int y2)
530 { 526 {
531 if ( ((unsigned)x < (unsigned)CURRENT_VP->width) 527 if ( ((unsigned)x < (unsigned)CURRENT_VP->width)
532 && ((unsigned)y < (unsigned)CURRENT_VP->height) 528 && ((unsigned)y < (unsigned)CURRENT_VP->height)
533#if defined(HAVE_VIEWPORT_CLIP)
534 && ((unsigned)x < (unsigned)LCDM(WIDTH))
535 && ((unsigned)y < (unsigned)LCDM(HEIGHT))
536#endif
537 ) 529 )
538 pfunc(CURRENT_VP->x + x, CURRENT_VP->y + y); 530 pfunc(CURRENT_VP->x + x, CURRENT_VP->y + y);
539 531
@@ -585,20 +577,6 @@ void LCDFN(hline)(int x1, int x2, int y)
585 x2 += CURRENT_VP->x; 577 x2 += CURRENT_VP->x;
586 y += CURRENT_VP->y; 578 y += CURRENT_VP->y;
587 579
588#if defined(HAVE_VIEWPORT_CLIP)
589 /********************* Viewport on screen clipping ********************/
590 /* nothing to draw? */
591 if (((unsigned)y >= (unsigned) LCDM(HEIGHT)) || (x1 >= LCDM(WIDTH))
592 || (x2 < 0))
593 return;
594
595 /* clipping */
596 if (x1 < 0)
597 x1 = 0;
598 if (x2 >= LCDM(WIDTH))
599 x2 = LCDM(WIDTH)-1;
600#endif
601
602 width = x2 - x1 + 1; 580 width = x2 - x1 + 1;
603 581
604 bfunc = LCDFN(blockfuncs)[CURRENT_VP->drawmode]; 582 bfunc = LCDFN(blockfuncs)[CURRENT_VP->drawmode];
@@ -644,20 +622,6 @@ void LCDFN(vline)(int x, int y1, int y2)
644 y2 += CURRENT_VP->y; 622 y2 += CURRENT_VP->y;
645 x += CURRENT_VP->x; 623 x += CURRENT_VP->x;
646 624
647#if defined(HAVE_VIEWPORT_CLIP)
648 /********************* Viewport on screen clipping ********************/
649 /* nothing to draw? */
650 if (( (unsigned) x >= (unsigned)LCDM(WIDTH)) || (y1 >= LCDM(HEIGHT))
651 || (y2 < 0))
652 return;
653
654 /* clipping */
655 if (y1 < 0)
656 y1 = 0;
657 if (y2 >= LCDM(HEIGHT))
658 y2 = LCDM(HEIGHT)-1;
659#endif
660
661 bfunc = LCDFN(blockfuncs)[CURRENT_VP->drawmode]; 625 bfunc = LCDFN(blockfuncs)[CURRENT_VP->drawmode];
662 dst = LCDFB(x,y1>>3); 626 dst = LCDFB(x,y1>>3);
663 stride_dst = CURRENT_VP->buffer->stride; 627 stride_dst = CURRENT_VP->buffer->stride;
@@ -728,31 +692,6 @@ void LCDFN(fillrect)(int x, int y, int width, int height)
728 x += CURRENT_VP->x; 692 x += CURRENT_VP->x;
729 y += CURRENT_VP->y; 693 y += CURRENT_VP->y;
730 694
731#if defined(HAVE_VIEWPORT_CLIP)
732 /********************* Viewport on screen clipping ********************/
733 /* nothing to draw? */
734 if ((x >= LCDM(WIDTH)) || (y >= LCDM(HEIGHT))
735 || (x + width <= 0) || (y + height <= 0))
736 return;
737
738 /* clip image in viewport in screen */
739 if (x < 0)
740 {
741 width += x;
742 x = 0;
743 }
744 if (y < 0)
745 {
746 height += y;
747 y = 0;
748 }
749 if (x + width > LCDM(WIDTH))
750 width = LCDM(WIDTH) - x;
751 if (y + height > LCDM(HEIGHT))
752 height = LCDM(HEIGHT) - y;
753#endif
754
755
756 if (CURRENT_VP->drawmode & DRMODE_INVERSEVID) 695 if (CURRENT_VP->drawmode & DRMODE_INVERSEVID)
757 { 696 {
758 if ((CURRENT_VP->drawmode & DRMODE_BG) && !backdrop) 697 if ((CURRENT_VP->drawmode & DRMODE_BG) && !backdrop)
@@ -857,32 +796,6 @@ void ICODE_ATTR LCDFN(mono_bitmap_part)(const unsigned char *src, int src_x,
857 x += CURRENT_VP->x; 796 x += CURRENT_VP->x;
858 y += CURRENT_VP->y; 797 y += CURRENT_VP->y;
859 798
860#if defined(HAVE_VIEWPORT_CLIP)
861 /********************* Viewport on screen clipping ********************/
862 /* nothing to draw? */
863 if ((x >= LCDM(WIDTH)) || (y >= LCDM(HEIGHT))
864 || (x + width <= 0) || (y + height <= 0))
865 return;
866
867 /* clip image in viewport in screen */
868 if (x < 0)
869 {
870 width += x;
871 src_x -= x;
872 x = 0;
873 }
874 if (y < 0)
875 {
876 height += y;
877 src_y -= y;
878 y = 0;
879 }
880 if (x + width > LCDM(WIDTH))
881 width = LCDM(WIDTH) - x;
882 if (y + height > LCDM(HEIGHT))
883 height = LCDM(HEIGHT) - y;
884#endif
885
886 src += stride * (src_y >> 3) + src_x; /* move starting point */ 799 src += stride * (src_y >> 3) + src_x; /* move starting point */
887 src_y &= 7; 800 src_y &= 7;
888 y -= src_y; 801 y -= src_y;
@@ -1027,32 +940,6 @@ void ICODE_ATTR LCDFN(bitmap_part)(const FBFN(data) *src, int src_x,
1027 x += CURRENT_VP->x; 940 x += CURRENT_VP->x;
1028 y += CURRENT_VP->y; 941 y += CURRENT_VP->y;
1029 942
1030#if defined(HAVE_VIEWPORT_CLIP)
1031 /********************* Viewport on screen clipping ********************/
1032 /* nothing to draw? */
1033 if ((x >= LCDM(WIDTH)) || (y >= LCDM(HEIGHT))
1034 || (x + width <= 0) || (y + height <= 0))
1035 return;
1036
1037 /* clip image in viewport in screen */
1038 if (x < 0)
1039 {
1040 width += x;
1041 src_x -= x;
1042 x = 0;
1043 }
1044 if (y < 0)
1045 {
1046 height += y;
1047 src_y -= y;
1048 y = 0;
1049 }
1050 if (x + width > LCDM(WIDTH))
1051 width = LCDM(WIDTH) - x;
1052 if (y + height > LCDM(HEIGHT))
1053 height = LCDM(HEIGHT) - y;
1054#endif
1055
1056 src += stride * (src_y >> 3) + src_x; /* move starting point */ 943 src += stride * (src_y >> 3) + src_x; /* move starting point */
1057 src_y &= 7; 944 src_y &= 7;
1058 y -= src_y; 945 y -= src_y;
diff --git a/firmware/drivers/lcd-bitmap-common.c b/firmware/drivers/lcd-bitmap-common.c
index c85d16cb70..24b302b6d4 100644
--- a/firmware/drivers/lcd-bitmap-common.c
+++ b/firmware/drivers/lcd-bitmap-common.c
@@ -139,11 +139,7 @@ struct viewport* LCDFN(set_viewport_ex)(struct viewport* vp, int flags)
139 || vp->x + vp->width > LCDM(WIDTH) 139 || vp->x + vp->width > LCDM(WIDTH)
140 || vp->y + vp->height > LCDM(HEIGHT)) 140 || vp->y + vp->height > LCDM(HEIGHT))
141 { 141 {
142#if !defined(HAVE_VIEWPORT_CLIP)
143 DEBUGF("ERROR: " 142 DEBUGF("ERROR: "
144#else
145 DEBUGF("NOTE: "
146#endif
147 "set_viewport out of bounds: x: %d y: %d width: %d height:%d\n", 143 "set_viewport out of bounds: x: %d y: %d width: %d height:%d\n",
148 vp->x, vp->y, vp->width, vp->height); 144 vp->x, vp->y, vp->width, vp->height);
149 } 145 }
diff --git a/firmware/drivers/lcd-color-common.c b/firmware/drivers/lcd-color-common.c
index a867583d36..36144b574c 100644
--- a/firmware/drivers/lcd-color-common.c
+++ b/firmware/drivers/lcd-color-common.c
@@ -198,10 +198,6 @@ void lcd_drawpixel(int x, int y)
198{ 198{
199 if ( ((unsigned)x < (unsigned)lcd_current_viewport->width) 199 if ( ((unsigned)x < (unsigned)lcd_current_viewport->width)
200 && ((unsigned)y < (unsigned)lcd_current_viewport->height) 200 && ((unsigned)y < (unsigned)lcd_current_viewport->height)
201#if defined(HAVE_VIEWPORT_CLIP)
202 && ((unsigned)x < (unsigned)LCD_WIDTH)
203 && ((unsigned)y < (unsigned)LCD_HEIGHT)
204#endif
205 ) 201 )
206 lcd_fastpixelfuncs[lcd_current_viewport->drawmode](FBADDR(lcd_current_viewport->x+x, lcd_current_viewport->y+y)); 202 lcd_fastpixelfuncs[lcd_current_viewport->drawmode](FBADDR(lcd_current_viewport->x+x, lcd_current_viewport->y+y));
207} 203}
@@ -281,10 +277,6 @@ void lcd_drawline(int x1, int y1, int x2, int y2)
281 if ((x >= 0 && y >= 0) 277 if ((x >= 0 && y >= 0)
282 && (x < w_vp) 278 && (x < w_vp)
283 && (y < h_vp) 279 && (y < h_vp)
284#if defined(HAVE_VIEWPORT_CLIP)
285 && (x < LCD_WIDTH)
286 && (y < LCD_HEIGHT)
287#endif
288 ) 280 )
289 pfunc(fbaddr( x + x_vp, y + y_vp)); 281 pfunc(fbaddr( x + x_vp, y + y_vp));
290 282
diff --git a/firmware/export/config/mrobe500.h b/firmware/export/config/mrobe500.h
index ffc8a6bfb8..ebda42d160 100644
--- a/firmware/export/config/mrobe500.h
+++ b/firmware/export/config/mrobe500.h
@@ -65,9 +65,6 @@
65/* define this if the target has volume keys which can be used in the lists */ 65/* define this if the target has volume keys which can be used in the lists */
66#define HAVE_VOLUME_IN_LIST 66#define HAVE_VOLUME_IN_LIST
67 67
68/* define this if you want viewport clipping enabled for safe LCD functions */
69#define HAVE_VIEWPORT_CLIP
70
71/* LCD dimensions */ 68/* LCD dimensions */
72#define CONFIG_LCD LCD_MROBE500 69#define CONFIG_LCD LCD_MROBE500
73 70
diff --git a/firmware/export/config/sansaconnect.h b/firmware/export/config/sansaconnect.h
index fa929f3c10..a06ea9b207 100644
--- a/firmware/export/config/sansaconnect.h
+++ b/firmware/export/config/sansaconnect.h
@@ -66,9 +66,6 @@
66/* define this if the target has volume keys which can be used in the lists */ 66/* define this if the target has volume keys which can be used in the lists */
67#define HAVE_VOLUME_IN_LIST 67#define HAVE_VOLUME_IN_LIST
68 68
69/* define this if you want viewport clipping enabled for safe LCD functions */
70#define HAVE_VIEWPORT_CLIP
71
72/* LCD dimensions */ 69/* LCD dimensions */
73#define CONFIG_LCD LCD_CONNECT 70#define CONFIG_LCD LCD_CONNECT
74 71