From patchwork Thu Feb 25 17:16:11 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lionel Landwerlin X-Patchwork-Id: 8425341 Return-Path: X-Original-To: patchwork-intel-gfx@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 119559F372 for ; Thu, 25 Feb 2016 17:17:07 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 417B320160 for ; Thu, 25 Feb 2016 17:17:06 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id 6DF572011D for ; Thu, 25 Feb 2016 17:17:04 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 216346E92B; Thu, 25 Feb 2016 17:17:04 +0000 (UTC) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by gabe.freedesktop.org (Postfix) with ESMTP id 7A8846E92B for ; Thu, 25 Feb 2016 17:17:02 +0000 (UTC) Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by orsmga103.jf.intel.com with ESMTP; 25 Feb 2016 09:16:52 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.22,498,1449561600"; d="scan'208";a="54733942" Received: from sthoene-mobl.ger.corp.intel.com (HELO ivy.ger.corp.intel.com) ([10.252.33.122]) by fmsmga004.fm.intel.com with ESMTP; 25 Feb 2016 09:16:47 -0800 From: Lionel Landwerlin To: intel-gfx@lists.freedesktop.org Date: Thu, 25 Feb 2016 17:16:11 +0000 Message-Id: <1456420573-4693-4-git-send-email-lionel.g.landwerlin@intel.com> X-Mailer: git-send-email 2.7.0 In-Reply-To: <1456420573-4693-1-git-send-email-lionel.g.landwerlin@intel.com> References: <1456420573-4693-1-git-send-email-lionel.g.landwerlin@intel.com> Subject: [Intel-gfx] [PATCH i-g-t 3/5] lib: fb: add igt_paint_color_gradient_range X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP This is a helper to draw a gradient between 2 colors. Signed-off-by: Lionel Landwerlin --- 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);