All of lore.kernel.org
 help / color / mirror / Atom feed
From: "André Almeida" <andrealmeid@igalia.com>
To: igt-dev@lists.freedesktop.org
Cc: petri.latvala@intel.com, kernel-dev@igalia.com, markyacoub@google.com
Subject: [igt-dev] [PATCH i-g-t v2 1/2] lib/igt_fb: Add support for drawing rectangles with random colors
Date: Fri, 20 May 2022 17:35:30 -0300	[thread overview]
Message-ID: <20220520203531.14394-2-andrealmeid@igalia.com> (raw)
In-Reply-To: <20220520203531.14394-1-andrealmeid@igalia.com>

Add support for drawing rectangles with random colors, useful for tests
that you don't mind which color will be used.

Signed-off-by: André Almeida <andrealmeid@igalia.com>
Reviewed-by: Melissa Wen <mwen@igalia.com>
Reviewed-by: Alex Hung <alex.hung@amd.com>
---

Changes from v1:
- Fix function comment typo

 lib/igt_fb.c | 20 ++++++++++++++++++++
 lib/igt_fb.h |  1 +
 2 files changed, 21 insertions(+)

diff --git a/lib/igt_fb.c b/lib/igt_fb.c
index eafbe7fd..5c4648fe 100644
--- a/lib/igt_fb.c
+++ b/lib/igt_fb.c
@@ -1465,6 +1465,26 @@ void igt_paint_color(cairo_t *cr, int x, int y, int w, int h,
 	cairo_fill(cr);
 }
 
+/**
+ * igt_paint_color_rand:
+ * @cr: cairo drawing context
+ * @x: pixel x-coordination of the fill rectangle
+ * @y: pixel y-coordination of the fill rectangle
+ * @w: width of the fill rectangle
+ * @h: height of the fill rectangle
+ *
+ * This functions draws a solid rectangle with random colors using the drawing
+ * context @cr.
+ */
+void igt_paint_color_rand(cairo_t *cr, int x, int y, int w, int h)
+{
+	double r = rand() / (double)RAND_MAX;
+	double g = rand() / (double)RAND_MAX;
+	double b = rand() / (double)RAND_MAX;
+
+	igt_paint_color(cr, x, y, w, h, r, g, b);
+}
+
 /**
  *
  * igt_fill_cts_color_square_framebuffer:
diff --git a/lib/igt_fb.h b/lib/igt_fb.h
index 623a8caa..b3f096fe 100644
--- a/lib/igt_fb.h
+++ b/lib/igt_fb.h
@@ -191,6 +191,7 @@ cairo_t *igt_get_cairo_ctx(int fd, struct igt_fb *fb);
 void igt_put_cairo_ctx(cairo_t *cr);
 void igt_paint_color(cairo_t *cr, int x, int y, int w, int h,
 			 double r, double g, double b);
+void igt_paint_color_rand(cairo_t *cr, int x, int y, int w, int h);
 void igt_paint_color_alpha(cairo_t *cr, int x, int y, int w, int h,
 			       double r, double g, double b, double a);
 void igt_paint_color_gradient(cairo_t *cr, int x, int y, int w, int h,
-- 
2.36.0

  reply	other threads:[~2022-05-20 20:36 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-05-20 20:35 [igt-dev] [PATCH i-g-t v2 0/2] tests/kms_async_flips: Expand test André Almeida
2022-05-20 20:35 ` André Almeida [this message]
2022-05-20 20:35 ` [igt-dev] [PATCH i-g-t v2 2/2] tests/kms_async_flips: Support more vendors André Almeida
2022-05-20 21:30 ` [igt-dev] ✗ GitLab.Pipeline: warning for tests/kms_async_flips: Expand test (rev4) Patchwork
2022-05-20 21:52 ` [igt-dev] ✓ Fi.CI.BAT: success " Patchwork
2022-05-20 23:24 ` [igt-dev] ✓ Fi.CI.IGT: " Patchwork
2022-05-24 13:14 ` [igt-dev] [PATCH i-g-t v2 0/2] tests/kms_async_flips: Expand test Rodrigo Siqueira Jordao
2022-05-24 13:21   ` André Almeida
2022-05-24 15:48   ` Vudum, Lakshminarayana
2022-05-24 16:01     ` Rodrigo Siqueira Jordao

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=20220520203531.14394-2-andrealmeid@igalia.com \
    --to=andrealmeid@igalia.com \
    --cc=igt-dev@lists.freedesktop.org \
    --cc=kernel-dev@igalia.com \
    --cc=markyacoub@google.com \
    --cc=petri.latvala@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 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.