[Intel-gfx] [PATCH i-g-t 3/5] lib: fb: add igt_paint_color_gradient_range

Lionel Landwerlin lionel.g.landwerlin at intel.com
Fri Feb 19 15:46:12 UTC 2016


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

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

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);
diff --git a/lib/igt_kms.c b/lib/igt_kms.c
index 22996d5..97ee156 100644
--- a/lib/igt_kms.c
+++ b/lib/igt_kms.c
@@ -1185,7 +1185,7 @@ void igt_display_init(igt_display_t *display, int drm_fd)
 						  NULL,
 					  NULL);
 				get_crtc_property(display->drm_fd, output->config.crtc->crtc_id,
-						  "CTM_MATRIX",
+						  "CTM",
 						  &pipe->ctm_property,
 						  NULL,
 						  NULL);
-- 
2.7.0



More information about the Intel-gfx mailing list