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 2/4] tools/intel_hdcp: Move text rendering into helper function
Date: Mon, 13 Apr 2026 16:36:27 -0700 [thread overview]
Message-ID: <20260413233629.771034-3-John.Harrison@Igalia.com> (raw)
In-Reply-To: <20260413233629.771034-1-John.Harrison@Igalia.com>
Rather than duplicate the text rendering calculations over and over,
add a helper function.
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 | 25 +++++++++++++------------
1 file changed, 13 insertions(+), 12 deletions(-)
diff --git a/tools/intel_hdcp.c b/tools/intel_hdcp.c
index c9968f329..4dfeda594 100644
--- a/tools/intel_hdcp.c
+++ b/tools/intel_hdcp.c
@@ -468,6 +468,17 @@ static void *keypress_thread(void *arg)
return NULL;
}
+static double draw_text_right(cairo_t *cr, double font_size, double x, double y, const char *str )
+{
+ cairo_text_extents_t ext;
+
+ cairo_set_font_size(cr, font_size);
+ cairo_text_extents(cr, str, &ext);
+ cairo_move_to(cr, x - ext.width, y);
+ cairo_show_text(cr, str);
+ return y - ext.height - (font_size / 4);
+}
+
static void *video_player_thread(void *arg)
{
double font_size, x, y, edge_gap;
@@ -476,7 +487,6 @@ static void *video_player_thread(void *arg)
igt_plane_t *primary;
const char *hdcp_str;
double bg_r = 0.0, bg_g = 0.0, bg_b = 0.0;
- cairo_text_extents_t ext;
enum hdcp_type cur_type, prev_type;
data_t *data;
char timer_str[32];
@@ -542,19 +552,10 @@ static void *video_player_thread(void *arg)
minutes = elapsed / 60;
seconds = elapsed % 60;
snprintf(timer_str, sizeof(timer_str), "%02d:%02d", minutes, seconds);
-
- cairo_set_font_size(cr, font_size / 2.0);
- cairo_text_extents(cr, timer_str, &ext);
- cairo_move_to(cr, x - ext.width, y);
- cairo_show_text(cr, timer_str);
- y -= ext.height + edge_gap;
+ y = draw_text_right(cr, font_size / 2.0, x, y, timer_str );
/* 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;
+ y = draw_text_right(cr, font_size, x, y, hdcp_str );
cairo_destroy(cr);
--
2.43.0
next prev parent 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 ` [PATCH i-g-t v3 1/4] tools/intel_hdcp: Fix status rendering John Harrison
2026-04-14 15:55 ` Kamil Konieczny
2026-04-13 23:36 ` John Harrison [this message]
2026-04-14 16:03 ` [PATCH i-g-t v3 2/4] tools/intel_hdcp: Move text rendering into helper function 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-3-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