* [PATCH 1/3] 2d-primitives: fix missing pixel in gu_draw_line()
@ 2017-10-12 17:52 Nikita Yushchenko
2017-10-12 17:52 ` [PATCH 2/3] fbtest: add solid pattern Nikita Yushchenko
` (2 more replies)
0 siblings, 3 replies; 6+ messages in thread
From: Nikita Yushchenko @ 2017-10-12 17:52 UTC (permalink / raw)
To: Sascha Hauer; +Cc: Andrey Smirnov, barebox, Chris Healy, Nikita Yushchenko
When drawing line from (x1, y1) to (x2, y2), pixel at (x2, y2) should
be included.
Signed-off-by: Nikita Yushchenko <nikita.yoush@cogentembedded.com>
---
lib/gui/2d-primitives.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/lib/gui/2d-primitives.c b/lib/gui/2d-primitives.c
index 0f29b32ba..89acc092d 100644
--- a/lib/gui/2d-primitives.c
+++ b/lib/gui/2d-primitives.c
@@ -61,7 +61,7 @@ static void draw_simple_line(struct screen *sc,
swap(y1, y2);
}
- for (x = x1; x < x2 - 1; x++) {
+ for (x = x1; x <= x2; x++) {
if (!dash ||
(++pixel % (2 * dash)) < dash)
illuminate(sc->info,
@@ -137,7 +137,7 @@ void gu_draw_line(struct screen *sc,
j = y1;
eps = dy - dx;
- for (i = x1; i <= x2 - 1; i++) {
+ for (i = x1; i <= x2; i++) {
if (!dash ||
(++pixel % (2 * dash)) > dash) {
illuminate(sc->info,
--
2.11.0
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH 2/3] fbtest: add solid pattern
2017-10-12 17:52 [PATCH 1/3] 2d-primitives: fix missing pixel in gu_draw_line() Nikita Yushchenko
@ 2017-10-12 17:52 ` Nikita Yushchenko
2017-10-12 17:52 ` [PATCH 3/3] fbtest: add gradients pattern Nikita Yushchenko
2017-10-12 18:30 ` [PATCH 1/3] 2d-primitives: fix missing pixel in gu_draw_line() Chris Healy
2 siblings, 0 replies; 6+ messages in thread
From: Nikita Yushchenko @ 2017-10-12 17:52 UTC (permalink / raw)
To: Sascha Hauer; +Cc: Andrey Smirnov, barebox, Chris Healy, Nikita Yushchenko
This just fills entire screen with single color, as passed in -c
argument in RRGGBB format.
Suggested-by: Chris Healy <cphealy@gmail.com>
Signed-off-by: Nikita Yushchenko <nikita.yoush@cogentembedded.com>
---
commands/fbtest.c | 14 ++++++++++++--
1 file changed, 12 insertions(+), 2 deletions(-)
diff --git a/commands/fbtest.c b/commands/fbtest.c
index ca6ec2199..9981c1319 100644
--- a/commands/fbtest.c
+++ b/commands/fbtest.c
@@ -9,6 +9,15 @@
#include <linux/gcd.h>
#include <int_sqrt.h>
+static void fbtest_pattern_solid(struct screen *sc, u32 color)
+{
+ const u8 r = (color >> 16) & 0xff;
+ const u8 g = (color >> 8) & 0xff;
+ const u8 b = (color >> 0) & 0xff;
+
+ gu_fill_rectangle(sc, 0, 0, -1, -1, r, g, b, 0xff);
+}
+
static void fbtest_pattern_bars(struct screen *sc, u32 unused)
{
int i;
@@ -122,6 +131,7 @@ static int do_fbtest(int argc, char *argv[])
const char *name;
void (*func) (struct screen *sc, u32 color);
} patterns[] = {
+ { "solid", fbtest_pattern_solid },
{ "geometry", fbtest_pattern_geometry },
{ "bars", fbtest_pattern_bars }
};
@@ -191,8 +201,8 @@ BAREBOX_CMD_HELP_TEXT("This command displays a test pattern on a screen")
BAREBOX_CMD_HELP_TEXT("")
BAREBOX_CMD_HELP_TEXT("Options:")
BAREBOX_CMD_HELP_OPT ("-d <fbdev>\t", "framebuffer device (default /dev/fb0)")
-BAREBOX_CMD_HELP_OPT ("-c color\t", "color")
-BAREBOX_CMD_HELP_OPT ("-p pattern\t", "pattern name (geometry, bars)")
+BAREBOX_CMD_HELP_OPT ("-c color\t", "color, in hex RRGGBB format")
+BAREBOX_CMD_HELP_OPT ("-p pattern\t", "pattern name (solid, geometry, bars)")
BAREBOX_CMD_HELP_END
BAREBOX_CMD_START(fbtest)
--
2.11.0
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH 3/3] fbtest: add gradients pattern
2017-10-12 17:52 [PATCH 1/3] 2d-primitives: fix missing pixel in gu_draw_line() Nikita Yushchenko
2017-10-12 17:52 ` [PATCH 2/3] fbtest: add solid pattern Nikita Yushchenko
@ 2017-10-12 17:52 ` Nikita Yushchenko
2017-10-13 13:20 ` Sam Ravnborg
2017-10-12 18:30 ` [PATCH 1/3] 2d-primitives: fix missing pixel in gu_draw_line() Chris Healy
2 siblings, 1 reply; 6+ messages in thread
From: Nikita Yushchenko @ 2017-10-12 17:52 UTC (permalink / raw)
To: Sascha Hauer; +Cc: Andrey Smirnov, barebox, Chris Healy, Nikita Yushchenko
This pattern draws red, green, blue, and white color gradients, together with
3 anchor rectangles in corners.
To be used with automated screen testing via computer vision methods.
Suggested-by: Chris Healy <cphealy@gmail.com>
Signed-off-by: Nikita Yushchenko <nikita.yoush@cogentembedded.com>
---
commands/fbtest.c | 110 +++++++++++++++++++++++++++++++++++++++++++++++++++++-
1 file changed, 108 insertions(+), 2 deletions(-)
diff --git a/commands/fbtest.c b/commands/fbtest.c
index 9981c1319..8e6a5457f 100644
--- a/commands/fbtest.c
+++ b/commands/fbtest.c
@@ -117,6 +117,111 @@ static void fbtest_pattern_geometry(struct screen *sc, u32 color)
}
}
+static void draw_line_r(struct screen *sc, bool rotate_90_ccw,
+ int x1, int y1, int x2, int y2,
+ uint8_t r, uint8_t g, uint8_t b)
+{
+ if (rotate_90_ccw)
+ gu_draw_line(sc,
+ y1, sc->info->yres - x1,
+ y2, sc->info->yres - x2,
+ r, g, b, 0xff, 0);
+ else
+ gu_draw_line(sc, x1, y1, x2, y2, r, g, b, 0xff, 0);
+}
+
+static void solid_rect_r(struct screen *sc, bool rotate_90_ccw,
+ int x1, int y1, int x2, int y2,
+ uint8_t r, uint8_t g, uint8_t b)
+{
+ if (rotate_90_ccw)
+ gu_fill_rectangle(sc,
+ y1, sc->info->yres - x1,
+ y2, sc->info->yres - x2,
+ r, g, b, 0xff);
+ else
+ gu_fill_rectangle(sc, x1, y1, x2, y2, r, g, b, 0xff);
+}
+
+static void grad_rect_r(struct screen *sc, bool rotate_90_ccw,
+ int x1, int y1, int x2, int y2,
+ uint8_t r, uint8_t g, uint8_t b)
+{
+ int x;
+
+ for (x = x1; x <= x2; x++)
+ draw_line_r(sc, rotate_90_ccw, x, y1, x, y2,
+ r * (x - x1 + 1) / (x2 - x1 + 1),
+ g * (x - x1 + 1) / (x2 - x1 + 1),
+ b * (x - x1 + 1) / (x2 - x1 + 1));
+}
+
+static void anchor_rect_r(struct screen *sc, bool rotate_90_ccw,
+ int x1, int y1, int x2, int y2)
+{
+ int dx = (x2 - x1 + 1) / 6, dy = (y2 - y1 + 1) / 6;
+
+ solid_rect_r(sc, rotate_90_ccw,
+ x1, y1, x2, y2,
+ 0xff, 0xff, 0xff);
+
+ solid_rect_r(sc, rotate_90_ccw,
+ x1 + dx, y1 + dy, x2 - dx, y2 - dy,
+ 0, 0, 0);
+
+ solid_rect_r(sc, rotate_90_ccw,
+ x1 + 2 * dx, y1 + 2 * dy, x2 - 2 * dx, y2 - 2 * dy,
+ 0xff, 0xff, 0xff);
+}
+
+
+static void fbtest_pattern_gradient(struct screen *sc, u32 unused)
+{
+ bool rotate_90_ccw;
+ int w, h, border;
+
+ if (sc->info->xres > sc->info->yres) {
+ w = sc->info->xres;
+ h = sc->info->yres;
+ rotate_90_ccw = false;
+ } else {
+ w = sc->info->yres;
+ h = sc->info->xres;
+ rotate_90_ccw = true;
+ }
+
+ solid_rect_r(sc, rotate_90_ccw, 0, 0, w - 1, h - 1, 0, 0, 0);
+
+ border = h / 5;
+
+ anchor_rect_r(sc, rotate_90_ccw,
+ border * 3 / 10, border * 3 / 10,
+ border * 7 / 10, border * 7 / 10);
+ anchor_rect_r(sc, rotate_90_ccw,
+ w - border * 7 / 10, border * 3 / 10,
+ w - border * 3 / 10, border * 7 / 10);
+ anchor_rect_r(sc, rotate_90_ccw,
+ w - border * 7 / 10, h - border * 7 / 10,
+ w - border * 3 / 10, h - border * 3 / 10);
+
+ grad_rect_r(sc, rotate_90_ccw,
+ border, border,
+ w - border, border + (h - 2 * border) / 4 - 1,
+ 0xff, 0, 0);
+ grad_rect_r(sc, rotate_90_ccw,
+ border, border + (h - 2 * border) / 4,
+ w - border, border + (h - 2 * border) / 2 - 1,
+ 0, 0xff, 0);
+ grad_rect_r(sc, rotate_90_ccw,
+ border, border + (h - 2 * border) / 2,
+ w - border, border + (h - 2 * border) * 3 / 4 - 1,
+ 0, 0, 0xff);
+ grad_rect_r(sc, rotate_90_ccw,
+ border, border + (h - 2 * border) * 3 / 4,
+ w - border, h - border,
+ 0xff, 0xff, 0xff);
+}
+
static int do_fbtest(int argc, char *argv[])
{
struct screen *sc;
@@ -133,7 +238,8 @@ static int do_fbtest(int argc, char *argv[])
} patterns[] = {
{ "solid", fbtest_pattern_solid },
{ "geometry", fbtest_pattern_geometry },
- { "bars", fbtest_pattern_bars }
+ { "bars", fbtest_pattern_bars },
+ { "gradient", fbtest_pattern_gradient },
};
while((opt = getopt(argc, argv, "d:p:c:")) > 0) {
@@ -202,7 +308,7 @@ BAREBOX_CMD_HELP_TEXT("")
BAREBOX_CMD_HELP_TEXT("Options:")
BAREBOX_CMD_HELP_OPT ("-d <fbdev>\t", "framebuffer device (default /dev/fb0)")
BAREBOX_CMD_HELP_OPT ("-c color\t", "color, in hex RRGGBB format")
-BAREBOX_CMD_HELP_OPT ("-p pattern\t", "pattern name (solid, geometry, bars)")
+BAREBOX_CMD_HELP_OPT ("-p pattern\t", "pattern name (solid, geometry, bars, gradient)")
BAREBOX_CMD_HELP_END
BAREBOX_CMD_START(fbtest)
--
2.11.0
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH 1/3] 2d-primitives: fix missing pixel in gu_draw_line()
2017-10-12 17:52 [PATCH 1/3] 2d-primitives: fix missing pixel in gu_draw_line() Nikita Yushchenko
2017-10-12 17:52 ` [PATCH 2/3] fbtest: add solid pattern Nikita Yushchenko
2017-10-12 17:52 ` [PATCH 3/3] fbtest: add gradients pattern Nikita Yushchenko
@ 2017-10-12 18:30 ` Chris Healy
2 siblings, 0 replies; 6+ messages in thread
From: Chris Healy @ 2017-10-12 18:30 UTC (permalink / raw)
To: Nikita Yushchenko; +Cc: Andrey Smirnov, barebox
Full series is:
Tested-by: Chris Healy <cphealy@gmail.com>
Was tested on sandbox with various resolutions between 320x200 up to 1280x768.
On Thu, Oct 12, 2017 at 10:52 AM, Nikita Yushchenko
<nikita.yoush@cogentembedded.com> wrote:
> When drawing line from (x1, y1) to (x2, y2), pixel at (x2, y2) should
> be included.
>
> Signed-off-by: Nikita Yushchenko <nikita.yoush@cogentembedded.com>
> ---
> lib/gui/2d-primitives.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/lib/gui/2d-primitives.c b/lib/gui/2d-primitives.c
> index 0f29b32ba..89acc092d 100644
> --- a/lib/gui/2d-primitives.c
> +++ b/lib/gui/2d-primitives.c
> @@ -61,7 +61,7 @@ static void draw_simple_line(struct screen *sc,
> swap(y1, y2);
> }
>
> - for (x = x1; x < x2 - 1; x++) {
> + for (x = x1; x <= x2; x++) {
> if (!dash ||
> (++pixel % (2 * dash)) < dash)
> illuminate(sc->info,
> @@ -137,7 +137,7 @@ void gu_draw_line(struct screen *sc,
> j = y1;
> eps = dy - dx;
>
> - for (i = x1; i <= x2 - 1; i++) {
> + for (i = x1; i <= x2; i++) {
> if (!dash ||
> (++pixel % (2 * dash)) > dash) {
> illuminate(sc->info,
> --
> 2.11.0
>
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH 3/3] fbtest: add gradients pattern
2017-10-12 17:52 ` [PATCH 3/3] fbtest: add gradients pattern Nikita Yushchenko
@ 2017-10-13 13:20 ` Sam Ravnborg
2017-10-16 7:20 ` Sascha Hauer
0 siblings, 1 reply; 6+ messages in thread
From: Sam Ravnborg @ 2017-10-13 13:20 UTC (permalink / raw)
To: Nikita Yushchenko; +Cc: Andrey Smirnov, barebox, Chris Healy
Hi Nikita
Thanks for this, I have missed further fbtest options in the past.
Some nitpicks, that you may ignore.
Sam
On Thu, Oct 12, 2017 at 08:52:28PM +0300, Nikita Yushchenko wrote:
> This pattern draws red, green, blue, and white color gradients, together with
> 3 anchor rectangles in corners.
>
> To be used with automated screen testing via computer vision methods.
>
> Suggested-by: Chris Healy <cphealy@gmail.com>
> Signed-off-by: Nikita Yushchenko <nikita.yoush@cogentembedded.com>
> ---
> commands/fbtest.c | 110 +++++++++++++++++++++++++++++++++++++++++++++++++++++-
> 1 file changed, 108 insertions(+), 2 deletions(-)
>
> diff --git a/commands/fbtest.c b/commands/fbtest.c
> index 9981c1319..8e6a5457f 100644
> --- a/commands/fbtest.c
> +++ b/commands/fbtest.c
> @@ -117,6 +117,111 @@ static void fbtest_pattern_geometry(struct screen *sc, u32 color)
> }
> }
>
> +static void draw_line_r(struct screen *sc, bool rotate_90_ccw,
> + int x1, int y1, int x2, int y2,
> + uint8_t r, uint8_t g, uint8_t b)
> +{
> + if (rotate_90_ccw)
> + gu_draw_line(sc,
> + y1, sc->info->yres - x1,
> + y2, sc->info->yres - x2,
> + r, g, b, 0xff, 0);
> + else
> + gu_draw_line(sc, x1, y1, x2, y2, r, g, b, 0xff, 0);
> +}
> +
> +static void solid_rect_r(struct screen *sc, bool rotate_90_ccw,
> + int x1, int y1, int x2, int y2,
> + uint8_t r, uint8_t g, uint8_t b)
> +{
> + if (rotate_90_ccw)
> + gu_fill_rectangle(sc,
> + y1, sc->info->yres - x1,
> + y2, sc->info->yres - x2,
> + r, g, b, 0xff);
> + else
> + gu_fill_rectangle(sc, x1, y1, x2, y2, r, g, b, 0xff);
> +}
> +
> +static void grad_rect_r(struct screen *sc, bool rotate_90_ccw,
> + int x1, int y1, int x2, int y2,
> + uint8_t r, uint8_t g, uint8_t b)
> +{
> + int x;
> +
> + for (x = x1; x <= x2; x++)
> + draw_line_r(sc, rotate_90_ccw, x, y1, x, y2,
> + r * (x - x1 + 1) / (x2 - x1 + 1),
> + g * (x - x1 + 1) / (x2 - x1 + 1),
> + b * (x - x1 + 1) / (x2 - x1 + 1));
In the other xxx_xxx_sc(sc, ..) you have the following arguments on a new line.
But in this you have second argument on the same line.
It looks in-consistent.
Something like:
draw_line_r(sc,
rotate_90_ccw, x, y1, x, y2,
r * (x - x1 + 1) / (x2 - x1 + 1),
....
> +}
> +
> +static void anchor_rect_r(struct screen *sc, bool rotate_90_ccw,
> + int x1, int y1, int x2, int y2)
Following arguments should be aligned after first "(" like this:
static void anchor_rect_r(struct screen *sc, bool rotate_90_ccw,
int x1, int y1, int x2, int y2)
At least this is how the kernel does things and I recall barebox is the same
Sam
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH 3/3] fbtest: add gradients pattern
2017-10-13 13:20 ` Sam Ravnborg
@ 2017-10-16 7:20 ` Sascha Hauer
0 siblings, 0 replies; 6+ messages in thread
From: Sascha Hauer @ 2017-10-16 7:20 UTC (permalink / raw)
To: Sam Ravnborg; +Cc: Nikita Yushchenko, Andrey Smirnov, Chris Healy, barebox
On Fri, Oct 13, 2017 at 03:20:02PM +0200, Sam Ravnborg wrote:
> Hi Nikita
>
> Thanks for this, I have missed further fbtest options in the past.
> Some nitpicks, that you may ignore.
>
> Sam
>
> On Thu, Oct 12, 2017 at 08:52:28PM +0300, Nikita Yushchenko wrote:
> > This pattern draws red, green, blue, and white color gradients, together with
> > 3 anchor rectangles in corners.
> >
> > To be used with automated screen testing via computer vision methods.
> >
> > Suggested-by: Chris Healy <cphealy@gmail.com>
> > Signed-off-by: Nikita Yushchenko <nikita.yoush@cogentembedded.com>
> > ---
> > commands/fbtest.c | 110 +++++++++++++++++++++++++++++++++++++++++++++++++++++-
> > 1 file changed, 108 insertions(+), 2 deletions(-)
> >
> > diff --git a/commands/fbtest.c b/commands/fbtest.c
> > index 9981c1319..8e6a5457f 100644
> > --- a/commands/fbtest.c
> > +++ b/commands/fbtest.c
> > @@ -117,6 +117,111 @@ static void fbtest_pattern_geometry(struct screen *sc, u32 color)
> > }
> > }
> >
> > +static void draw_line_r(struct screen *sc, bool rotate_90_ccw,
> > + int x1, int y1, int x2, int y2,
> > + uint8_t r, uint8_t g, uint8_t b)
> > +{
> > + if (rotate_90_ccw)
> > + gu_draw_line(sc,
> > + y1, sc->info->yres - x1,
> > + y2, sc->info->yres - x2,
> > + r, g, b, 0xff, 0);
> > + else
> > + gu_draw_line(sc, x1, y1, x2, y2, r, g, b, 0xff, 0);
> > +}
> > +
> > +static void solid_rect_r(struct screen *sc, bool rotate_90_ccw,
> > + int x1, int y1, int x2, int y2,
> > + uint8_t r, uint8_t g, uint8_t b)
> > +{
> > + if (rotate_90_ccw)
> > + gu_fill_rectangle(sc,
> > + y1, sc->info->yres - x1,
> > + y2, sc->info->yres - x2,
> > + r, g, b, 0xff);
> > + else
> > + gu_fill_rectangle(sc, x1, y1, x2, y2, r, g, b, 0xff);
> > +}
> > +
> > +static void grad_rect_r(struct screen *sc, bool rotate_90_ccw,
> > + int x1, int y1, int x2, int y2,
> > + uint8_t r, uint8_t g, uint8_t b)
> > +{
> > + int x;
> > +
> > + for (x = x1; x <= x2; x++)
> > + draw_line_r(sc, rotate_90_ccw, x, y1, x, y2,
> > + r * (x - x1 + 1) / (x2 - x1 + 1),
> > + g * (x - x1 + 1) / (x2 - x1 + 1),
> > + b * (x - x1 + 1) / (x2 - x1 + 1));
> In the other xxx_xxx_sc(sc, ..) you have the following arguments on a new line.
> But in this you have second argument on the same line.
> It looks in-consistent.
>
> Something like:
> draw_line_r(sc,
> rotate_90_ccw, x, y1, x, y2,
> r * (x - x1 + 1) / (x2 - x1 + 1),
> ....
>
I think the function arguments are aligned quite nice in this patch and
what you see is because Nikita tried to align x/y or r/g/b arguments in
separate lines. I applied it as-is.
> > +}
> > +
> > +static void anchor_rect_r(struct screen *sc, bool rotate_90_ccw,
> > + int x1, int y1, int x2, int y2)
>
> Following arguments should be aligned after first "(" like this:
> static void anchor_rect_r(struct screen *sc, bool rotate_90_ccw,
> int x1, int y1, int x2, int y2)
>
> At least this is how the kernel does things and I recall barebox is the same
I fixed this up while applying.
Sascha
--
Pengutronix e.K. | |
Industrial Linux Solutions | http://www.pengutronix.de/ |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 |
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2017-10-16 7:20 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-10-12 17:52 [PATCH 1/3] 2d-primitives: fix missing pixel in gu_draw_line() Nikita Yushchenko
2017-10-12 17:52 ` [PATCH 2/3] fbtest: add solid pattern Nikita Yushchenko
2017-10-12 17:52 ` [PATCH 3/3] fbtest: add gradients pattern Nikita Yushchenko
2017-10-13 13:20 ` Sam Ravnborg
2017-10-16 7:20 ` Sascha Hauer
2017-10-12 18:30 ` [PATCH 1/3] 2d-primitives: fix missing pixel in gu_draw_line() Chris Healy
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox