summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--firmware/drivers/lcd-1bit-vert.c111
-rw-r--r--firmware/drivers/lcd-2bit-horz.c111
-rw-r--r--firmware/drivers/lcd-2bit-vert.c111
-rw-r--r--firmware/drivers/lcd-2bit-vi.c111
-rw-r--r--firmware/drivers/lcd-bitmap-common.c128
-rw-r--r--firmware/drivers/lcd-color-common.c114
6 files changed, 127 insertions, 559 deletions
diff --git a/firmware/drivers/lcd-1bit-vert.c b/firmware/drivers/lcd-1bit-vert.c
index e1b65ca9c0..ed66ee7e0c 100644
--- a/firmware/drivers/lcd-1bit-vert.c
+++ b/firmware/drivers/lcd-1bit-vert.c
@@ -271,102 +271,6 @@ void LCDFN(clear_viewport)(void)
CURRENT_VP->flags &= ~(VP_FLAG_VP_SET_CLEAN);
}
-/* Set a single pixel */
-void LCDFN(drawpixel)(int x, int y)
-{
- if (LCDFN(clip_viewport_pixel)(&x, &y))
- LCDFN(pixelfuncs)[CURRENT_VP->drawmode](x, y);
-}
-
-/* Draw a line */
-void LCDFN(drawline)(int x1, int y1, int x2, int y2)
-{
- int numpixels;
- int i;
- int deltax, deltay;
- int d, dinc1, dinc2;
- int x, xinc1, xinc2;
- int y, yinc1, yinc2;
- int x_vp, y_vp, w_vp, h_vp;
- LCDFN(pixelfunc_type) *pfunc = LCDFN(pixelfuncs)[CURRENT_VP->drawmode];
-
- deltax = abs(x2 - x1);
- if (deltax == 0)
- {
- /* DEBUGF(LCDNAME "drawline() called for vertical line - optimisation.\n"); */
- LCDFN(vline)(x1, y1, y2);
- return;
- }
- deltay = abs(y2 - y1);
- if (deltay == 0)
- {
- /* DEBUGF(LCDNAME "drawline() called for horizontal line - optimisation.\n"); */
- LCDFN(hline)(x1, x2, y1);
- return;
- }
- xinc2 = 1;
- yinc2 = 1;
-
- if (deltax >= deltay)
- {
- numpixels = deltax;
- d = 2 * deltay - deltax;
- dinc1 = deltay * 2;
- dinc2 = (deltay - deltax) * 2;
- xinc1 = 1;
- yinc1 = 0;
- }
- else
- {
- numpixels = deltay;
- d = 2 * deltax - deltay;
- dinc1 = deltax * 2;
- dinc2 = (deltax - deltay) * 2;
- xinc1 = 0;
- yinc1 = 1;
- }
- numpixels++; /* include endpoints */
-
- if (x1 > x2)
- {
- xinc1 = -xinc1;
- xinc2 = -xinc2;
- }
-
- if (y1 > y2)
- {
- yinc1 = -yinc1;
- yinc2 = -yinc2;
- }
-
- x = x1;
- y = y1;
-
- x_vp = CURRENT_VP->x;
- y_vp = CURRENT_VP->y;
- w_vp = CURRENT_VP->width;
- h_vp = CURRENT_VP->height;
-
- for (i = 0; i < numpixels; i++)
- {
- if (x >= 0 && y >= 0 && x < w_vp && y < h_vp)
- pfunc(x + x_vp, y + y_vp);
-
- if (d < 0)
- {
- d += dinc1;
- x += xinc1;
- y += yinc1;
- }
- else
- {
- d += dinc2;
- x += xinc2;
- y += yinc2;
- }
- }
-}
-
/* Draw a horizontal line (optimised) */
void LCDFN(hline)(int x1, int x2, int y)
{
@@ -419,21 +323,6 @@ void LCDFN(vline)(int x, int y1, int y2)
bfunc(dst, mask, 0xFFu);
}
-/* Draw a rectangular box */
-void LCDFN(drawrect)(int x, int y, int width, int height)
-{
- if ((width <= 0) || (height <= 0))
- return;
-
- int x2 = x + width - 1;
- int y2 = y + height - 1;
-
- LCDFN(vline)(x, y, y2);
- LCDFN(vline)(x2, y, y2);
- LCDFN(hline)(x, x2, y);
- LCDFN(hline)(x, x2, y2);
-}
-
/* Fill a rectangular area */
void LCDFN(fillrect)(int x, int y, int width, int height)
{
diff --git a/firmware/drivers/lcd-2bit-horz.c b/firmware/drivers/lcd-2bit-horz.c
index 37125679ad..1b192377f6 100644
--- a/firmware/drivers/lcd-2bit-horz.c
+++ b/firmware/drivers/lcd-2bit-horz.c
@@ -417,102 +417,6 @@ void lcd_clear_viewport(void)
lcd_current_viewport->flags &= ~(VP_FLAG_VP_SET_CLEAN);
}
-/* Set a single pixel */
-void lcd_drawpixel(int x, int y)
-{
- if (lcd_clip_viewport_pixel(&x, &y))
- lcd_pixelfuncs[lcd_current_viewport->drawmode](x, y);
-}
-
-/* Draw a line */
-void lcd_drawline(int x1, int y1, int x2, int y2)
-{
- int numpixels;
- int i;
- int deltax, deltay;
- int d, dinc1, dinc2;
- int x, xinc1, xinc2;
- int y, yinc1, yinc2;
- int x_vp, y_vp, w_vp, h_vp;
- lcd_pixelfunc_type *pfunc = lcd_pixelfuncs[lcd_current_viewport->drawmode];
-
- deltay = abs(y2 - y1);
- if (deltay == 0)
- {
- /* DEBUGF("lcd_drawline() called for horizontal line - optimisation.\n"); */
- lcd_hline(x1, x2, y1);
- return;
- }
- deltax = abs(x2 - x1);
- if (deltax == 0)
- {
- /* DEBUGF("lcd_drawline() called for vertical line - optimisation.\n"); */
- lcd_vline(x1, y1, y2);
- return;
- }
- xinc2 = 1;
- yinc2 = 1;
-
- if (deltax >= deltay)
- {
- numpixels = deltax;
- d = 2 * deltay - deltax;
- dinc1 = deltay * 2;
- dinc2 = (deltay - deltax) * 2;
- xinc1 = 1;
- yinc1 = 0;
- }
- else
- {
- numpixels = deltay;
- d = 2 * deltax - deltay;
- dinc1 = deltax * 2;
- dinc2 = (deltax - deltay) * 2;
- xinc1 = 0;
- yinc1 = 1;
- }
- numpixels++; /* include endpoints */
-
- if (x1 > x2)
- {
- xinc1 = -xinc1;
- xinc2 = -xinc2;
- }
-
- if (y1 > y2)
- {
- yinc1 = -yinc1;
- yinc2 = -yinc2;
- }
-
- x = x1;
- y = y1;
-
- x_vp = lcd_current_viewport->x;
- y_vp = lcd_current_viewport->y;
- w_vp = lcd_current_viewport->width;
- h_vp = lcd_current_viewport->height;
-
- for (i = 0; i < numpixels; i++)
- {
- if (x >= 0 && y >= 0 && x < w_vp && y < h_vp)
- pfunc(x + x_vp, y + y_vp);
-
- if (d < 0)
- {
- d += dinc1;
- x += xinc1;
- y += yinc1;
- }
- else
- {
- d += dinc2;
- x += xinc2;
- y += yinc2;
- }
- }
-}
-
/* Draw a horizontal line (optimised) */
void lcd_hline(int x1, int x2, int y)
{
@@ -564,21 +468,6 @@ void lcd_vline(int x, int y1, int y2)
while (dst <= dst_end);
}
-/* Draw a rectangular box */
-void lcd_drawrect(int x, int y, int width, int height)
-{
- if ((width <= 0) || (height <= 0))
- return;
-
- int x2 = x + width - 1;
- int y2 = y + height - 1;
-
- lcd_vline(x, y, y2);
- lcd_vline(x2, y, y2);
- lcd_hline(x, x2, y);
- lcd_hline(x, x2, y2);
-}
-
/* Fill a rectangular area */
void lcd_fillrect(int x, int y, int width, int height)
{
diff --git a/firmware/drivers/lcd-2bit-vert.c b/firmware/drivers/lcd-2bit-vert.c
index 5fd86c409a..9e1eb0ed37 100644
--- a/firmware/drivers/lcd-2bit-vert.c
+++ b/firmware/drivers/lcd-2bit-vert.c
@@ -419,102 +419,6 @@ void lcd_clear_viewport(void)
lcd_current_viewport->flags &= ~(VP_FLAG_VP_SET_CLEAN);
}
-/* Set a single pixel */
-void lcd_drawpixel(int x, int y)
-{
- if (lcd_clip_viewport_pixel(&x, &y))
- lcd_pixelfuncs[lcd_current_viewport->drawmode](x, y);
-}
-
-/* Draw a line */
-void lcd_drawline(int x1, int y1, int x2, int y2)
-{
- int numpixels;
- int i;
- int deltax, deltay;
- int d, dinc1, dinc2;
- int x, xinc1, xinc2;
- int y, yinc1, yinc2;
- int x_vp, y_vp, w_vp, h_vp;
- lcd_pixelfunc_type *pfunc = lcd_pixelfuncs[lcd_current_viewport->drawmode];
-
- deltax = abs(x2 - x1);
- if (deltax == 0)
- {
- /* DEBUGF("lcd_drawline() called for vertical line - optimisation.\n"); */
- lcd_vline(x1, y1, y2);
- return;
- }
- deltay = abs(y2 - y1);
- if (deltay == 0)
- {
- /* DEBUGF("lcd_drawline() called for horizontal line - optimisation.\n"); */
- lcd_hline(x1, x2, y1);
- return;
- }
- xinc2 = 1;
- yinc2 = 1;
-
- if (deltax >= deltay)
- {
- numpixels = deltax;
- d = 2 * deltay - deltax;
- dinc1 = deltay * 2;
- dinc2 = (deltay - deltax) * 2;
- xinc1 = 1;
- yinc1 = 0;
- }
- else
- {
- numpixels = deltay;
- d = 2 * deltax - deltay;
- dinc1 = deltax * 2;
- dinc2 = (deltax - deltay) * 2;
- xinc1 = 0;
- yinc1 = 1;
- }
- numpixels++; /* include endpoints */
-
- if (x1 > x2)
- {
- xinc1 = -xinc1;
- xinc2 = -xinc2;
- }
-
- if (y1 > y2)
- {
- yinc1 = -yinc1;
- yinc2 = -yinc2;
- }
-
- x = x1;
- y = y1;
-
- x_vp = lcd_current_viewport->x;
- y_vp = lcd_current_viewport->y;
- w_vp = lcd_current_viewport->width;
- h_vp = lcd_current_viewport->height;
-
- for (i = 0; i < numpixels; i++)
- {
- if (x >= 0 && y >= 0 && x < w_vp && y < h_vp)
- pfunc(x + x_vp, y + y_vp);
-
- if (d < 0)
- {
- d += dinc1;
- x += xinc1;
- y += yinc1;
- }
- else
- {
- d += dinc2;
- x += xinc2;
- y += yinc2;
- }
- }
-}
-
/* Draw a horizontal line (optimised) */
void lcd_hline(int x1, int x2, int y)
{
@@ -567,21 +471,6 @@ void lcd_vline(int x, int y1, int y2)
bfunc(dst, mask, 0xFFu);
}
-/* Draw a rectangular box */
-void lcd_drawrect(int x, int y, int width, int height)
-{
- if ((width <= 0) || (height <= 0))
- return;
-
- int x2 = x + width - 1;
- int y2 = y + height - 1;
-
- lcd_vline(x, y, y2);
- lcd_vline(x2, y, y2);
- lcd_hline(x, x2, y);
- lcd_hline(x, x2, y2);
-}
-
/* Fill a rectangular area */
void lcd_fillrect(int x, int y, int width, int height)
{
diff --git a/firmware/drivers/lcd-2bit-vi.c b/firmware/drivers/lcd-2bit-vi.c
index b19fdba266..976af8f62d 100644
--- a/firmware/drivers/lcd-2bit-vi.c
+++ b/firmware/drivers/lcd-2bit-vi.c
@@ -452,102 +452,6 @@ void LCDFN(clear_viewport)(void)
CURRENT_VP->flags &= ~(VP_FLAG_VP_SET_CLEAN);
}
-/* Set a single pixel */
-void LCDFN(drawpixel)(int x, int y)
-{
- if (LCDFN(clip_viewport_pixel)(&x, &y))
- LCDFN(pixelfuncs)[CURRENT_VP->drawmode](x, y);
-}
-
-/* Draw a line */
-void LCDFN(drawline)(int x1, int y1, int x2, int y2)
-{
- int numpixels;
- int i;
- int deltax, deltay;
- int d, dinc1, dinc2;
- int x, xinc1, xinc2;
- int y, yinc1, yinc2;
- int x_vp, y_vp, w_vp, h_vp;
- LCDFN(pixelfunc_type) *pfunc = LCDFN(pixelfuncs)[CURRENT_VP->drawmode];
-
- deltax = abs(x2 - x1);
- if (deltax == 0)
- {
- /* DEBUGF(LCDNAME "drawline() called for vertical line - optimisation.\n"); */
- LCDFN(vline)(x1, y1, y2);
- return;
- }
- deltay = abs(y2 - y1);
- if (deltay == 0)
- {
- /* DEBUGF(LCDNAME "drawline() called for horizontal line - optimisation.\n"); */
- LCDFN(hline)(x1, x2, y1);
- return;
- }
- xinc2 = 1;
- yinc2 = 1;
-
- if (deltax >= deltay)
- {
- numpixels = deltax;
- d = 2 * deltay - deltax;
- dinc1 = deltay * 2;
- dinc2 = (deltay - deltax) * 2;
- xinc1 = 1;
- yinc1 = 0;
- }
- else
- {
- numpixels = deltay;
- d = 2 * deltax - deltay;
- dinc1 = deltax * 2;
- dinc2 = (deltax - deltay) * 2;
- xinc1 = 0;
- yinc1 = 1;
- }
- numpixels++; /* include endpoints */
-
- if (x1 > x2)
- {
- xinc1 = -xinc1;
- xinc2 = -xinc2;
- }
-
- if (y1 > y2)
- {
- yinc1 = -yinc1;
- yinc2 = -yinc2;
- }
-
- x = x1;
- y = y1;
-
- x_vp = CURRENT_VP->x;
- y_vp = CURRENT_VP->y;
- w_vp = CURRENT_VP->width;
- h_vp = CURRENT_VP->height;
-
- for (i = 0; i < numpixels; i++)
- {
- if (x >= 0 && y >= 0 && x < w_vp && y < h_vp)
- pfunc(x + x_vp, y + y_vp);
-
- if (d < 0)
- {
- d += dinc1;
- x += xinc1;
- y += yinc1;
- }
- else
- {
- d += dinc2;
- x += xinc2;
- y += yinc2;
- }
- }
-}
-
/* Draw a horizontal line (optimised) */
void LCDFN(hline)(int x1, int x2, int y)
{
@@ -602,21 +506,6 @@ void LCDFN(vline)(int x, int y1, int y2)
bfunc(dst, mask, 0xFFFFu);
}
-/* Draw a rectangular box */
-void LCDFN(drawrect)(int x, int y, int width, int height)
-{
- if ((width <= 0) || (height <= 0))
- return;
-
- int x2 = x + width - 1;
- int y2 = y + height - 1;
-
- LCDFN(vline)(x, y, y2);
- LCDFN(vline)(x2, y, y2);
- LCDFN(hline)(x, x2, y);
- LCDFN(hline)(x, x2, y2);
-}
-
/* Fill a rectangular area */
void LCDFN(fillrect)(int x, int y, int width, int height)
{
diff --git a/firmware/drivers/lcd-bitmap-common.c b/firmware/drivers/lcd-bitmap-common.c
index c867b214b5..bd6efa167c 100644
--- a/firmware/drivers/lcd-bitmap-common.c
+++ b/firmware/drivers/lcd-bitmap-common.c
@@ -67,7 +67,8 @@ static bool LCDFN(clip_viewport_pixel)(int *x, int *y)
{
struct viewport *vp = LCDFN(current_viewport);
- if(*x >= vp->width || *y >= vp->height)
+ if (*x < 0 || *x >= vp->width ||
+ *y < 0 || *y >= vp->height)
return false;
*x += vp->x;
@@ -805,3 +806,128 @@ void LCDFN(nine_segment_bmp)(const struct bitmap* bm, int x, int y,
LCDFN(bmp_part)(bm, bm->width - corner_w, bm->width - corner_h,
width - corner_w, height - corner_h, corner_w, corner_h);
}
+
+void LCDFN(drawpixel)(int x, int y)
+{
+ struct viewport *vp = LCDFN(current_viewport);
+ if (LCDFN(clip_viewport_pixel(&x, &y)))
+ {
+#if LCDM(DEPTH) >= 8
+ LCDFN(fastpixelfunc_type) *pfunc = LCDFN(fastpixelfuncs)[vp->drawmode];
+ void *(*fbaddr)(int x, int y) = vp->buffer->get_address_fn;
+ pfunc(fbaddr(x, y));
+#else
+ LCDFN(pixelfunc_type) *pfunc = LCDFN(pixelfuncs)[vp->drawmode];
+ pfunc(x, y);
+#endif
+ }
+}
+
+void LCDFN(drawline)(int x1, int y1, int x2, int y2)
+{
+ struct viewport *vp = LCDFN(current_viewport);
+ int numpixels;
+ int i;
+ int deltax, deltay;
+ int d, dinc1, dinc2;
+ int x, xinc1, xinc2;
+ int y, yinc1, yinc2;
+
+ deltay = abs(y2 - y1);
+ if (deltay == 0)
+ {
+ lcd_hline(x1, x2, y1);
+ return;
+ }
+
+ deltax = abs(x2 - x1);
+ if (deltax == 0)
+ {
+ lcd_vline(x1, y1, y2);
+ return;
+ }
+
+ xinc2 = 1;
+ yinc2 = 1;
+
+ if (deltax >= deltay)
+ {
+ numpixels = deltax;
+ d = 2 * deltay - deltax;
+ dinc1 = deltay * 2;
+ dinc2 = (deltay - deltax) * 2;
+ xinc1 = 1;
+ yinc1 = 0;
+ }
+ else
+ {
+ numpixels = deltay;
+ d = 2 * deltax - deltay;
+ dinc1 = deltax * 2;
+ dinc2 = (deltax - deltay) * 2;
+ xinc1 = 0;
+ yinc1 = 1;
+ }
+ numpixels++; /* include endpoints */
+
+ if (x1 > x2)
+ {
+ xinc1 = -xinc1;
+ xinc2 = -xinc2;
+ }
+
+ if (y1 > y2)
+ {
+ yinc1 = -yinc1;
+ yinc2 = -yinc2;
+ }
+
+ x = x1;
+ y = y1;
+
+#if LCDM(DEPTH) >= 8
+ LCDFN(fastpixelfunc_type) *pfunc = LCDFN(fastpixelfuncs)[vp->drawmode];
+ void *(*fbaddr)(int x, int y) = vp->buffer->get_address_fn;
+#else
+ LCDFN(pixelfunc_type) *pfunc = LCDFN(pixelfuncs)[vp->drawmode];
+#endif
+
+ for (i = 0; i < numpixels; i++)
+ {
+ if (x >= 0 && y >= 0 && x < vp->width && y < vp->height)
+ {
+#if LCDM(DEPTH) >= 8
+ pfunc(fbaddr(x + vp->x, y + vp->y));
+#else
+ pfunc(x + vp->x, y + vp->y);
+#endif
+ }
+
+ if (d < 0)
+ {
+ d += dinc1;
+ x += xinc1;
+ y += yinc1;
+ }
+ else
+ {
+ d += dinc2;
+ x += xinc2;
+ y += yinc2;
+ }
+ }
+}
+
+void LCDFN(drawrect)(int x, int y, int width, int height)
+{
+ if ((width <= 0) || (height <= 0))
+ return;
+
+ int x2 = x + width - 1;
+ int y2 = y + height - 1;
+
+ LCDFN(vline)(x, y, y2);
+ LCDFN(vline)(x2, y, y2);
+ LCDFN(hline)(x, x2, y);
+ LCDFN(hline)(x, x2, y2);
+}
diff --git a/firmware/drivers/lcd-color-common.c b/firmware/drivers/lcd-color-common.c
index 8a9ef64cea..a1d2f47c22 100644
--- a/firmware/drivers/lcd-color-common.c
+++ b/firmware/drivers/lcd-color-common.c
@@ -40,7 +40,6 @@ static fb_data lcd_static_framebuffer[LCD_FBHEIGHT][LCD_FBWIDTH]
IRAM_LCDFRAMEBUFFER CACHEALIGN_AT_LEAST_ATTR(16);
static void *lcd_frameaddress_default(int x, int y);
-static bool lcd_clip_viewport_pixel(int *x, int *y);
static fb_data* lcd_backdrop = NULL;
static long lcd_backdrop_offset IDATA_ATTR = 0;
@@ -194,119 +193,6 @@ fb_data* lcd_get_backdrop(void)
return lcd_backdrop;
}
-/* Set a single pixel */
-void lcd_drawpixel(int x, int y)
-{
- if (lcd_clip_viewport_pixel(&x, &y))
- lcd_fastpixelfuncs[lcd_current_viewport->drawmode](FBADDR(x, y));
-}
-
-/* Draw a line */
-void lcd_drawline(int x1, int y1, int x2, int y2)
-{
- int numpixels;
- int i;
- int deltax, deltay;
- int d, dinc1, dinc2;
- int x, xinc1, xinc2;
- int y, yinc1, yinc2;
- int x_vp, y_vp, w_vp, h_vp;
- lcd_fastpixelfunc_type *pfunc = lcd_fastpixelfuncs[lcd_current_viewport->drawmode];
-
- deltay = abs(y2 - y1);
- if (deltay == 0)
- {
- /* DEBUGF("lcd_drawline() called for horizontal line - optimisation.\n"); */
- lcd_hline(x1, x2, y1);
- return;
- }
- deltax = abs(x2 - x1);
- if (deltax == 0)
- {
- /* DEBUGF("lcd_drawline() called for vertical line - optimisation.\n"); */
- lcd_vline(x1, y1, y2);
- return;
- }
- xinc2 = 1;
- yinc2 = 1;
-
- if (deltax >= deltay)
- {
- numpixels = deltax;
- d = 2 * deltay - deltax;
- dinc1 = deltay * 2;
- dinc2 = (deltay - deltax) * 2;
- xinc1 = 1;
- yinc1 = 0;
- }
- else
- {
- numpixels = deltay;
- d = 2 * deltax - deltay;
- dinc1 = deltax * 2;
- dinc2 = (deltax - deltay) * 2;
- xinc1 = 0;
- yinc1 = 1;
- }
- numpixels++; /* include endpoints */
-
- if (x1 > x2)
- {
- xinc1 = -xinc1;
- xinc2 = -xinc2;
- }
-
- if (y1 > y2)
- {
- yinc1 = -yinc1;
- yinc2 = -yinc2;
- }
-
- x = x1;
- y = y1;
-
- void *(*fbaddr)(int x, int y) = FB_CURRENTVP_BUFFER->get_address_fn;
- x_vp = lcd_current_viewport->x;
- y_vp = lcd_current_viewport->y;
- w_vp = lcd_current_viewport->width;
- h_vp = lcd_current_viewport->height;
-
- for (i = 0; i < numpixels; i++)
- {
- if (x >= 0 && y >= 0 && x < w_vp && y < h_vp)
- pfunc(fbaddr(x + x_vp, y + y_vp));
-
- if (d < 0)
- {
- d += dinc1;
- x += xinc1;
- y += yinc1;
- }
- else
- {
- d += dinc2;
- x += xinc2;
- y += yinc2;
- }
- }
-}
-
-/* Draw a rectangular box */
-void lcd_drawrect(int x, int y, int width, int height)
-{
- if ((width <= 0) || (height <= 0))
- return;
-
- int x2 = x + width - 1;
- int y2 = y + height - 1;
-
- lcd_vline(x, y, y2);
- lcd_vline(x2, y, y2);
- lcd_hline(x, x2, y);
- lcd_hline(x, x2, y2);
-}
-
-
/* Draw a full native bitmap */
void lcd_bitmap(const fb_data *src, int x, int y, int width, int height)
{