@@ -311,16 +311,19 @@ static int copy_to_texture(void *lcd_base, const struct vid_bbox *damage)
return 0;
}
-static void draw_grid(void)
+static void draw_grid(int size)
{
int x, y;
+ if (!size)
+ size = 0x20;
+
SDL_SetRenderDrawColor(sdl.renderer, 192, 192, 192, SDL_ALPHA_OPAQUE);
- for (x = 0; x < sdl.vis_width; x += 10)
+ for (x = 0; x < sdl.vis_width; x += size)
SDL_RenderDrawLine(sdl.renderer, x, 0, x, sdl.vis_height - 1);
- for (y = 0; y < sdl.vis_height; y += 10)
+ for (y = 0; y < sdl.vis_height; y += size)
SDL_RenderDrawLine(sdl.renderer, 0, y, sdl.vis_width - 1, y);
}
@@ -345,7 +348,7 @@ int sandbox_sdl_sync(void *lcd_base, const struct vid_bbox *damage,
}
if (opts && opts->draw_grid)
- draw_grid();
+ draw_grid(opts->grid_size);
/*
* On some machines this does not appear. Draw an empty rectangle which
@@ -13,9 +13,11 @@
* struct sandbox_sdl_sync_opts - Options for sandbox_sdl_sync()
*
* @draw_grid: Draw a grid overlay on the display
+ * @grid_size: Grid size in pixels (0 for default of 0x20)
*/
struct sandbox_sdl_sync_opts {
bool draw_grid;
+ int grid_size;
};
#endif
@@ -180,6 +180,7 @@ struct sandbox_state {
bool quiet_vidconsole; /* Don't use vidconsole for stdout */
bool disable_mcheck; /* Disable mcheck heap protection */
bool show_grid; /* Show grid overlay on video */
+ int grid_size; /* Grid size in pixels (0 for default) */
int video_test; /* ms to wait before next assert */
const char *video_frames_dir; /* Directory to write video frames */
int video_frame_count; /* Number of frames written */
@@ -106,6 +106,8 @@ static int do_sb_grid(struct cmd_tbl *cmdtp, int flag, int argc,
return CMD_RET_USAGE;
state->show_grid = hextoul(argv[1], NULL);
+ if (argc >= 3)
+ state->grid_size = hextoul(argv[2], NULL);
return 0;
}
@@ -160,7 +162,7 @@ static int do_sb_devoff(struct cmd_tbl *cmdtp, int flag, int argc,
U_BOOT_LONGHELP(sb,
"devoff <node> - Disable device from device tree node\n"
"sb devon <node> - Enable device from device tree node\n"
- "sb grid <0|1> - Enable/disable grid overlay on video\n"
+ "sb grid <0|1> [<size>] - Enable/disable grid overlay on video\n"
"sb handoff - Show handoff data received from SPL\n"
"sb map - Show mapped memory\n"
"sb state - Show sandbox state");
@@ -168,7 +170,7 @@ U_BOOT_LONGHELP(sb,
U_BOOT_CMD_WITH_SUBCMDS(sb, "Sandbox status commands", sb_help_text,
U_BOOT_SUBCMD_MKENT(devoff, 2, 1, do_sb_devoff),
U_BOOT_SUBCMD_MKENT(devon, 2, 1, do_sb_devon),
- U_BOOT_SUBCMD_MKENT(grid, 2, 1, do_sb_grid),
+ U_BOOT_SUBCMD_MKENT(grid, 3, 1, do_sb_grid),
U_BOOT_SUBCMD_MKENT(handoff, 1, 1, do_sb_handoff),
U_BOOT_SUBCMD_MKENT(map, 1, 1, do_sb_map),
U_BOOT_SUBCMD_MKENT(state, 1, 1, do_sb_state));
@@ -797,6 +797,10 @@ For example, to watch an expo test render with a visible display::
./u-boot -T -l -V 500 --video_frames /tmp/good -c "ut bootstd expo_render_image"
+The :doc:`../usage/cmd/sb` ``grid`` subcommand can be used to overlay a grid on
+the display, to help with checking alignment of objects. The grid size defaults
+to 0x20 pixels but can be specified as a parameter.
+
This will write each asserted expo frame to ``/tmp/good/frame0.bmp``,
``/tmp/good/frame1.bmp``, etc.
@@ -13,7 +13,7 @@ Synopsis
sb devoff <node>
sb devon <node>
- sb grid <0|1>
+ sb grid <0|1> [<size>]
sb handoff
sb map
sb state
@@ -45,8 +45,9 @@ sb grid
~~~~~~~
This enables or disables a grid overlay on the video display. When enabled,
-a 10-pixel grid is drawn over the display, which is useful for debugging UI
-layout and alignment. Use ``sb grid 1`` to enable and ``sb grid 0`` to disable.
+a grid is drawn over the display, which is useful for debugging UI layout and
+alignment. Use ``sb grid 1`` to enable and ``sb grid 0`` to disable. An
+optional second parameter specifies the grid size in pixels (default 0x20).
sb handoff
~~~~~~~~~~
@@ -149,6 +149,7 @@ static int sandbox_sdl_video_sync(struct udevice *vid, uint flags)
sizeof(plat->last_sync_damage));
opts.draw_grid = state->show_grid;
+ opts.grid_size = state->grid_size;
return sandbox_sdl_sync(uc_priv->fb, damage, &opts);
}
@@ -130,6 +130,7 @@ static int dm_test_sb_grid(struct unit_test_state *uts)
/* Ensure grid is initially off */
state->show_grid = false;
+ state->grid_size = 0;
/* Enable grid */
ut_assertok(run_command("sb grid 1", 0));
@@ -141,6 +142,16 @@ static int dm_test_sb_grid(struct unit_test_state *uts)
ut_assert_console_end();
ut_asserteq(false, state->show_grid);
+ /* Enable grid with custom size (0x14 = 20 decimal) */
+ ut_assertok(run_command("sb grid 1 14", 0));
+ ut_assert_console_end();
+ ut_asserteq(true, state->show_grid);
+ ut_asserteq(0x14, state->grid_size);
+
+ /* Clean up */
+ state->show_grid = false;
+ state->grid_size = 0;
+
return 0;
}
DM_TEST(dm_test_sb_grid, UTF_CONSOLE);