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/4] lib: fb: add igt_paint_color_gradient_range
Date: Mon,  1 Feb 2016 15:34:51 +0000	[thread overview]
Message-ID: <1454340892-21408-4-git-send-email-lionel.g.landwerlin@intel.com> (raw)
In-Reply-To: <1454340892-21408-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 5f23136..bbafcd9 100644
--- a/lib/igt_fb.c
+++ b/lib/igt_fb.c
@@ -277,6 +277,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 4e6a769..469fbbc 100644
--- a/lib/igt_fb.h
+++ b/lib/igt_fb.h
@@ -105,6 +105,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.7.0

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

  parent reply	other threads:[~2016-02-01 15:35 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-02-01 15:34 [PATCH i-g-t 0/4] New pipe level color management tests V3 Lionel Landwerlin
2016-02-01 15:34 ` [PATCH i-g-t 1/4] lib: kms: add crtc_id to igt_pipe_t Lionel Landwerlin
2016-02-01 15:34 ` [PATCH i-g-t 2/4] lib: kms: add helpers for color management properties on pipes Lionel Landwerlin
2016-02-01 15:34 ` Lionel Landwerlin [this message]
2016-02-01 15:34 ` [PATCH i-g-t 4/4] tests/kms_color: New test for pipe level color management Lionel Landwerlin
  -- strict thread matches above, loose matches on Subject: below --
2016-01-22 12:14 [PATCH i-g-t 0/4] New pipe level color management tests V2 Lionel Landwerlin
2016-01-22 12:14 ` [PATCH i-g-t 3/4] lib: fb: add igt_paint_color_gradient_range Lionel Landwerlin
2016-01-21 15:11 [PATCH i-g-t 0/4] New pipe level color management tests Lionel Landwerlin
2016-01-21 15:11 ` [PATCH i-g-t 3/4] 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=1454340892-21408-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.