All of lore.kernel.org
 help / color / mirror / Atom feed
From: David Zhang <dingchen.zhang@amd.com>
To: <igt-dev@lists.freedesktop.org>
Subject: [igt-dev] [PATCH v3 1/4] tests/amdgpu/amd_psr: add helper to draw cursor pattern
Date: Wed, 20 Apr 2022 17:58:31 -0400	[thread overview]
Message-ID: <20220420215834.30467-2-dingchen.zhang@amd.com> (raw)
In-Reply-To: <20220420215834.30467-1-dingchen.zhang@amd.com>

[why & how]
For amdgpu PSR-SU validation, we'd create and test cursor update
use case as well. To emulate a mouse-like cursor movement, we'd
define a helper to draw a cursor pattern.

- helper draw the cursor pattern as an 45-degrees rotated arrow
- for the region of arrow, set alpha to 1 to make cursor foreground
  and always on the top
- for rest of the non-arrow region, set alpha to 0 to make it as
  background

Cc: Rodrigo Siqueira <rodrigo.siqueira@amd.com>
Cc: Harry Wentland <harry.wentland@amd.com>
Cc: Leo Li <sunpeng.li@amd.com>
Cc: Jay Pillai <aurabindo.pillai@amd.com>
Cc: Wayne Lin <wayne.lin@amd.com>

Signed-off-by: David Zhang <dingchen.zhang@amd.com>
---
 tests/amdgpu/amd_psr.c | 47 ++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 47 insertions(+)

diff --git a/tests/amdgpu/amd_psr.c b/tests/amdgpu/amd_psr.c
index d4bfb7bb..e3a2cb4a 100644
--- a/tests/amdgpu/amd_psr.c
+++ b/tests/amdgpu/amd_psr.c
@@ -81,6 +81,53 @@ static void draw_color_alpha(igt_fb_t *fb, int x, int y, int w, int h,
 	igt_put_cairo_ctx(cr);
 }
 
+/* draw a cursor pattern assuming the FB given is square w/ FORMAT ARGB */
+static void draw_color_cursor(igt_fb_t *fb, int size, double r, double g, double b)
+{
+	cairo_t *cr = igt_get_cairo_ctx(fb->fd, fb);
+	int x, y, line_w;
+
+	cairo_set_operator(cr, CAIRO_OPERATOR_SOURCE);
+
+	/*
+	 * draw cursor
+	 * recall that alpha blending value:
+	 * - 0, output pixel is the background
+	 * - 1, output pixel is simply the foreground
+	 * - (0, 1), mix of background + foreground
+	 */
+
+	/* set cursor FB to background first */
+	igt_paint_color_alpha(cr, 0, 0, size, size, 1.0, 1.0, 1.0, .0);
+
+	/*
+	 * draw cursur pattern w/ alpha set to 1
+	 * - 1. draw triangle part
+	 * - 2. draw rectangle part
+	 */
+	for (x = y = 0, line_w = size / 2; line_w > 0; ++y, --line_w)
+		igt_paint_color_alpha(cr, x, y, line_w, 1, r, g, b, 1.0);
+
+	/*
+	 * draw rectangle part, split into three geometry parts
+	 * - triangle
+	 * - rhombus
+	 * - reversed triangle
+	 */
+	for (x = size * 3 / 8, y = size / 8, line_w = 1; y < size * 3 / 8; --x, ++y, line_w += 2)
+		igt_paint_color_alpha(cr, x, y, line_w, 1, r, g, b, 1.0);
+
+	for (x = size / 8, y = size * 3 / 8; y < size * 3 / 4; ++x, ++y)
+		igt_paint_color_alpha(cr, x, y, line_w, 1, r, g, b, 1.0);
+
+	for (; line_w > 0; ++x, ++y, line_w -= 2)
+		igt_paint_color_alpha(cr, x, y, line_w, 1, r, g, b, 1.0);
+
+	cairo_set_operator(cr, CAIRO_OPERATOR_OVER);
+
+	igt_put_cairo_ctx(cr);
+}
+
 /* Common test setup. */
 static void test_init(data_t *data)
 {
-- 
2.25.1

  reply	other threads:[~2022-04-20 21:58 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-04-20 21:58 [igt-dev] [PATCH v3 0/4] amdgpu PSR-SU cursor move test cases David Zhang
2022-04-20 21:58 ` David Zhang [this message]
2022-04-20 21:58 ` [igt-dev] [PATCH v3 2/4] tests/amdgpu/amd_psr: set visual-confirm option required argument David Zhang
2022-04-20 21:58 ` [igt-dev] [PATCH v3 3/4] tests/amdgpu/amd_psr: add PSR-SU cursor movement test case David Zhang
2022-04-20 21:58 ` [igt-dev] [PATCH v3 4/4] tests/amdgpu/amd_psr: add PSR-SU test case for cursor move + MPO scenario David Zhang
2022-04-20 22:45 ` [igt-dev] ✓ Fi.CI.BAT: success for amdgpu PSR-SU cursor move test cases Patchwork
2022-04-21  1:46 ` [igt-dev] ✗ Fi.CI.IGT: failure " Patchwork
2022-04-25 15:36 [igt-dev] [PATCH v3 0/4] " David Zhang
2022-04-25 15:36 ` [igt-dev] [PATCH v3 1/4] tests/amdgpu/amd_psr: add helper to draw cursor pattern David Zhang
2022-04-25 15:52   ` Pillai, Aurabindo

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=20220420215834.30467-2-dingchen.zhang@amd.com \
    --to=dingchen.zhang@amd.com \
    --cc=igt-dev@lists.freedesktop.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.