@@ -681,7 +681,7 @@ static int scene_obj_render(struct scene_obj *obj, bool text_mode)
struct scene_obj_box *box = (struct scene_obj_box *)obj;
video_draw_box(dev, obj->bbox.x0, obj->bbox.y0, obj->bbox.x1,
- obj->bbox.y1, box->width, vid_priv->colour_fg);
+ obj->bbox.y1, box->width, vid_priv->colour_fg, false);
break;
}
case SCENEOBJT_TEXTEDIT: {
@@ -218,7 +218,7 @@ int video_fill_part(struct udevice *dev, int xstart, int ystart, int xend,
}
int video_draw_box(struct udevice *dev, int x0, int y0, int x1, int y1,
- int width, u32 colour)
+ int width, u32 colour, bool fill)
{
struct video_priv *priv = dev_get_uclass_priv(dev);
int pbytes = VNBYTES(priv->bpix);
@@ -233,17 +233,24 @@ int video_draw_box(struct udevice *dev, int x0, int y0, int x1, int y1,
void *ptr = line;
int i;
- for (i = 0; i < width; i++)
- fill_pixel_and_goto_next(&ptr, colour, pbytes, pbytes);
- if (row < y0 + width || row >= y1 - width) {
- for (i = 0; i < pixels - width * 2; i++)
- fill_pixel_and_goto_next(&ptr, colour, pbytes,
- pbytes);
+ if (fill) {
+ /* fill the entire row */
+ for (i = 0; i < pixels; i++)
+ fill_pixel_and_goto_next(&ptr, colour, pbytes, pbytes);
} else {
- ptr += (pixels - width * 2) * pbytes;
+ /* draw outline only */
+ for (i = 0; i < width; i++)
+ fill_pixel_and_goto_next(&ptr, colour, pbytes, pbytes);
+ if (row < y0 + width || row >= y1 - width) {
+ for (i = 0; i < pixels - width * 2; i++)
+ fill_pixel_and_goto_next(&ptr, colour, pbytes,
+ pbytes);
+ } else {
+ ptr += (pixels - width * 2) * pbytes;
+ }
+ for (i = 0; i < width; i++)
+ fill_pixel_and_goto_next(&ptr, colour, pbytes, pbytes);
}
- for (i = 0; i < width; i++)
- fill_pixel_and_goto_next(&ptr, colour, pbytes, pbytes);
line += priv->line_length;
}
video_damage(dev, x0, y0, x1 - x0, y1 - y0);
@@ -277,10 +277,11 @@ int video_fill_part(struct udevice *dev, int xstart, int ystart, int xend,
* @y1: Y end position in pixels from the top
* @width: width in pixels
* @colour: Value to write
+ * @fill: true to fill the box, false to draw outline only
* Return: 0 if OK, -ENOSYS if the display depth is not supported
*/
int video_draw_box(struct udevice *dev, int x0, int y0, int x1, int y1,
- int width, u32 colour);
+ int width, u32 colour, bool fill);
/**
* video_sync() - Sync a device's frame buffer with its hardware
@@ -911,14 +911,23 @@ static int dm_test_video_box(struct unit_test_state *uts)
ut_assertok(video_get_nologo(uts, &dev));
priv = dev_get_uclass_priv(dev);
+
+ /* test outline boxes */
video_draw_box(dev, 100, 100, 200, 200, 3,
- video_index_to_colour(priv, VID_LIGHT_BLUE));
+ video_index_to_colour(priv, VID_LIGHT_BLUE), false);
video_draw_box(dev, 300, 100, 400, 200, 1,
- video_index_to_colour(priv, VID_MAGENTA));
+ video_index_to_colour(priv, VID_MAGENTA), false);
video_draw_box(dev, 500, 100, 600, 200, 20,
- video_index_to_colour(priv, VID_LIGHT_RED));
+ video_index_to_colour(priv, VID_LIGHT_RED), false);
ut_asserteq(133, video_compress_fb(uts, dev, false));
- ut_assertok(video_check_copy_fb(uts, dev));
+
+ /* test filled boxes */
+ video_draw_box(dev, 150, 250, 200, 300, 0,
+ video_index_to_colour(priv, VID_GREEN), true);
+ video_draw_box(dev, 350, 250, 400, 300, 0,
+ video_index_to_colour(priv, VID_YELLOW), true);
+
+ ut_asserteq(175, video_compress_fb(uts, dev, false));
return 0;
}