Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id AF938C7EE2A for ; Thu, 1 Jun 2023 16:28:46 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 1DF2E863AF; Thu, 1 Jun 2023 18:25:31 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="COnVAdjI"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id C3FDE8637C; Thu, 1 Jun 2023 18:24:55 +0200 (CEST) Received: from mail-il1-x12e.google.com (mail-il1-x12e.google.com [IPv6:2607:f8b0:4864:20::12e]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 7CB878632A for ; Thu, 1 Jun 2023 18:24:49 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=sjg@chromium.org Received: by mail-il1-x12e.google.com with SMTP id e9e14a558f8ab-33bbc91dcb7so4222815ab.3 for ; Thu, 01 Jun 2023 09:24:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1685636689; x=1688228689; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=3Zuv9xE5x8W5FYKc8NzyVyCqGA4o+LCoEc9+XcttuxY=; b=COnVAdjItTDectkLJC8W1/23ita9mqaoKs2crFXdYn5Nz46xNQ5ldBJvEMW0U5Xcd5 ybRTZYTvfwjCKFOTAeOkxuY7o1N/S5z9mJ3h4qZAh+CXJ8PQu/wo/J6ZX5RllQgo+kIr OI7PiKjX/hhx4moHtyxCLQr1Byvr9X/itV+9Y= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1685636689; x=1688228689; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=3Zuv9xE5x8W5FYKc8NzyVyCqGA4o+LCoEc9+XcttuxY=; b=DGPscKL4Ona/m6u3ytj/XZ9cw4dpimrGAEtd2CLcglgXi3qtMxOaqutuLpX68sTtzF Ouf8XnLYBQOrn+RdlwV/t/WrushRntH2tNmfKvfNpkDsXEr0+vMwV3WCIXDTCyYbvqTq mwgxf58QXKW2y3KIUfDYYUSiUvtW5Ik2FWM6MWX439H8E8OOQuHillNwtfCFKeQ33Kui NxNdpaokKwhZzUYVg4FaD4HIj1rLjbGMNSqzKAoIcTpyKy4a1OdPwtRxkjqG5zfoSxVz z0fw2wrOEkh86bDXsvfH7laWyQAURh4dzqEJFfO2dRfld9yzRgUghq1iR10ixpnR13ww CUvQ== X-Gm-Message-State: AC+VfDxnTl4fEVVq+515yHCb1A9vo4iqA1anRObHo2jvBeeZ3Gts7XDb G3328NgNcWagbWCjZE4ZO62k2Gjj2SPYGlFiuLo= X-Google-Smtp-Source: ACHHUZ42HJiLTVvcTI3WglphGfvmiUkgKIAfqlAT0fJ6dYOee3qbKwokyZKIv0yT8U6bkKUaDO+GCA== X-Received: by 2002:a92:d986:0:b0:33a:a518:653f with SMTP id r6-20020a92d986000000b0033aa518653fmr7120018iln.15.1685636688957; Thu, 01 Jun 2023 09:24:48 -0700 (PDT) Received: from sjg1.lan (c-73-14-173-85.hsd1.co.comcast.net. [73.14.173.85]) by smtp.gmail.com with ESMTPSA id l1-20020a922901000000b0033a6e7ee4e3sm3862098ilg.1.2023.06.01.09.24.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 01 Jun 2023 09:24:48 -0700 (PDT) From: Simon Glass To: U-Boot Mailing List Cc: Heinrich Schuchardt , Tom Rini , Simon Glass Subject: [PATCH 26/40] expo: Use flags for objects Date: Thu, 1 Jun 2023 10:22:50 -0600 Message-ID: <20230601162404.220488-25-sjg@chromium.org> X-Mailer: git-send-email 2.41.0.rc0.172.g3f132b7071-goog In-Reply-To: <20230601162404.220488-1-sjg@chromium.org> References: <20230601162404.220488-1-sjg@chromium.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.8 at phobos.denx.de X-Virus-Status: Clean We currently have just a 'hide' property for each object. In preparation for adding more properties, convert the struct to use a flags value, instead of individual booleans. This is more extensible. Signed-off-by: Simon Glass --- boot/scene.c | 17 +++++++++++++++-- boot/scene_internal.h | 11 +++++++++++ include/expo.h | 13 +++++++++++-- test/boot/expo.c | 6 +++--- 4 files changed, 40 insertions(+), 7 deletions(-) diff --git a/boot/scene.c b/boot/scene.c index 8033d77fb266..dd1472d4f9aa 100644 --- a/boot/scene.c +++ b/boot/scene.c @@ -208,13 +208,26 @@ int scene_obj_set_pos(struct scene *scn, uint id, int x, int y) } int scene_obj_set_hide(struct scene *scn, uint id, bool hide) +{ + int ret; + + ret = scene_obj_flag_clrset(scn, id, SCENEOF_HIDE, + hide ? SCENEOF_HIDE : 0); + if (ret) + return log_msg_ret("flg", ret); + + return 0; +} + +int scene_obj_flag_clrset(struct scene *scn, uint id, uint clr, uint set) { struct scene_obj *obj; obj = scene_obj_find(scn, id, SCENEOBJT_NONE); if (!obj) return log_msg_ret("find", -ENOENT); - obj->hide = hide; + obj->flags &= ~clr; + obj->flags |= set; return 0; } @@ -358,7 +371,7 @@ int scene_render(struct scene *scn) int ret; list_for_each_entry(obj, &scn->obj_head, sibling) { - if (!obj->hide) { + if (!(obj->flags & SCENEOF_HIDE)) { ret = scene_obj_render(obj, exp->text_mode); if (ret && ret != -ENOTSUPP) return log_msg_ret("ren", ret); diff --git a/boot/scene_internal.h b/boot/scene_internal.h index 9f173dd749f0..24a2ba6a6a3d 100644 --- a/boot/scene_internal.h +++ b/boot/scene_internal.h @@ -54,6 +54,17 @@ void *scene_obj_find(struct scene *scn, uint id, enum scene_obj_t type); int scene_obj_add(struct scene *scn, const char *name, uint id, enum scene_obj_t type, uint size, struct scene_obj **objp); +/** + * scene_obj_flag_clrset() - Adjust object flags + * + * @scn: Scene to update + * @id: ID of object to update + * @clr: Bits to clear in the object's flags + * @set: Bits to set in the object's flags + * Returns 0 if OK, -ENOENT if the object was not found + */ +int scene_obj_flag_clrset(struct scene *scn, uint id, uint clr, uint set); + /** * scene_menu_arrange() - Set the position of things in the menu * diff --git a/include/expo.h b/include/expo.h index 5135954ba139..b6777cebcbec 100644 --- a/include/expo.h +++ b/include/expo.h @@ -137,6 +137,15 @@ struct scene_dim { int h; }; +/** + * enum scene_obj_flags_t - flags for objects + * + * @SCENEOF_HIDE: object should be hidden + */ +enum scene_obj_flags_t { + SCENEOF_HIDE = 1 << 0, +}; + /** * struct scene_obj - information about an object in a scene * @@ -145,7 +154,7 @@ struct scene_dim { * @id: ID number of the object * @type: Type of this object * @dim: Dimensions for this object - * @hide: true if the object should be hidden + * @flags: Flags for this object * @sibling: Node to link this object to its siblings */ struct scene_obj { @@ -154,7 +163,7 @@ struct scene_obj { uint id; enum scene_obj_t type; struct scene_dim dim; - bool hide; + int flags; struct list_head sibling; }; diff --git a/test/boot/expo.c b/test/boot/expo.c index 10cb7b246f3f..5088776f7bd5 100644 --- a/test/boot/expo.c +++ b/test/boot/expo.c @@ -372,7 +372,7 @@ static int expo_object_menu(struct unit_test_state *uts) ut_asserteq(-4, prev1->obj.dim.x); ut_asserteq(menu->obj.dim.y + 32, prev1->obj.dim.y); - ut_asserteq(false, prev1->obj.hide); + ut_asserteq(false, prev1->obj.flags & SCENEOF_HIDE); expo_destroy(exp); @@ -488,10 +488,10 @@ static int expo_render_image(struct unit_test_state *uts) /* make sure only the preview for the second item is shown */ obj = scene_obj_find(scn, ITEM1_PREVIEW, SCENEOBJT_NONE); - ut_asserteq(true, obj->hide); + ut_asserteq(true, obj->flags & SCENEOF_HIDE); obj = scene_obj_find(scn, ITEM2_PREVIEW, SCENEOBJT_NONE); - ut_asserteq(false, obj->hide); + ut_asserteq(false, obj->flags & SCENEOF_HIDE); /* select it */ ut_assertok(expo_send_key(exp, BKEY_SELECT)); -- 2.41.0.rc0.172.g3f132b7071-goog