[Concept,17/22] expo: Add scene_render_obj() to render by object ID

Message ID 20251207201628.2882382-18-sjg@u-boot.org
State New
Headers
Series expo: Expand docs, dump and textlines in non-popup expos |

Commit Message

Simon Glass Dec. 7, 2025, 8:16 p.m. UTC
  From: Simon Glass <simon.glass@canonical.com>

Add a function to render a single object by its ID. This provides a
convenient way to render individual objects without needing to look up
the object pointer first.

Assume that text mode is not used.

Co-developed-by: Claude <claude@anthropic.com>
Signed-off-by: Simon Glass <simon.glass@canonical.com>
---

 boot/scene.c          | 18 ++++++++++++++++++
 boot/scene_internal.h |  9 +++++++++
 2 files changed, 27 insertions(+)
  

Patch

diff --git a/boot/scene.c b/boot/scene.c
index 1bc4c9c25ac..1bcc3c39e33 100644
--- a/boot/scene.c
+++ b/boot/scene.c
@@ -903,6 +903,24 @@  int scene_arrange(struct scene *scn)
 	return 0;
 }
 
+int scene_render_obj(struct scene *scn, uint id)
+{
+	struct scene_obj *obj;
+	int ret;
+
+	obj = scene_obj_find(scn, id, SCENEOBJT_NONE);
+	if (!obj)
+		return log_msg_ret("obj", -ENOENT);
+
+	if (!(obj->flags & SCENEOF_HIDE)) {
+		ret = scene_obj_render(obj, false);
+		if (ret && ret != -ENOTSUPP)
+			return log_msg_ret("ren", ret);
+	}
+
+	return 0;
+}
+
 int scene_render_deps(struct scene *scn, uint id)
 {
 	struct scene_obj *obj;
diff --git a/boot/scene_internal.h b/boot/scene_internal.h
index 2bfbb5dcf50..5cc81f031a0 100644
--- a/boot/scene_internal.h
+++ b/boot/scene_internal.h
@@ -314,6 +314,15 @@  bool scene_textline_within(const struct scene *scn,
  */
 int scene_send_click(struct scene *scn, int x, int y, struct expo_action *event);
 
+/**
+ * scene_render_obj() - Render an object
+ *
+ * @scn: Scene containing the object
+ * @id: Object ID to render
+ * Returns: 0 if OK, -ENOENT if object not found, -ve on other error
+ */
+int scene_render_obj(struct scene *scn, uint id);
+
 /**
  * scene_render_deps() - Render an object and its dependencies
  *