From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from NAM12-BN8-obe.outbound.protection.outlook.com (mail-bn8nam12on2071.outbound.protection.outlook.com [40.107.237.71]) by gabe.freedesktop.org (Postfix) with ESMTPS id 3A37710F8C1 for ; Mon, 25 Apr 2022 15:52:15 +0000 (UTC) From: "Pillai, Aurabindo" To: "Zhang, Dingchen (David)" , "igt-dev@lists.freedesktop.org" Date: Mon, 25 Apr 2022 15:52:12 +0000 Message-ID: References: <20220425153654.752046-1-dingchen.zhang@amd.com> <20220425153654.752046-2-dingchen.zhang@amd.com> In-Reply-To: <20220425153654.752046-2-dingchen.zhang@amd.com> Content-Language: en-US Content-Type: multipart/alternative; boundary="_000_CH0PR12MB52848E95A39A26C10E5A47C18BF89CH0PR12MB5284namp_" MIME-Version: 1.0 Subject: Re: [igt-dev] [PATCH v3 1/4] tests/amdgpu/amd_psr: add helper to draw cursor pattern List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: igt-dev-bounces@lists.freedesktop.org Sender: "igt-dev" List-ID: --_000_CH0PR12MB52848E95A39A26C10E5A47C18BF89CH0PR12MB5284namp_ Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable [AMD Official Use Only] This series is: Reviewed-by: Aurabindo Pillai -- Regards, Jay ________________________________ From: Zhang, Dingchen (David) Sent: Monday, April 25, 2022 11:36 AM To: igt-dev@lists.freedesktop.org Cc: Siqueira, Rodrigo ; Wentland, Harry ; Li, Sun peng (Leo) ; Pillai, Aurabindo= ; Lin, Wayne Subject: [PATCH v3 1/4] tests/amdgpu/amd_psr: add helper to draw cursor pat= tern [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 Cc: Harry Wentland Cc: Leo Li Cc: Jay Pillai Cc: Wayne Lin Signed-off-by: David Zhang --- 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 =3D 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 =3D y =3D 0, line_w =3D 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 =3D size * 3 / 8, y =3D size / 8, line_w =3D 1; y < size * 3= / 8; --x, ++y, line_w +=3D 2) + igt_paint_color_alpha(cr, x, y, line_w, 1, r, g, b, 1.0); + + for (x =3D size / 8, y =3D 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 -=3D 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 --_000_CH0PR12MB52848E95A39A26C10E5A47C18BF89CH0PR12MB5284namp_ Content-Type: text/html; charset="us-ascii" Content-Transfer-Encoding: quoted-printable

[AMD Official Use Only]



This series is:

Reviewed-by: Aurabindo Pillai <aurabindo.pillai@amd.com>
--

Regards,
Jay

From: Zhang, Dingchen (Davi= d) <Dingchen.Zhang@amd.com>
Sent: Monday, April 25, 2022 11:36 AM
To: igt-dev@lists.freedesktop.org <igt-dev@lists.freedesktop.org&= gt;
Cc: Siqueira, Rodrigo <Rodrigo.Siqueira@amd.com>; Wentland, Ha= rry <Harry.Wentland@amd.com>; Li, Sun peng (Leo) <Sunpeng.Li@amd.c= om>; Pillai, Aurabindo <Aurabindo.Pillai@amd.com>; Lin, Wayne <= Wayne.Lin@amd.com>
Subject: [PATCH v3 1/4] tests/amdgpu/amd_psr: add helper to draw cur= sor pattern
 
[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 =3D 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 va= lue:
+        * - 0, output pixel is the back= ground
+        * - 1, output pixel is simply t= he 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 =3D y =3D 0, line_w =3D size /= 2; line_w > 0; ++y, --line_w)
+            &n= bsp;  igt_paint_color_alpha(cr, x, y, line_w, 1, r, g, b, 1.0);
+
+       /*
+        * draw rectangle part, split in= to three geometry parts
+        * - triangle
+        * - rhombus
+        * - reversed triangle
+        */
+       for (x =3D size * 3 / 8, y =3D size /= 8, line_w =3D 1; y < size * 3 / 8; --x, ++y, line_w +=3D 2)
+            &n= bsp;  igt_paint_color_alpha(cr, x, y, line_w, 1, r, g, b, 1.0);
+
+       for (x =3D size / 8, y =3D size * 3 /= 8; y < size * 3 / 4; ++x, ++y)
+            &n= bsp;  igt_paint_color_alpha(cr, x, y, line_w, 1, r, g, b, 1.0);
+
+       for (; line_w > 0; ++x, ++y, line_= w -=3D 2)
+            &n= bsp;  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

--_000_CH0PR12MB52848E95A39A26C10E5A47C18BF89CH0PR12MB5284namp_--