<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
<style type="text/css" style="display:none;"> P {margin-top:0;margin-bottom:0;} </style>
</head>
<body dir="ltr">
<p style="font-family:Arial;font-size:10pt;color:#0000FF;margin:5pt;" align="Left">
[AMD Official Use Only]<br>
</p>
<br>
<div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);">
<br>
</div>
<div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
This series is:
<div><br>
</div>
Reviewed-by: Aurabindo Pillai <aurabindo.pillai@amd.com><br>
</div>
<div id="Signature">
<div>
<div></div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
--</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<br>
</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
Regards,</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
Jay<br>
</div>
</div>
</div>
</div>
<div id="appendonsend"></div>
<hr style="display:inline-block;width:98%" tabindex="-1">
<div id="divRplyFwdMsg" dir="ltr"><font face="Calibri, sans-serif" style="font-size:11pt" color="#000000"><b>From:</b> Zhang, Dingchen (David) <Dingchen.Zhang@amd.com><br>
<b>Sent:</b> Monday, April 25, 2022 11:36 AM<br>
<b>To:</b> igt-dev@lists.freedesktop.org <igt-dev@lists.freedesktop.org><br>
<b>Cc:</b> Siqueira, Rodrigo <Rodrigo.Siqueira@amd.com>; Wentland, Harry <Harry.Wentland@amd.com>; Li, Sun peng (Leo) <Sunpeng.Li@amd.com>; Pillai, Aurabindo <Aurabindo.Pillai@amd.com>; Lin, Wayne <Wayne.Lin@amd.com><br>
<b>Subject:</b> [PATCH v3 1/4] tests/amdgpu/amd_psr: add helper to draw cursor pattern</font>
<div> </div>
</div>
<div class="BodyFragment"><font size="2"><span style="font-size:11pt;">
<div class="PlainText">[why & how]<br>
For amdgpu PSR-SU validation, we'd create and test cursor update<br>
use case as well. To emulate a mouse-like cursor movement, we'd<br>
define a helper to draw a cursor pattern.<br>
<br>
- helper draw the cursor pattern as an 45-degrees rotated arrow<br>
- for the region of arrow, set alpha to 1 to make cursor foreground<br>
and always on the top<br>
- for rest of the non-arrow region, set alpha to 0 to make it as<br>
background<br>
<br>
Cc: Rodrigo Siqueira <rodrigo.siqueira@amd.com><br>
Cc: Harry Wentland <harry.wentland@amd.com><br>
Cc: Leo Li <sunpeng.li@amd.com><br>
Cc: Jay Pillai <aurabindo.pillai@amd.com><br>
Cc: Wayne Lin <wayne.lin@amd.com><br>
<br>
Signed-off-by: David Zhang <dingchen.zhang@amd.com><br>
---<br>
tests/amdgpu/amd_psr.c | 47 ++++++++++++++++++++++++++++++++++++++++++<br>
1 file changed, 47 insertions(+)<br>
<br>
diff --git a/tests/amdgpu/amd_psr.c b/tests/amdgpu/amd_psr.c<br>
index d4bfb7bb..e3a2cb4a 100644<br>
--- a/tests/amdgpu/amd_psr.c<br>
+++ b/tests/amdgpu/amd_psr.c<br>
@@ -81,6 +81,53 @@ static void draw_color_alpha(igt_fb_t *fb, int x, int y, int w, int h,<br>
igt_put_cairo_ctx(cr);<br>
}<br>
<br>
+/* draw a cursor pattern assuming the FB given is square w/ FORMAT ARGB */<br>
+static void draw_color_cursor(igt_fb_t *fb, int size, double r, double g, double b)<br>
+{<br>
+ cairo_t *cr = igt_get_cairo_ctx(fb->fd, fb);<br>
+ int x, y, line_w;<br>
+<br>
+ cairo_set_operator(cr, CAIRO_OPERATOR_SOURCE);<br>
+<br>
+ /*<br>
+ * draw cursor<br>
+ * recall that alpha blending value:<br>
+ * - 0, output pixel is the background<br>
+ * - 1, output pixel is simply the foreground<br>
+ * - (0, 1), mix of background + foreground<br>
+ */<br>
+<br>
+ /* set cursor FB to background first */<br>
+ igt_paint_color_alpha(cr, 0, 0, size, size, 1.0, 1.0, 1.0, .0);<br>
+<br>
+ /*<br>
+ * draw cursur pattern w/ alpha set to 1<br>
+ * - 1. draw triangle part<br>
+ * - 2. draw rectangle part<br>
+ */<br>
+ for (x = y = 0, line_w = size / 2; line_w > 0; ++y, --line_w)<br>
+ igt_paint_color_alpha(cr, x, y, line_w, 1, r, g, b, 1.0);<br>
+<br>
+ /*<br>
+ * draw rectangle part, split into three geometry parts<br>
+ * - triangle<br>
+ * - rhombus<br>
+ * - reversed triangle<br>
+ */<br>
+ for (x = size * 3 / 8, y = size / 8, line_w = 1; y < size * 3 / 8; --x, ++y, line_w += 2)<br>
+ igt_paint_color_alpha(cr, x, y, line_w, 1, r, g, b, 1.0);<br>
+<br>
+ for (x = size / 8, y = size * 3 / 8; y < size * 3 / 4; ++x, ++y)<br>
+ igt_paint_color_alpha(cr, x, y, line_w, 1, r, g, b, 1.0);<br>
+<br>
+ for (; line_w > 0; ++x, ++y, line_w -= 2)<br>
+ igt_paint_color_alpha(cr, x, y, line_w, 1, r, g, b, 1.0);<br>
+<br>
+ cairo_set_operator(cr, CAIRO_OPERATOR_OVER);<br>
+<br>
+ igt_put_cairo_ctx(cr);<br>
+}<br>
+<br>
/* Common test setup. */<br>
static void test_init(data_t *data)<br>
{<br>
-- <br>
2.25.1<br>
<br>
</div>
</span></font></div>
</div>
</body>
</html>