Igt-dev Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: John Harrison <John.Harrison@Igalia.com>
To: igt-dev@lists.freedesktop.org
Cc: Santhosh Reddy Guddati <santhosh.reddy.guddati@intel.com>,
	Suraj Kandpal <suraj.kandpal@intel.com>
Subject: [PATCH i-g-t v3 1/4] tools/intel_hdcp: Fix status rendering
Date: Mon, 13 Apr 2026 16:36:26 -0700	[thread overview]
Message-ID: <20260413233629.771034-2-John.Harrison@Igalia.com> (raw)
In-Reply-To: <20260413233629.771034-1-John.Harrison@Igalia.com>

The time was being drawn twice and the position of the text was based
on magic numbers rather than the font size. Which meant it could move
to different places depending upon the screen resolution (as the font
size is calculated based on the screen size).

CC: Santhosh Reddy Guddati <santhosh.reddy.guddati@intel.com>
CC: Suraj Kandpal <suraj.kandpal@intel.com>
Signed-off-by: John Harrison <John.Harrison@Igalia.com>
---
 tools/intel_hdcp.c | 34 +++++++++++++---------------------
 1 file changed, 13 insertions(+), 21 deletions(-)

diff --git a/tools/intel_hdcp.c b/tools/intel_hdcp.c
index 266ee1968..c9968f329 100644
--- a/tools/intel_hdcp.c
+++ b/tools/intel_hdcp.c
@@ -470,7 +470,7 @@ static void *keypress_thread(void *arg)
 
 static void *video_player_thread(void *arg)
 {
-	double font_size, x, y;
+	double font_size, x, y, edge_gap;
 	struct igt_fb fb;
 	cairo_t *cr;
 	igt_plane_t *primary;
@@ -528,29 +528,13 @@ static void *video_player_thread(void *arg)
 
 		draw_menu_text(cr, data);
 
-		current_time = time(NULL);
-		elapsed = current_time - data->video_start_time;
-		minutes = elapsed / 60;
-		seconds = elapsed % 60;
-		snprintf(timer_str, sizeof(timer_str), "%02d:%02d", minutes, seconds);
-
 		cairo_select_font_face(cr, "Helvetica", CAIRO_FONT_SLANT_NORMAL,
 				       CAIRO_FONT_WEIGHT_BOLD);
 		cairo_set_source_rgb(cr, 1.0, 1.0, 1.0);
 		font_size = data->height / 12.0;
-		cairo_set_font_size(cr, font_size / 2.0);
-		cairo_text_extents(cr, timer_str, &ext);
-		cairo_move_to(cr, data->width - ext.width - 20, data->height - 20);
-		cairo_show_text(cr, timer_str);
-
-		/* Draw HDCP status above timer */
-		cairo_set_font_size(cr, font_size);
-		cairo_text_extents(cr, hdcp_str, &ext);
-		x = data->width - ext.width - 20;
-		y = data->height - ext.height - 60;
-
-		cairo_move_to(cr, x, y);
-		cairo_show_text(cr, hdcp_str);
+		edge_gap = font_size / 5;
+		x = data->width - edge_gap;
+		y = data->height - edge_gap;
 
 		/* Add timer in bottom-right corner */
 		current_time = time(NULL);
@@ -561,8 +545,16 @@ static void *video_player_thread(void *arg)
 
 		cairo_set_font_size(cr, font_size / 2.0);
 		cairo_text_extents(cr, timer_str, &ext);
-		cairo_move_to(cr, data->width - ext.width - 20, data->height - 20);
+		cairo_move_to(cr, x - ext.width, y);
 		cairo_show_text(cr, timer_str);
+		y -= ext.height + edge_gap;
+
+		/* Draw HDCP status above timer */
+		cairo_set_font_size(cr, font_size);
+		cairo_text_extents(cr, hdcp_str, &ext);
+		cairo_move_to(cr, x - ext.width, y);
+		cairo_show_text(cr, hdcp_str);
+		y -= ext.height + edge_gap;
 
 		cairo_destroy(cr);
 
-- 
2.43.0


  reply	other threads:[~2026-04-13 23:38 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-04-13 23:36 [PATCH i-g-t v3 0/4] tool/intel_hdcp: Fix flickering and show actual HDCP status John Harrison
2026-04-13 23:36 ` John Harrison [this message]
2026-04-14 15:55   ` [PATCH i-g-t v3 1/4] tools/intel_hdcp: Fix status rendering Kamil Konieczny
2026-04-13 23:36 ` [PATCH i-g-t v3 2/4] tools/intel_hdcp: Move text rendering into helper function John Harrison
2026-04-14 16:03   ` Kamil Konieczny
2026-04-13 23:36 ` [PATCH i-g-t v3 3/4] tools/intel_hdcp: Show actual HDCP status John Harrison
2026-04-14  2:55   ` Kandpal, Suraj
2026-04-14 16:04   ` Kamil Konieczny
2026-04-13 23:36 ` [PATCH i-g-t v3 4/4] tools/intel_hdcp: Fix flickering when changing HDCP state John Harrison
2026-04-14  2:56   ` Kandpal, Suraj
2026-04-14  2:55 ` ✓ Xe.CI.BAT: success for tool/intel_hdcp: Fix flickering and show actual HDCP status (rev3) Patchwork
2026-04-14  3:01 ` ✓ i915.CI.BAT: " Patchwork
2026-04-14  6:50 ` ✓ Xe.CI.FULL: " Patchwork
2026-04-14  9:35 ` ✓ i915.CI.Full: " Patchwork
2026-04-14 16:48 ` [PATCH i-g-t v3 0/4] tool/intel_hdcp: Fix flickering and show actual HDCP status Kamil Konieczny
2026-04-14 17:06   ` John Harrison

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260413233629.771034-2-John.Harrison@Igalia.com \
    --to=john.harrison@igalia.com \
    --cc=igt-dev@lists.freedesktop.org \
    --cc=santhosh.reddy.guddati@intel.com \
    --cc=suraj.kandpal@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox