All of lore.kernel.org
 help / color / mirror / Atom feed
From: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
To: intel-gfx@lists.freedesktop.org
Subject: [PATCH i-g-t 3/6] lib: fb: add igt_paint_color_gradient_range
Date: Fri, 18 Mar 2016 17:33:02 +0000	[thread overview]
Message-ID: <1458322385-25591-4-git-send-email-lionel.g.landwerlin@intel.com> (raw)
In-Reply-To: <1458322385-25591-1-git-send-email-lionel.g.landwerlin@intel.com>

This is a helper to draw a gradient between 2 colors.

Signed-off-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
---
 lib/igt_fb.c | 34 ++++++++++++++++++++++++++++++++++
 lib/igt_fb.h |  3 +++
 2 files changed, 37 insertions(+)

diff --git a/lib/igt_fb.c b/lib/igt_fb.c
index 7b53556..06f4a62 100644
--- a/lib/igt_fb.c
+++ b/lib/igt_fb.c
@@ -282,6 +282,40 @@ igt_paint_color_gradient(cairo_t *cr, int x, int y, int w, int h,
 	cairo_pattern_destroy(pat);
 }
 
+/**
+ * igt_paint_color_gradient_range:
+ * @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
+ * @sr: red value to use as start gradient color
+ * @sg: green value to use as start gradient color
+ * @sb: blue value to use as start gradient color
+ * @er: red value to use as end gradient color
+ * @eg: green value to use as end gradient color
+ * @eb: blue value to use as end gradient color
+ *
+ * This functions draws a gradient into the rectangle which fades in
+ * from one color to the other using the drawing context @cr.
+ */
+void
+igt_paint_color_gradient_range(cairo_t *cr, int x, int y, int w, int h,
+			       double sr, double sg, double sb,
+			       double er, double eg, double eb)
+{
+	cairo_pattern_t *pat;
+
+	pat = cairo_pattern_create_linear(x, y, x + w, y + h);
+	cairo_pattern_add_color_stop_rgba(pat, 1, sr, sg, sb, 1);
+	cairo_pattern_add_color_stop_rgba(pat, 0, er, eg, eb, 1);
+
+	cairo_rectangle(cr, x, y, w, h);
+	cairo_set_source(cr, pat);
+	cairo_fill(cr);
+	cairo_pattern_destroy(pat);
+}
+
 static void
 paint_test_patterns(cairo_t *cr, int width, int height)
 {
diff --git a/lib/igt_fb.h b/lib/igt_fb.h
index 6cfd1bb..e8fe3ac 100644
--- a/lib/igt_fb.h
+++ b/lib/igt_fb.h
@@ -106,6 +106,9 @@ 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,
 				  int r, int g, int b);
+void igt_paint_color_gradient_range(cairo_t *cr, int x, int y, int w, int h,
+				    double sr, double sg, double sb,
+				    double er, double eg, double eb);
 void igt_paint_test_pattern(cairo_t *cr, int width, int height);
 void igt_paint_image(cairo_t *cr, const char *filename,
 			 int dst_x, int dst_y, int dst_width, int dst_height);
-- 
2.8.0.rc3

_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

  parent reply	other threads:[~2016-03-18 17:33 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-03-18 17:32 [PATCH i-g-t 0/6] New pipe level color management tests Lionel Landwerlin
2016-03-18 17:33 ` [PATCH i-g-t 1/6] lib: kms: add crtc_id to igt_pipe_t Lionel Landwerlin
2016-03-18 17:33 ` [PATCH i-g-t 2/6] lib: kms: add helpers for color management properties on pipes Lionel Landwerlin
2016-03-18 17:33 ` Lionel Landwerlin [this message]
2016-03-18 17:33 ` [PATCH i-g-t 4/6] lib: add crc comparison function without an assert Lionel Landwerlin
2016-03-18 17:33 ` [PATCH i-g-t 5/6] tests/kms_color: New test for pipe level color management Lionel Landwerlin
2016-03-18 17:33 ` [PATCH i-g-t 6/6] test/kms_pipe_color: add test to verify legacy ioctl resets GAMMA_LUT Lionel Landwerlin
  -- strict thread matches above, loose matches on Subject: below --
2016-03-11 12:32 [PATCH i-g-t 0/6] New pipe level color management tests Lionel Landwerlin
2016-03-11 12:32 ` [PATCH i-g-t 3/6] lib: fb: add igt_paint_color_gradient_range Lionel Landwerlin
2016-03-10 12:46 [PATCH i-g-t 0/6] New pipe level color management tests Lionel Landwerlin
2016-03-10 12:47 ` [PATCH i-g-t 3/6] lib: fb: add igt_paint_color_gradient_range Lionel Landwerlin

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=1458322385-25591-4-git-send-email-lionel.g.landwerlin@intel.com \
    --to=lionel.g.landwerlin@intel.com \
    --cc=intel-gfx@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.