diff options
| author | Simon Glass <[email protected]> | 2025-04-02 06:29:43 +1300 |
|---|---|---|
| committer | Tom Rini <[email protected]> | 2025-05-02 13:40:25 -0600 |
| commit | f94f1f4b8ce62855693b4b48356f7e8d229b3fa4 (patch) | |
| tree | f3a8400dd68f59b9a15fee6385d733a5747897df /drivers | |
| parent | cb32266d4aeca4a730c1f8b85c981a8793d768c4 (diff) | |
video: Add a function to draw a rectangle
Provide a way to draw an unfilled box of a certain width. This is useful
for grouping menu items together.
Add a comment showing how to see the copy-framebuffer, for testing.
Signed-off-by: Simon Glass <[email protected]>
Diffstat (limited to 'drivers')
| -rw-r--r-- | drivers/video/video-uclass.c | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/drivers/video/video-uclass.c b/drivers/video/video-uclass.c index 1c372bd58b7..53641fc28b6 100644 --- a/drivers/video/video-uclass.c +++ b/drivers/video/video-uclass.c @@ -26,6 +26,7 @@ #ifdef CONFIG_SANDBOX #include <asm/sdl.h> #endif +#include "vidconsole_internal.h" /* * Theory of operation: @@ -216,6 +217,40 @@ int video_fill_part(struct udevice *dev, int xstart, int ystart, int xend, return 0; } +int video_draw_box(struct udevice *dev, int x0, int y0, int x1, int y1, + int width, u32 colour) +{ + struct video_priv *priv = dev_get_uclass_priv(dev); + int pbytes = VNBYTES(priv->bpix); + void *start, *line; + int pixels = x1 - x0; + int row; + + start = priv->fb + y0 * priv->line_length; + start += x0 * pbytes; + line = start; + for (row = y0; row < y1; row++) { + 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); + } else { + ptr += (pixels - width * 2) * 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); + + return 0; +} + int video_reserve_from_bloblist(struct video_handoff *ho) { if (!ho->fb || ho->size == 0) @@ -481,6 +516,7 @@ int video_sync(struct udevice *vid, bool force) video_flush_dcache(vid, true); #if defined(CONFIG_VIDEO_SANDBOX_SDL) + /* to see the copy framebuffer, use priv->copy_fb */ sandbox_sdl_sync(priv->fb); #endif priv->last_sync = get_timer(0); |
